AutoHotkey Community

It is currently May 26th, 2012, 8:58 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: $ not working
PostPosted: June 25th, 2009, 4:14 pm 
Offline

Joined: June 25th, 2009, 4:08 pm
Posts: 4
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 25th, 2009, 4:28 pm 
Offline

Joined: June 25th, 2009, 4:08 pm
Posts: 4
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 =.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 25th, 2009, 4:35 pm 
very weird...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 25th, 2009, 4:39 pm 
Offline

Joined: June 23rd, 2009, 11:43 pm
Posts: 16
this works for me:

#IfWinActive, ahk_group esctoclose
ESC::!F4

instead of the group you can use window title or ahk_class...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 25th, 2009, 4:44 pm 
Offline

Joined: June 25th, 2009, 4:08 pm
Posts: 4
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 25th, 2009, 4:52 pm 
Offline

Joined: June 23rd, 2009, 11:43 pm
Posts: 16
#IfWinActive, ahk_class Notepad
$=::Send, abc


this works.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 25th, 2009, 5:00 pm 
Offline

Joined: May 24th, 2009, 1:23 pm
Posts: 89
Location: Bærum, Norway
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 25th, 2009, 5:23 pm 
Offline

Joined: June 25th, 2009, 4:08 pm
Posts: 4
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: $ not working
PostPosted: June 26th, 2009, 12:20 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3330
Location: Simi Valley, CA
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!


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: bekihito, Bing [Bot], BrandonHotkey, coinman, Exabot [Bot], Google Feedfetcher, oldbrother and 61 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group