| View previous topic :: View next topic |
| Author |
Message |
shawn8888
Joined: 25 Jun 2009 Posts: 4
|
Posted: Thu Jun 25, 2009 3:14 pm Post subject: $ not working |
|
|
I want to remap = button only when one application is activated. But it seems not working. It remaps for all applications.
Here is my code:
| Code: |
$=::
IfWinActive,Notepad
{
Send abc
return
}
else
{
Send =
}
return
|
So, what's wrong with my code?
Thanks! |
|
| Back to top |
|
 |
shawn8888
Joined: 25 Jun 2009 Posts: 4
|
Posted: Thu Jun 25, 2009 3:28 pm Post subject: |
|
|
I did set the match mode at the beginning.
SetTitleMatchMode 2 ;A window's title can contain WinTitle anywhere inside it to be a match.
BTW, if the match mode is not set, it should always send =, right? But it is on the contrary, it never sends =. |
|
| Back to top |
|
 |
Guest
|
Posted: Thu Jun 25, 2009 3:35 pm Post subject: |
|
|
| very weird... |
|
| Back to top |
|
 |
WHACKSTER
Joined: 23 Jun 2009 Posts: 16
|
Posted: Thu Jun 25, 2009 3:39 pm Post subject: |
|
|
this works for me:
#IfWinActive, ahk_group esctoclose
ESC::!F4
instead of the group you can use window title or ahk_class... |
|
| Back to top |
|
 |
shawn8888
Joined: 25 Jun 2009 Posts: 4
|
Posted: Thu Jun 25, 2009 3:44 pm Post subject: |
|
|
| WHACKSTER wrote: | this works for me:
#IfWinActive, ahk_group esctoclose
ESC::!F4
instead of the group you can use window title or ahk_class... |
I am not sure how this works.
Can you post the code for the same function that I want to do? |
|
| Back to top |
|
 |
WHACKSTER
Joined: 23 Jun 2009 Posts: 16
|
Posted: Thu Jun 25, 2009 3:52 pm Post subject: |
|
|
#IfWinActive, ahk_class Notepad
$=::Send, abc
this works. |
|
| Back to top |
|
 |
DreymaR
Joined: 24 May 2009 Posts: 89 Location: Bćrum, Norway
|
Posted: Thu Jun 25, 2009 4:00 pm Post subject: |
|
|
Whackster is right. What you did was to map the '$' unconditionally and then ask whether the window was active with your IfWin command. In contrast, his directive asks whether the window is active in the remapping itself. _________________ Better burden you cannot carry than man-wisdom much -- Hávamál |
|
| Back to top |
|
 |
shawn8888
Joined: 25 Jun 2009 Posts: 4
|
Posted: Thu Jun 25, 2009 4:23 pm Post subject: |
|
|
| WHACKSTER wrote: | #IfWinActive, ahk_class Notepad
$=::Send, abc
this works. |
Thanks, it works.
BTW, ahk_class is not necessary.
#IfWinActive, Notepad
works fine too.
Just out of curiosity, why my code in the first post is not working? |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 3254 Location: Simi Valley, CA
|
Posted: Thu Jun 25, 2009 11:20 pm Post subject: Re: $ not working |
|
|
| shawn8888 wrote: | I want to remap = button only when one application is activated. But it seems not working. It remaps for all applications.
Here is my code:
| Code: |
$=::
IfWinActive,Notepad
{
Send abc
return
}
else
{
Send =
}
return
|
So, what's wrong with my code?
Thanks! |
That is because the "Send =" is interpreted as "assign an empty string to the variable 'Send'"
| Quote: | Global Variables (alphabetical)
--------------------------------------------------
0[1 of 3]: 0
ErrorLevel[1 of 3]: 0
Send[0 of 0]: |
Putting a comma after the Send command would have made it work correctly (although you'd also need SetTitleMatchMode 2 for the window title to match). _________________ Ternary (a ? b : c) guide TSV Table Manipulation Library
Post code inside [code][/code] tags! |
|
| Back to top |
|
 |
|