AutoHotkey Community

It is currently May 26th, 2012, 4:00 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Jump to hotkey routine
PostPosted: April 11th, 2009, 12:45 am 
Offline

Joined: January 22nd, 2007, 6:19 pm
Posts: 16
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 11th, 2009, 8:01 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
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 FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 14th, 2009, 7:52 am 
Offline

Joined: January 22nd, 2007, 6:19 pm
Posts: 16
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


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Exabot [Bot], G. Sperotto, gamax92, Google Feedfetcher and 16 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