Trying to automate a usage decision temporarily due to staff shortages
My code works but I've had to use timing rather than WaitWinActive as despite the fact if I capture the active window and return it in a message box with WinExist("A") AHK doesn't seem to register that. I also can't use the loop as I can't break it, so at the moment it goes on endlessly, I tried using an input box and times but there are other reasons why I need to be able to break the code as if another users is in the inspection it causes a nightmare.
Code: Select all
#Warn all
global Break_Window:= 0x20400
^j::
Loop
{
;Enters UD code and saves the UD
send, ZU02
send, {Ctrl down}s{Ctrl up}
Sleep, 500 ;Required as cant get WinWaitActive to work)
;Activates the pop up window and tabs left once, presses enter
ActiveWin := WinExist("A")
;msgbox %ActiveWinB% ;(returned 0xf03ae)
WinActivate "ahk_id %ActiveWin%"
send, {lshift down}{tab}{lshift up}
send, {Enter}
Sleep, 1000 ;Required as cant get WinWaitActive to work)
;NOT WORKING - This code is meant to test if SAP has returned to the main inspection window (QA32) and breaks the loop if so.
ActiveWinC := WinExist("A")
;msgbox %ActiveWinC% ;(returned 0x20400 when on QA32 window)
Ifwinactive "ahk_id" %Break_Window%
{
break
}
;'This code returns to UD window and presses tab twice to return to UD field
Sleep, 8000 ;Required as cant get WinWaitActive to work)
ActiveWinB := WinExist("A")
;msgbox %ActiveWinB% ;(returned 0xa084c)
WinActivate "ahk_id %ActiveWinB%"
send, {Tab}
send, {Tab}
;End loop
}
return