AutoHotkey Community

It is currently May 24th, 2012, 2:00 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Action while key is held
PostPosted: June 23rd, 2008, 11:34 pm 
Is there any way to have holding a key down corresponding to holding another down until you release the key, while having an initial action when first depressed?

Specifically, I want to be able to hold down the "a" key which will cause AHK to hold down "1" and press "Enter" once, but not press Enter again until I let off the "a" key and press it again... but still holding "1" as long as "a" remains depressed.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 23rd, 2008, 11:42 pm 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
Code:
a::Send, {1 down}{enter}
a up::Send {1 up}

:?:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 23rd, 2008, 11:53 pm 
Krogdor wrote:
Code:
a::Send, {1 down}{enter}
a up::Send {1 up}

:?:

I guessed and tried that, but holding down the "a" key still presses Enter many times. I want Enter to only be pressed on the initial depression of "a".


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 23rd, 2008, 11:59 pm 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
Code:
a::
Send, {1 down}{enter}
KeyWait, a
return

a up::Send {1 up}

Better?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 24th, 2008, 12:03 am 
Krogdor wrote:
Code:
a::
Send, {1 down}{enter}
KeyWait, a
return

a up::Send {1 up}

Better?


Sounds logical, but it doesn't seem to have changed. Something with KeyWait seems ideal, but I don't want to have to go into condition loops if possible...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 24th, 2008, 12:42 am 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
Szalkow wrote:
Sounds logical, but it doesn't seem to have changed. Something with KeyWait seems ideal,


Eh. There is a KeyWait there, so I dont know what you mean by that second sentence.

Also, I just tried that script myself and it works fine... Sends enter one time only.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 24th, 2008, 12:46 am 
I've been using wildcards (*) before each key since I may need to use multiple keys at once, will that affect it?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 24th, 2008, 12:48 am 
Sure enough, wildcards override it. Will removing them still allow me to use multiple keys at once?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 24th, 2008, 1:37 am 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
I'm sorry, I don't quite understand what you are saying.
Could you post an example of something that does not function properly?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 24th, 2008, 2:22 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3328
Location: Simi Valley, CA
Code:
$*a:: ; hotkey = [a] with any/no modifier keys and using kbd hook
Send {blind}{1 down}{enter}
Keywait, % SubStr(A_ThisHotkey, 0) ; grabs the last char off this hotkey (="a")
Send {blind}{1 up}
return
:?:

_________________
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  [ 10 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Albireo, batto, fragman, jyloup, KenC, Pulover, Yahoo [Bot] and 22 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