AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Jump to hotkey routine

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
doggy4s



Joined: 22 Jan 2007
Posts: 16

PostPosted: Fri Apr 10, 2009 11:45 pm    Post subject: Jump to hotkey routine Reply with quote

Hope the code explains the goal a bit

- Hotkey values are stored and retrieved from .ini file
- Key_x can have same keys as main1 ie ^Z
- if same how can I jump to same routine as hotkey and/or simulate physical keypresses based on %key_x% values to execute hotkeys or pass on program(window) ?

The hotkey part is working perfectly its the SomeTest: going to function: that is giving me troubles.

Code:

Gui, Add, Hotkey, vmain1, %main1%

Gui, Add, Hotkey, vkey_1, %key_1%
Gui, Add, Hotkey, vkey_2, %key_2%

Hotkey, %main% ,function,on
 
;-------------------

SomeTest:
if test
   {
   Need to go to hotkey  based on %key_1% !
   ;%key_1% could be same as %main1% => goto function: !!!
   }else{
   Need to go to hotkey  based on %key_2%
   }
return


function:     ;%main1%
;do something
return

other:
;do something
return

;......



Thanks much
Back to top
View user's profile Send private message
SoLong&Thx4AllTheFish



Joined: 27 May 2007
Posts: 4999

PostPosted: Sat Apr 11, 2009 7:01 pm    Post subject: Reply with quote

Perhaps you can use A_ThisHotkey and have all hotkeys go to the same label/function and use A_ThisHotkey to decide what needs to be done?
_________________
AHK Wiki FAQ
TF : Text files & strings lib, TF Forum
Back to top
View user's profile Send private message
doggy4s



Joined: 22 Jan 2007
Posts: 16

PostPosted: Tue Apr 14, 2009 6:52 am    Post subject: Reply with quote

thanks
Already had kind of found a workaround ( sure it can be improved)

Main problem I had was when a hotkey already was specified I could not specify the same keycombination again in the Gui.
Think I got a solution (working so far)
external switches check( through serial) whoes shortcut keys can be specified through Gui
Those keys can already exist ie have the same hotkey code (and mouse )as a predefined one (who happened to be the same as standardly used in the software but I wanted to catch to add functions to it)



Code:

Gui, Add, Hotkey, vmain1, %main1%

Gui, Add, Hotkey, vkey_1, %key_1%
Gui, Add, Hotkey, vkey_2, %key_2%

Hotkey, ^x, fixedkey ,on
SetTimer, Timer, On
;==============================


Timer:

; thanks to http://www.autohotkey.com/forum/topic26533.html

Port_DCD(nCid)
Port_DSR(nCid)
Port_CTS(nCid)
Port_RI(nCid)

IfEqual, S_DCD, 128 ;switch 1
   {
   Jumpto(key_1)
   Loop         ; make sure the switch has been released first !
   {
   Port_DCD(nCid)   
   IfNotEqual, S_DCD, 128
      {
      return
      }
   }
   }

IfEqual, S_RI, 64 ;switch 2
   {
   Jumpto(key_2)
   ;etc
   }
; etc
return

Jumpto(button)
{
    if button = ^x   ;check if hotkey exist
      {
      Gosub,fixedkey%button%
      }else{
      
      SendInput, %button%   
      }
}
return


$LButton::
MouseGetPos, ,,,mpos
if (mpos in nameofgraphicalitem1,nameofgraphicalitem2)and (IfWinActive,windowtitle)
   {
     
   Goto,fixedkey^x
   }
Click L Down
Keywait, LButton
Click L Up
return



fixedkey^x:  ; the workaround instead of ^x:: which prevented choosing the same keys in the Gui
fixedkey:      ;hotkey
   {
   ; the hotkey routine
   }
return
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group