我试图构建一个基本上简单的脚本:
我写了这个简单的剧本,但是我错过了一些东西,窗户闪烁,我不知道为什么
#NoEnv
#Persistent
SetTitleMatchMode, 2
SetTimer, tableDiff, 1000
firstRun := 0
return
tableDiff:
if (firstRun <> 0)
{
winUnderMouseLast := winUnderMouseCurrent
WinGetTitle, titleLast, ahk_id %winUnderMouseLast%
WinGetClass, classLast, ahk_id %winUnderMouseLast%
WinGetPos, xLast, yLast, wLast, hLast, ahk_id %winUnderMouseLast%
}
else
msgbox, 1st run
MouseGetPos,,,winUnderMouseCurrent
WinGetTitle, titleCurrent, ahk_id %winUnderMouseCurrent%
WinGetClass, classCurrent, ahk_id %winUnderMouseCurrent%
WinGetPos, xCurrent, yCurrent, wCurrent, hCurrent, ahk_id %winUnderMouseCurrent%
If (winUnderMouseLast != winUnderMouseCurrent)
{
winMove, ahk_id %winUnderMouseLast%,,%xLast%,%yLast%
;msgbox, Current %titleCurrent% Last %titleLast%
WinMove, ahk_id %winUnderMouseCurrent%,, 421, 156, 1016, 727
}
firstRun := 1
return
答案 0 :(得分:1)
使用WinWaitNotActive代替计时器:
loop {
winwaitnotactive, % "ahk_id " winExist("A")
mousegetpos,,,id
if (lastID)
winmove, ahk_id %lastID%,, x,y,w,h
wingetpos, x,y,w,h, ahk_id %id%
winmove, ahk_id %id%,, 421, 156, 1016, 727
lastID := id
}