sn1perwild wrote: ↑
The hasMoved variable is only set to false when the window is not active. The window is not active all the time. But, on the times it is active, hasMoved stays as true after being moved.
No, that is not correct. You used
WinExist, not
WinActive, so it will keep moving it as long as the window
exists, whether it is active or not.
sn1perwild wrote: ↑
At least that's my understanding and the script indeed works, the window only changes once per time I activate the window
Not only is that not correct because you used WinExist instead of WinActive, there is nothing in the logic of your script that would have it happen only once. Even if you used WinActive instead, it would keep moving it. Like I said, it keeps changing the value of the hasMoved variable from true to false and from false to true as long as the window exists (or as long as it's active if you end up changing it to WinActive). You have nothing in your script to make it stop moving it after it moved it once. Just follow what lines would execute and tell me where it would stop moving it and why (which you will find if you do it correctly, it won't stop moving it).
sn1perwild wrote: ↑
My concern is how sometimes it doesn't work, so do you think this might have something to do with it?
...
Then if there's an error in the logic, how come it does work all the other times?
Like I said, it could be because you're moving the window every two seconds (even if you're "moving" it in place, you're having Windows perform the move operation), and maybe doing that over and over causes it to lock up somehow.
sn1perwild wrote: ↑
And how can I fix it to work reliably?
You could change the logic to actually have it move once per time it's active and perhaps that would do it. But like I said, just changing it from WinExist to WinActive wouldn't accomplish that because it would keep moving it over and over while it's active. This is all that's needed to have it move exactly once each time it's active, then wait patiently for the next time it's active to move it again:
Code: Select all
Menu, Tray, Icon, Icons\shell32_184.ico
loop {
WinWaitActive, ahk_class ApplicationFrameWindow ahk_exe ApplicationFrameHost.exe
WinMove,,, 2821, 153, 1476, 1044
WinWaitNotActive
}