Hi All,
Can someone please tell me what I'm doing wrong with this code?
No matter what I ask the if statement to match it always types E when I press `, even if it equates to false.
I need the send to only work on a specific domain. If my domain is XYZ then the below code will still send E when I type `. In fact, even if I pause the script it still replaces ` with E!!? The variable MyDomain returns the correct domain name in the msgbox.
Thanks!
_______________________________
EnvGet, MyDomain, USERDOMAIN
MsgBox, % MyDomain
if (MyDomain = "ABC")
{
#IfWinExists ahk_class Notepad
`::Send, E
}
______________________________
I've also tried
______________________________
EnvGet, MyDomain, USERDOMAIN
MsgBox, % MyDomain
if MyDomain = "ABC"
{
If WinExist("ahk_class Notepad")
{
`::Send, E
Return
}
Return
}
Send action always runs, even when IF statement equates to false??
Re: Send action always runs, even when IF statement equates to false??
To define a context sensitive hotkey you can use #If outside the hotkey definition:
OR:
Code: Select all
EnvGet, MyDomain, USERDOMAIN
MsgBox, % MyDomain
#If (MyDomain = "ABC") ; context sensitive
`::
If WinActive("ahk_class Notepad")
Send, E
Return
Code: Select all
EnvGet, MyDomain, USERDOMAIN
MsgBox, % MyDomain
#If WinActive("ahk_class Notepad") ; context sensitive
`::
If (MyDomain = "ABC")
Send, E
Return
Re: Send action always runs, even when IF statement equates to false??
Thanks for clarifying the #if for me, I was trying to figure that out.
I'll give it a try again now.
I'll give it a try again now.
Re: Send action always runs, even when IF statement equates to false??
Perfect, thank you! I also now see that I can use IF etc after ::, that's very useful!
Of note, when I pause the script the ` key is still sending E? I have to exit the script for it to stop applying, is that expected behavior?
Of note, when I pause the script the ` key is still sending E? I have to exit the script for it to stop applying, is that expected behavior?
Code: Select all
EnvGet, MyDomain, USERDOMAIN
#if MyDomain = "abc"
{
`::
If WinExist("ahk_class Notepad")
Send, E
Return
}
Re: Send action always runs, even when IF statement equates to false??
Yes it is. You either have to suspend the script or make the following change. Note I moved the Notepad check to be conditional, this causes the ` key to retain its native function if notepad is closed opposed to blocking it.
Code: Select all
EnvGet, MyDomain, USERDOMAIN
#if MyDomain = "abc" && WinExist("ahk_class Notepad") && !A_IsPaused
`::Send, E
Who is online
Users browsing this forum: Spawnova and 58 guests