Not working - IfWinExist/If WinExist/IfWinActive/If WinActive Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
hymal7
Posts: 66
Joined: 14 Sep 2016, 05:37

Not working - IfWinExist/If WinExist/IfWinActive/If WinActive

21 Nov 2018, 04:34

Hi all,

When a warning message appears on my screen (after I try to run a program), I want to automatically close the warning message. But none of the IfWinExist/If WinExist/IfWinActive/If WinActive function is working.
What am I doing wrong?
Any help would be much appreciated.

Thanks

Code: Select all

SetTitleMatchMode, 2
run, C:\program.lnk
sleep 1000
IfWinExist, Open File
{
	msgbox 1
}

IfWinActive, Open File
{
	msgbox 2
}

IfWinExist, ahk_class #32770
{
	msgbox 3
}

IfWinActive, ahk_class #32770
{
	msgbox 4
}

If WinExist("Open File")
{
	MsgBox 5
}

If WinExist("ahk_class #32770")
{
	MsgBox 6
}

If WinActive("Open File")
{
	MsgBox 7
}

If WinActive("ahk_class #32770")
{
	MsgBox 8
}

esc::exitapp
Attachments
winexist.png
winexist.png (157.65 KiB) Viewed 1448 times
neokix
Posts: 36
Joined: 10 May 2017, 07:50
Contact:

Re: Not working - IfWinExist/If WinExist/IfWinActive/If WinActive

21 Nov 2018, 21:58

I'm not much of a programmer but probably you need to nest properly maybe using "else" and "return"?

eg.

Code: Select all

IfWinExist, Open File
{
	msgbox 1
}
else{
}
;;;end of your script;;;
return
Or, you can also use something like this to ensure closing.

Code: Select all

While WinExist("ahk_class #YOURCLASS")
	{
	ControlClick, Button ;your "Cancel"button number, WindowsSpy will tell you
	}
	Sleep, 300
return
Hope this helps :roll:
hymal7
Posts: 66
Joined: 14 Sep 2016, 05:37

Re: Not working - IfWinExist/If WinExist/IfWinActive/If WinActive  Topic is solved

27 Nov 2018, 12:16

I now run a different script in the background before the warning appears

Code: Select all

Loop
{
	IfWinexist, Open File - Security Warning
	{
		WinActivate
		send {left}
		sleep 100
		send {enter}
	}
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: CrowexBR, mebelantikjaya and 302 guests