This is my current AHK script. I'm a newb so it might be a little clunky, but I made a website to test it on quickly, and that worked fine. The idea is have it click a button to launch something, wait 14 seconds for that thing to launch, and then screenshot the thing, and close it down. Ideally it does that over and over again until I say stop (or until 100 loops).
The problem:
The problem is that whenever I try to actually use the program that is called by WinActivate, or even if I dont use WinActivate and just run the script while focused on the specific launcher, it doesn't do the click functions properly. It still takes the screenshots, but wont move the mouse or click. Again, it works fine if I'm focused on google chrome or Windows Explorer, it's just the specific thing that I want to run it on. The program is called Haze launcher. I have tried doing window relative coords and screen relative coords, and neither work. Any help would be greatly appreciated.
Code: Select all
#Include CaptureScreen.ahk
^+r:: ; This creates a hotkey of Control+Shift+R
xCoord := 3690
yCoord := 123
; Set the delay time in milliseconds
delay_time := 14000
; Set the number of times to loop
LoopCount := 100
CoordMode, pixel, Screen
; Loop through the specified number of times
Loop %LoopCount% {
WinActivate, ahk_id 328264
Sleep 50
; Click the button at the specified coordinate
Click %xCoord%, %yCoord%
; Wait for the delay time
Sleep %delay_time%
; Take a screenshot
CaptureScreen(3, 0, "ScarygirlSS\TestShot" A_Now ".png")
; first parameter indicates full screen capture
; change 2nd parameter to 1 if you want mouse cursor in image
; change to desired path. can also change .png to .jpg or other
WinActivate, ahk_id 328264
Click %xCoord%, %yCoord%
; Wait for a short time before continuing the loop
Sleep 5000
}
esc::ExitApp