WinWaitClose help

Get help with using AutoHotkey and its commands and hotkeys
sttrebo
Posts: 66
Joined: 27 Jan 2014, 12:31

WinWaitClose help

08 Nov 2018, 19:38

I have a very simple script, but I think I'm missing something on the WinWaitClose command.
I want the script to open up notepad.exe, then wait for me to exit/close notepad.exe.
When I exit notepad, I want to check the keystate of the left ctrl key. if down, run a program. if not down then just exit. here is a sample of the script:

Code: Select all

#Persistent
#InstallKeybdHook

Run, notepad.exe
WinWaitClose, Untitled - Notepad
GetKeyState, state, LCtrl
if state = D
	{
	run "i_view32.exe"
	}
	else
	{
	msgbox, "nope"
	}
exitapp
I thought the WinWaitClose command would pause the script until notepad is closed, but it doesn't. what am I missing?
swagfag
Posts: 4021
Joined: 11 Jan 2017, 17:59

Re: WinWaitClose help

08 Nov 2018, 19:54

Run, notepad.exe is executed. it takes some time for notepad to start up
meanwhile execution continues with WinWaitClose, Untitled - Notepad. at this point no notepad windows exist yet(cuz its still starting up), ErrorLevel get set to 0 and execution continues

u need to use either WinWaitActive beforehand, or simply RunWait instead of Run
sttrebo
Posts: 66
Joined: 27 Jan 2014, 12:31

Re: WinWaitClose help

09 Nov 2018, 17:36

knew i missed something simple. thanks for the help. not the first time i forgot to allow time for the window to be created...

thanks

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Dante, Google [Bot], Lem2001, mikeyww, nestea2k and 47 guests