| View previous topic :: View next topic |
| Author |
Message |
elchapin
Joined: 06 Mar 2007 Posts: 64 Location: Columbus, OH, USA
|
Posted: Tue Aug 21, 2007 4:41 pm Post subject: triple press, problem with "send" |
|
|
I am trying to create a hotstring for triple-pressing "d" to insert the date. I want a single press to pass a "d", and a double press to pass a "dd".
I used the script from Help, but I cannot get input to be sent for single-pressing or double-pressing "d".
| Code: |
SetKeyDelay, -1
SendMode, Input
return
; Example #3: Detection of single, double, and triple-presses of a hotkey. This
; allows a hotkey to perform a different operation depending on how many times
; you press it:
d::
if d_presses > 0 ; SetTimer already started, so we log the keypress instead.
{
d_presses += 1
return
}
; Otherwise, this is the first press of a new series. Set count to 1 and start the timer:
d_presses = 1
SetTimer, KeyD, 400 ; Wait for more presses within a 200 millisecond window.
return
KeyD:
SetTimer, KeyD, off
if d_presses = 1 ; The key was pressed once.
{
Send, d
}
else if d_presses = 2 ; The key was pressed twice.
{
Send, dd
}
else if d_presses > 2
{
Send, _%A_YYYY%%A_MM%%A_DD%_
}
; Regardless of which action above was triggered, reset the count to prepare for the next series of presses:
d_presses = 0
return
|
It also seems to continue to log the key presses until there are three, even if I wait several seconds between presses...
I swapped out the "send" lines for "msgbox" and it worked fine then... I am confused! Please help! _________________ My startup is Telesaur - a telecommuting job site. |
|
| Back to top |
|
 |
ManaUser
Joined: 24 May 2007 Posts: 1121
|
Posted: Tue Aug 21, 2007 5:02 pm Post subject: |
|
|
Why not just use a hotstring ?
| Code: | ::ddd::
Send, _%A_YYYY%%A_MM%%A_DD%_
return |
Granted that will take effect no matter how slowly you type ddd, but I wouldn't think that would usually be a problem. |
|
| Back to top |
|
 |
tonne
Joined: 06 Jun 2006 Posts: 1651 Location: Denmark
|
|
| Back to top |
|
 |
elchapin
Joined: 06 Mar 2007 Posts: 64 Location: Columbus, OH, USA
|
Posted: Tue Aug 21, 2007 5:26 pm Post subject: |
|
|
@ManaUser - That's a workable solution... I didn't think of the obvious.
I am still curious about how to do this with key delays though... _________________ My startup is Telesaur - a telecommuting job site. |
|
| Back to top |
|
 |
tonne
Joined: 06 Jun 2006 Posts: 1651 Location: Denmark
|
Posted: Tue Aug 21, 2007 5:39 pm Post subject: |
|
|
In order to let a script send its own hotkey it must be prefixed with $. It seems that this holds even if the d in your case is sent from a timer!?
Try changing your hotkey to:
_________________ RegEx Powered Dynamic Hotstrings
COM
AutoHotkey 2 |
|
| Back to top |
|
 |
elchapin
Joined: 06 Mar 2007 Posts: 64 Location: Columbus, OH, USA
|
Posted: Tue Aug 21, 2007 5:58 pm Post subject: |
|
|
@tonne - I switched "d::" to "$d::", as you suggested, and it worked! Thanks.
I will have to look into the other comment a little more, thanks guys! _________________ My startup is Telesaur - a telecommuting job site. |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4710 Location: Boulder, CO
|
Posted: Tue Aug 21, 2007 6:55 pm Post subject: |
|
|
The Help just demonstrates the use of timers. For this task you don't need it: | Code: | $~d::
If (A_ThisHotKey = A_PriorHotKey && A_TimeSincePriorHotKey < 500)
count++
Else count = 0
If (count > 1)
Send {BS 3}_%A_YYYY%%A_MM%%A_DD%_ |
|
|
| Back to top |
|
 |
elchapin
Joined: 06 Mar 2007 Posts: 64 Location: Columbus, OH, USA
|
Posted: Tue Aug 21, 2007 7:43 pm Post subject: |
|
|
@Laszlo - Now, that's beautiful! I guess I haven't learned all of the built in variables yet! Thanks! _________________ My startup is Telesaur - a telecommuting job site. |
|
| Back to top |
|
 |
|