 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Poupin Guest
|
Posted: Mon Dec 13, 2004 5:45 pm Post subject: One Hotkey -> Two Tasks |
|
|
How could I assign two different actions to a single hotkey in a script?
ex: Press F1 and have some hotkeys actions
Press F2 and have other actions with the "same" hotkeys
For instance:
F1 --> Numpad4::MouseMove, -3, 0, 0, R ;in a first routine
F2 --> Numpad4::MouseMove, -30, 0, 0, R; in a second one
I have a result with different scripts wich goes on&off but it's not "satisfying".
Can't we modify a hotkey in a script ? Please...
Thanks by now. |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 2951 Location: Minnesota
|
Posted: Mon Dec 13, 2004 6:12 pm Post subject: |
|
|
Yes, you can modify the contents of a hotkey. First you need to create and label your subroutines (segments of code):
| Code: | Move1: ; <-- This is your label. Name it whatever you want.
; Your code goes below the label.
MouseMove, -3, 0, 0, R
; Remember to return!
Return
Move2:
MouseMove, -30, 0, 0, R
Return |
Now, assign your default action by placing the hotkey label:
| Code: | Numpad4::
Move1:
MouseMove, -3, 0, 0, R
Return
Move2:
MouseMove, -30, 0, 0, R
Return |
Now, you can make F1 and F2 change the hotkey's action:
| Code: | Numpad4::
Move1:
MouseMove, -3, 0, 0, R
Return
Move2:
MouseMove, -30, 0, 0, R
Return
; See the documentation for more info on the Hotkey command.
F1::Hotkey, Numpad4, Move1
F2::Hotkey, Numpad4, Move2 |
You could also make it so that holding down F2 and pressing it would do the different one.
But it seems to me that what you're trying to do is make the numpad into a mouse. Before you bust any more brain cells, you might want to check out this excellent script that's already been written to do just that:
http://www.autohotkey.com/docs/scripts/NumpadMouse.htm |
|
| Back to top |
|
 |
poupin Guest
|
Posted: Mon Dec 13, 2004 6:33 pm Post subject: |
|
|
Hi Jony!
I think you resolved my prob.
I don't actually remap a mouse but create an adaptating "pad" in a game.
Using DEL, END, PGDN, alternatively, i want 3 pads in one for each sequencies of the game, a sim airplane. ( 3x9 commands...and more)
Congratulation for your help!
(& sorry for Shakespeare...) |
|
| Back to top |
|
 |
poupin Guest
|
Posted: Mon Dec 13, 2004 7:10 pm Post subject: |
|
|
But...
How can i combine several keys with F1 or F2?
---------------------------------------------------------
Numpad4:: ;Left
Move1: ;Slow
MouseMove, -3, 0, 0, R
Return
Move2: ;Fast
MouseMove, -30, 0, 0, R
Return
Numpad6:: ;Right
Move3: ;Slow
MouseMove, 3, 0, 0, R
Return
Move4: ;Fast
MouseMove, 30, 0, 0, R
Return
; Slow Mode
F1::
Hotkey, Numpad4, Move1
Hotkey, Numpad6, Move3
; Fast Mode
F2::
Hotkey, Numpad4, Move2
Hotkey, Numpad6, Move4
return
-------------------------------------------------
In my test, i just have 2 buttons , 2 modes;
and i get stick on the second one...
It begins on the slow mode but stay on the Fast. It doesn't toggle.
...jony? |
|
| Back to top |
|
 |
Simpleton
Joined: 02 Nov 2004 Posts: 14
|
Posted: Mon Dec 13, 2004 7:25 pm Post subject: |
|
|
| your hotkey for switching to slow mode doesn't have a return statement, so it's "falling through" to your fast mode hotkey. |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 2951 Location: Minnesota
|
Posted: Mon Dec 13, 2004 9:58 pm Post subject: |
|
|
Ya, sorry, I forgot to clarify... If a hotkey label has only one line, and it's on the same one as the label, it automatically returns.
Yes:
| Code: | | F1::Hotkey, Numpad4, Move |
Yes:
| Code: | F1::
Hotkey, Numpad4, Move1
Hotkey, Numpad6, Move3
Return |
No:
| Code: | F1::
Hotkey, Numpad4, Move1
Hotkey, Numpad6, Move3 |
|
|
| 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
|