Code: Select all
Run "notepad",,, &pid
WinActivate "ahk_pid " pid
msgbox("finished")
Code: Select all
Run "notepad",,, &pid
WinActivate "ahk_pid " pid
msgbox("finished")
Code: Select all
Run "notepad",,, &pid
WinWaitActive "ahk_pid " pid
WinActivate "ahk_pid " pid
msgbox("finished")
Code: Select all
Run "notepad",,, &pid
sleep 1000
WinActivate "ahk_pid " pid
msgbox("finished")
Code: Select all
WinActivate "ahk_pid " pid
Code: Select all
Run "notepad",,, &pid
Code: Select all
Run "notepad.exe",,, &pid
Code: Select all
Run "notepad.exe",,, &pid_from_run_command
sleep 1500
pid_from_wingetid := WinGetPID("Notepad")
Bull123 wrote: ↑25 Aug 2023, 06:02Running the codegives to different values for pid_from_run_command and pid_from_wingetidCode: Select all
Run "notepad.exe",,, &pid_from_run_command sleep 1500 pid_from_wingetid := WinGetPID("Notepad")
In task manager, I see that there are two processes for notepad.
One with pid_from_run_command and the other with pid_from_wingetid.
And pid_from_run_command seems to refere to the wrong process
Code: Select all
; This script shows how to wait for a new instance of a program's window
#Requires AutoHotkey v2.0
app := A_WinDir '\System32\notepad.exe'
winTitle := 'ahk_exe' app
win1 := WinGetList(winTitle)
Run app
Loop {
Sleep 250
win2 := WinGetList(winTitle)
} Until win2.Length > win1.Length
WinActivate win2[1]
MsgBox 'Done!', 'Status', 64
Code: Select all
winlist_pre_appstart:= WinGetList(ahk_exe)
Run commandstring ;for instance "firefox.exe https://somewebsite.com"
sleep_accumulated:=0
Loop {
Sleep 150
sleep_accumulated+=150
if sleep_accumulated > MAX_SLEEP_TIME_IN_RUN_COMMANDSTRING_AND_ACTIVATE_WINDOW ; MAX_SLEEP... is just a numeric value
{
break
}
winlist_current := WinGetList(ahk_exe)
} Until winlist_current.Length > winlist_pre_appstart.Length
elem_in_list1_no_in_list2:=find_elem_in_list1_not_in_list2(winlist_current,winlist_pre_appstart)