Hello to all!
I have a question about a simple toggle function. Is it possible with hidmacros to toggle a key, for example "x", that if you press it one time it generates an "a" the next time a "b" and once again a "c" and so on. I know this must be a script, if its possible at all. If multiple functions not possible, is it possible to switch between two states ( "a" and "b" only ) at least?
With Autohotkey I've done exact this, but AHK could not seperate the devices (keyboards/numpads) connected to the computer.
I want to use this functionality with a selfmade overhead panel to operate multi position rotaries (eg. something like the mags switch in FS).
I have not so many keys available, that I can use one key for one position only.
Built a universal pit for mostly Falcon BMS, but at times I want to fly the big birds, too. So I built a very simple generic overhead panel with the
use of some numpads. Don't want to make the same complex electronics, like in the main pit, once again.
Thanks so much
Viper
P.S: I use the good old FS2004 for civil siming, so FSX variables or sim connect aren't an option in my case.
HIDmacros: One key toggle between multiple functions?
Re: HIDmacros: One key toggle between multiple functions?
It is possible, introduce global variable, when macro is triggered, check its value and send appropriate key. And modify the variable to get ready for next time.
Petr Medek
LUAmacros author
LUAmacros author
Re: HIDmacros: One key toggle between multiple functions?
Hello Petr,
many thanks for your reply. Have tried what you described, but I'm no programmer at all. Don't now exactly what you mean. The thing
I've tried looks like this:
iKeyStrokeCount = iKeyStrokeCount + 1
iKeyStrokeCount = 1
If iKeyStrokeCount = 1 Then
SendKeys ("A")
End If
If iKeyStrokeCount = 2 Then
SendKeys ("B")
End If
I think (as far as I came with my restricted knowledge) that the script ends after the first send keys, cause with this first keypress its finished. After that it starts from the beginning as a new instance. Don't now how to get the count-function from one instance to the next. Excuse my ignorance, but programming was always a mystery for me.
many thanks for your reply. Have tried what you described, but I'm no programmer at all. Don't now exactly what you mean. The thing
I've tried looks like this:
iKeyStrokeCount = iKeyStrokeCount + 1
iKeyStrokeCount = 1
If iKeyStrokeCount = 1 Then
SendKeys ("A")
End If
If iKeyStrokeCount = 2 Then
SendKeys ("B")
End If
I think (as far as I came with my restricted knowledge) that the script ends after the first send keys, cause with this first keypress its finished. After that it starts from the beginning as a new instance. Don't now how to get the count-function from one instance to the next. Excuse my ignorance, but programming was always a mystery for me.
Re: HIDmacros: One key toggle between multiple functions?
Without any testing or checking you should be able to do e.g. something like (there are more ways how to achieve this):
Into global (procedure) section
Into macro definition
Or to have more options
Into global (procedure) section
Code: Select all
macroMode= 1
Code: Select all
If macroMode = 1 Then
SendKeys ("A")
macroMode = 2
Else
SendKeys ("B")
macroMode = 1
End If
Code: Select all
If macroMode = 1 Then
SendKeys ("A")
End If
If macroMode = 2 Then
SendKeys ("B")
End If
If macroMode = 3 Then
SendKeys ("C")
End If
macroMode = macroMode + 1
If macroMode = 4 Then
macroMode = 1
End If
Petr Medek
LUAmacros author
LUAmacros author
Re: HIDmacros: One key toggle between multiple functions?
O.k. will try this. Thank's for the examples.
As I said I'm not good in programming, but if I have some code in front of me, of which I know its correct, maybe I get the big intuition .
Till now I had absolutely no plan how to begin, but with your code examples I could look how things are working and take my conclusions.
As I said I'm not good in programming, but if I have some code in front of me, of which I know its correct, maybe I get the big intuition .
Till now I had absolutely no plan how to begin, but with your code examples I could look how things are working and take my conclusions.