AutoHotkey Community

It is currently May 27th, 2012, 11:06 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 13 posts ] 
Author Message
PostPosted: May 1st, 2007, 2:02 am 
Offline

Joined: June 20th, 2005, 9:13 pm
Posts: 37
I searched the help for an hour and was not able to discover how to send a Hotkey without redefining it. For example, suppose in a program you sometimes want a Control-B Hotkey to send Control-B.

Could someone direct me to the relevant Help section?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 1st, 2007, 4:55 am 
Offline

Joined: December 1st, 2006, 9:27 am
Posts: 460
Do you mean that you don't want a static hotkey like this:
Code:
^b::gosub something

If so, you can create one like this:
Code:
Hotkey, ^b, something

If you want to make it dynamic you can use a variable:
Code:
modifier = ^
key = b
Hotkey, %modifier%%key%, something

If you mean you want to disable a hotkey, you can:
Code:
Hotkey, ^b, Off

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 1st, 2007, 5:15 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8667
Location: Salem, MA
i think he means this: (untested)

Code:
$^b::
;do something else
send, ^b
return


The $ makes it all work

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 1st, 2007, 6:32 am 
Offline

Joined: December 1st, 2006, 9:27 am
Posts: 460
Or maybe he meant this:
Code:
^b::
   If(x = 1)
   {   Send ^b
   }
   Else
   {   Send !b
   }
Return

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 1st, 2007, 4:38 pm 
Offline

Joined: June 20th, 2005, 9:13 pm
Posts: 37
Thanks for your replies. I found by testing that a hotkey such as ^B cannot send ^B because that results in an infinite loop. I know there is a way to tell AutoHotKey not to interpet the sent ^B as a hotkey press, but I can't find the place in the help where it tells how to do that. Autohotkey is recursive apparently.

Sorry, at the time I posted the original message, I didn't know how to explain better.

Sometimes there are situations in which you want to make a ^B (Control-B) hotkey send ^B under some circumstances and do something else under other circumstances.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 1st, 2007, 5:15 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8667
Location: Salem, MA
Futurepower(R) wrote:
Thanks for your replies. I found by testing that a hotkey such as ^B cannot send ^B because that results in an infinite loop. I know there is a way to tell AutoHotKey not to interpet the sent ^B as a hotkey press, but I can't find the place in the help where it tells how to do that. Autohotkey is recursive apparently.

Sorry, at the time I posted the original message, I didn't know how to explain better.

Sometimes there are situations in which you want to make a ^B (Control-B) hotkey send ^B under some circumstances and do something else under other circumstances.


Like I said in my last post, $ makes it all work. the documentation for this is here:Hotkeys. Look at the table containing modifiers to find $

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 1st, 2007, 5:54 pm 
Offline

Joined: December 1st, 2006, 9:27 am
Posts: 460
Best of both worlds
Code:
$^b::
   GetKeyState, cState, CapsLock, T
   If(cState = "D")
   {   Send ^b   ;send ctrl & b
   }
   Else
   {   Send +b   ;send shift & b
   }
return

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 1st, 2007, 6:00 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8667
Location: Salem, MA
Michas, where are you getting this reques tto send either Ctrl or Alt B from? He only asked about control...

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 1st, 2007, 6:43 pm 
Offline

Joined: December 1st, 2006, 9:27 am
Posts: 460
Quote:
Sometimes there are situations in which you want to make a ^B (Control-B) hotkey send ^B under some circumstances and do something else under other circumstances.

The "do something else under other circumstances" part. I made it do something else. Since he didn't specify what "something else" I used my imagination. It does Ctrl-b and something else. What's the problem?

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 1st, 2007, 10:05 pm 
Offline

Joined: June 20th, 2005, 9:13 pm
Posts: 37
I would like Control-B to send Control-B, as in:

^B::Send ^B

Try it, it doesn't work, because it sends the ^B back to AutoHotkey, which sends another ^B, which goes back to AutoHotkey, and so on.

Obviously, no one would do exactly that. I want to modify have Control-B send Control-B sometimes, and, programmatically, sometimes send something else.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 1st, 2007, 10:18 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8667
Location: Salem, MA
Code:
$^b::Send, ^b


Try it - it does work. Also try any of the code posted by Michas or me in this thread. We are giving you the answer you need. Add a $ to your hotkey, and it is allowed to send itselve without being recursive.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 1st, 2007, 10:42 pm 
Offline

Joined: June 20th, 2005, 9:13 pm
Posts: 37
Thanks very much.

I read the code, but didn't see the $, because I looked only in the lower portion of the code, assuming a normal hotkey was being defined.

Could you direct me to the place in the help where it describes this?

Thanks, again.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 1st, 2007, 10:52 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8667
Location: Salem, MA
Again, this was in a previous post. the word "Hotkeys" here is a link:

engunneer wrote:
Like I said in my last post, $ makes it all work. the documentation for this is here:Hotkeys. Look at the table containing modifiers to find $

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Edd, Exabot [Bot], Google Feedfetcher, HotkeyStick, Yahoo [Bot] and 12 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