#IfWinActive not working

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
partof
Posts: 110
Joined: 16 Jan 2016, 08:38

#IfWinActive not working

29 Dec 2017, 13:23

I want to send a hotkeys to a specific log in popup.

Here is my code:

Code: Select all

#IfWinActive, ahk_class Credential Dialog Xaml Host
	Send, {TAB 2}
	Send, {Enter}
But the tabs and the enter are still send to any Windows open (chrome, np++,MS Word...).

With Window Spy, I got this info for Windows Tilte, Class and Process of the pop up :

Code: Select all

Windows Security
ahk_class Credential Dialog Xaml Host
ahk_exe explorer.exe
So I also tried "#IfWinActive, ahk_exe explorer.exe" (not ideal because it' s not specific enough) and "#IfWinActive Windows Security"
I have also tried to replace "#IfWinActive" by "IfWinActive" and to use the normal If:

Code: Select all

#If WinActive("ahk_class Credential Dialog Xaml Host")
	Send, {TAB 2}
	Send, {Enter}
#If
Here is the pop up I want to send the command to (it's the login pop up of a network drive in Windows10:
[img]https://images.scdn8.secure.raxcdn.com/ ... 50e889.jpg
[/img]
A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: #IfWinActive not working

29 Dec 2017, 13:32

Creates context-sensitive hotkeys and hotstrings.
source: #IfWinActive / #IfWinExist

Code: Select all

#IfWinActive ahk_exe notepad.exe
a::MsgBox % A_ThisHotkey ; < this works: we've defined a double-colon hotkey, yet #If directives affect hotkeys and hotstrings
return
Try this instead:

Code: Select all

if (WinActive("ahk_exe notepad.exe")) {
	Send, {TAB 2}
	Send, {Enter}
} ; contrary to whats' happen using the #if directive, you must but in a block, enclosed in braces the code whose execution should depends on the fact that the condition is satisfied
my scripts
partof
Posts: 110
Joined: 16 Jan 2016, 08:38

Re: #IfWinActive not working

30 Dec 2017, 09:33

Super! It's working, thanks so much!
I can even use the windows title:

Code: Select all

if (WinActive("Windows Security")){
	Send, {TAB 2}
	Send, {Enter}
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada and 269 guests