AutoHotkey Community

It is currently May 27th, 2012, 7:54 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: One Hotkey -> Two Tasks
PostPosted: December 13th, 2004, 6:45 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 13th, 2004, 7:12 pm 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 13th, 2004, 7:33 pm 
Hi Jony!

I think you resolved my prob. :lol:

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...)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 13th, 2004, 8:10 pm 
But... :oops:

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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 13th, 2004, 8:25 pm 
Offline

Joined: November 2nd, 2004, 5:06 pm
Posts: 14
your hotkey for switching to slow mode doesn't have a return statement, so it's "falling through" to your fast mode hotkey.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 13th, 2004, 10:58 pm 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
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


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: bobbysoon, just me and 75 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