; Phase 1: Wait for Control + Shift + K to be pressed Phase1: ; Prompt the user to enter the number of clicks InputBox, numClicks, Enter Number of Clicks, Please enter the number of clicks (1-5): numClicks := Clamp(numClicks, 1, 5) ; Clamp the value between 1 and 5 Loop { if (GetKeyState("Control") && GetKeyState("Shift") && GetKeyState("K")) break Sleep 1 } ;MsgBox Phase 1 complete. ; Phase 2: Learning Phase2: Tooltip, Click on the window title to record HWND and title. CoordMode, Mouse, Relative ; Wait for the left mouse button to be pressed KeyWait, LButton, D MouseGetPos, x, y WinGet, hWnd, ID, A WinGetTitle, title, ahk_id %hWnd% ;MsgBox % "HWND: " hWnd "`nTitle: " title ; Store the HWND and title for further use hwnd := hWnd windowTitle := title ; Wait for the left mouse button to be released KeyWait, LButton, U ; Record X and Y coordinates for each click Loop, %numClicks% { Tooltip, Click %A_Index% of %numClicks%. (Press left mouse button) ; Wait for the left mouse button to be pressed KeyWait, LButton, D ; Record the mouse position MouseGetPos, x, y ClickX%A_Index% := x ClickY%A_Index% := y ; Wait for the left mouse button to be released KeyWait, LButton, U Sleep 1 ; Adjust the delay as needed } Tooltip ; Wait for the window to close or timeout timeout := A_TickCount + 5000 ; Set the timeout to 5 seconds Loop { Sleep 1 WinGet, exists, ID, %windowTitle% if (!exists || A_TickCount >= timeout) break } MsgBox Phase 2 complete. ; Phase 3: Action Phase3: Loop { if GetKeyState("LShift") { MsgBox Action paused. Sleep 100 continue } if GetKeyState("RShift") { MsgBox Starting from Phase 1 again. Sleep 100 Goto Phase1 } ; Wait for the next popup window with the learned HWND WinWaitActive, ahk_id %hwnd% ; Perform the specified number of clicks on the window Loop, %numClicks% { x := ClickX%A_Index% y := ClickY%A_Index% ;ControlClick, x%x% y%y%, ahk_id %hwnd% MouseClick, left, %x%, %y% Sleep 10 ; Adjust the delay between clicks as needed } ; Wait for the window to become inactive again with a timeout of 5 seconds WinWaitNotActive, ahk_id %hwnd%, , 5 ; Proceed without notice if the window doesn't become inactive within the timeout if (ErrorLevel) continue } MsgBox Phase 3 complete. ; Start from Phase 1 Goto Phase1 ; Helper function to clamp a value between a minimum and maximum Clamp(value, min, max) { return (value < min) ? min : (value > max) ? max : value }