AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

$ not working

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
shawn8888



Joined: 25 Jun 2009
Posts: 4

PostPosted: Thu Jun 25, 2009 3:14 pm    Post subject: $ not working Reply with quote

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
View user's profile Send private message
shawn8888



Joined: 25 Jun 2009
Posts: 4

PostPosted: Thu Jun 25, 2009 3:28 pm    Post subject: Reply with quote

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
View user's profile Send private message
Guest






PostPosted: Thu Jun 25, 2009 3:35 pm    Post subject: Reply with quote

very weird...
Back to top
WHACKSTER



Joined: 23 Jun 2009
Posts: 16

PostPosted: Thu Jun 25, 2009 3:39 pm    Post subject: Reply with quote

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
View user's profile Send private message
shawn8888



Joined: 25 Jun 2009
Posts: 4

PostPosted: Thu Jun 25, 2009 3:44 pm    Post subject: Reply with quote

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
View user's profile Send private message
WHACKSTER



Joined: 23 Jun 2009
Posts: 16

PostPosted: Thu Jun 25, 2009 3:52 pm    Post subject: Reply with quote

#IfWinActive, ahk_class Notepad
$=::Send, abc


this works.
Back to top
View user's profile Send private message
DreymaR



Joined: 24 May 2009
Posts: 89
Location: Bćrum, Norway

PostPosted: Thu Jun 25, 2009 4:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
shawn8888



Joined: 25 Jun 2009
Posts: 4

PostPosted: Thu Jun 25, 2009 4:23 pm    Post subject: Reply with quote

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
View user's profile Send private message
[VxE]



Joined: 07 Oct 2006
Posts: 3254
Location: Simi Valley, CA

PostPosted: Thu Jun 25, 2009 11:20 pm    Post subject: Re: $ not working Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group