AutoHotKey:WinTitle 是如何工作的?

AutoHotKey: How does the WinTitle work?

我今天才开始玩 AutoHotKey,但卡在了 moving/resizing windows... WinMove 需要一个 WinTitle 但我不知道 WinTitle 是如何工作的。

当我尝试以下代码时:

#SingleInstance force 

#y::

run, notepad
Sleep, 1000
WinGetTitle, window,, A
MsgBox, Active window: %window%
Sleep, 1000
WinMove, window,, 0, 0
MsgBox, %window% moved.

return

记事本没有移到左上角,为什么?
我还尝试将 ID 存储为字符串:program := window WinMove, program,, 0, 0 但这也不起作用。

在您的示例中,"window" 是一个变量,"WinMove" 是一个命令。

命令 始终使用 "traditional syntax"。含义:在命令中使用变量时,必须用百分号将变量括起来:

WinMove, %window%,, 0, 0

编辑:

顺便说一句。

WinGetTitle,window,A

必须

WinGetTitle, window, A

编辑2:

#SingleInstance force 

#y::
run, notepad
WinWait, Untitled - Notepad ;  title - Use Window Spy to find the exact title of this window
; IfWinNotActive, Untitled - Notepad, ,WinActivate, Untitled - Notepad
; WinWaitActive, Untitled - Notepad
Sleep, 200
WinMove, Untitled - Notepad,, 0, 0
return