 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
huma
Joined: 15 Mar 2008 Posts: 2
|
Posted: Sat Mar 15, 2008 7:54 pm Post subject: Sequence of keys |
|
|
Hello !
I need some help with building a script that will be executed on a sequence of keys pressed, ie:
Win+c (press and release) + t : that will execute one program with a certain configuration
Win+c (press and release) + h : that will execute the some program but with a diferent configuration.
I didsomething like this:
| Code: | #c::
keywait,t,D
Run C:\telindus\programas\cygwin\cygwin_telindus.bat
keywait,h,D
Run C:\telindus\programas\cygwin\cygwin.bat
return |
but it doesn't work very well.
Can anyone help me ?
Thanks in advance
Hugo Marcelino |
|
| Back to top |
|
 |
DarthCrap
Joined: 15 Mar 2008 Posts: 8 Location: Behind You
|
Posted: Sat Mar 15, 2008 9:23 pm Post subject: A possible solution |
|
|
I've seen two problems with this script
Firstly, if you do not press either t or h directly after pressing Win+C, and you happen to type the letter t (or h) in somewhere else (eg : the autohotkey forum), it will activate then?.
Secondly, if I am correct, then it will never respond to h, unless it has already picked up t.
Is this what you meant by it not working very well?
If so, then try this (it is a bit inefficient though)
| Code: |
#SingleInstance
#Persistent
winc_pressed = 0
#c::
winc_pressed = 1
SetTimer, ResetWinC, -3000
Return
ResetWinC:
winc_pressed = 0
Return
~t::
IfEqual, winc_pressed, 1
{
Run, C:\telindus\programas\cygwin\cygwin_telindus.bat
winc_pressed = 0
}
Return
~h::
IfEqual, winc_pressed, 1
{
Run, C:\telindus\programas\cygwin\cygwin.bat
winc_pressed = 0
}
Return
|
If not, then sorry, but I can't help you. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2737 Location: Australia, Qld
|
Posted: Sun Mar 16, 2008 6:24 am Post subject: |
|
|
Here's my solution:
| Code: | #c::
Hotkey, t, #c_key, On
Hotkey, h, #c_key, On
SetTimer, #c_timeout, -500 ; Tweak this.
return
#c_timeout:
Hotkey, t, Off
Hotkey, h, Off
return
#c_key:
gosub #c_timeout
MsgBox %A_ThisHotkey%
return |
|
|
| Back to top |
|
 |
k3ph
Joined: 20 Jul 2006 Posts: 174
|
Posted: Sun Mar 16, 2008 6:52 am Post subject: |
|
|
[Note from moderator: Quoting the post directly above is unnecessary and inconvenient to readers. Quote removed.]
nice, using Lexikos' code:
| Code: | LWin & c::
send {LWin}c
keywait, LWin
keywait, c
hotkey, t, tkey, On
hotkey, h, hkey, On
settimer, turnoff, 500
return
turnoff:
hotkey, t, off
hotkey, h, off
return
tkey:
Run C:\telindus\programas\cygwin\cygwin_telindus.bat
return
hkey:
Run C:\telindus\programas\cygwin\cygwin.bat
return |
|
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2737 Location: Australia, Qld
|
Posted: Sun Mar 16, 2008 7:58 am Post subject: |
|
|
For me, #c (Win+c) and LWin & c are identical, since I have no RWin key.
Why send LWin and c individually, or at all?
| Code: | send {LWin}c ; presses and releases LWin, then presses and releases c.
send #c ; holds win, presses and releases c, releases win.
~#c:: ; detects Win + C without blocking either. |
|
|
| Back to top |
|
 |
canta
Joined: 30 May 2006 Posts: 49
|
Posted: Sun Mar 16, 2008 11:38 am Post subject: |
|
|
I have been trying the Input method in some scripts. How is this? | Code: | #c::
MatchList = h,t
Input, UserInput, L1 C T3,, %MatchList%
SetKeyDelay, -1
If UserInput = h
Run C:\telindus\programas\cygwin\cygwin.bat
else if UserInput = t
Run C:\telindus\programas\cygwin\cygwin_telindus.bat
Return |
|
|
| Back to top |
|
 |
k3ph
Joined: 20 Jul 2006 Posts: 174
|
Posted: Mon Mar 17, 2008 3:15 am Post subject: |
|
|
| Lexikos wrote: | For me, #c (Win+c) and LWin & c are identical, since I have no RWin key.
Why send LWin and c individually, or at all?
| Code: | send {LWin}c ; presses and releases LWin, then presses and releases c.
send #c ; holds win, presses and releases c, releases win.
~#c:: ; detects Win + C without blocking either. |
|
hmm i see now the difference and i think your method is safer, so {LWin}c should be changed by #c so keywait can be discarted.
thank you again Lexikos |
|
| Back to top |
|
 |
huma
Joined: 15 Mar 2008 Posts: 2
|
Posted: Mon Mar 17, 2008 2:47 pm Post subject: |
|
|
sorry.
I've bean away and only today i could see the responses.
And i'm very happy, because that was exactly what i wanted
Thanks for your help.
Best Regards |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|