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