PDA

View Full Version : Toggle question



thinus
04-30-2009, 02:00 AM
I've been reading through the HotKeyNet samples and I have a question about toggling.



<HotKey 1-5>
<Toggle>
<SendLabel w1>
<Key %Trigger%>
<Toggle>
<SendLabel w2>
<Key %Trigger%>
<Toggle>
<SendLabel w3>
<Key %Trigger%>
<Toggle>
<SendLabel w4>
<Key %Trigger%>
<Toggle>
<SendLabel w5>
<Key %Trigger%>

<HotKey 6>
<Toggle>
<SendLabel w1>
<Key %Trigger%>
<Toggle>
<SendLabel w2>
<Key %Trigger%>
<Toggle>
<SendLabel w3>
<Key %Trigger%>
<Toggle>
<SendLabel w4>
<Key %Trigger%>
<Toggle>
<SendLabel w5>
<Key %Trigger%>


In the above script will 1-5 share a sequence, in other words, if I press 5 and then 3 will it send 5 to w1 and 3 to w2?
And will 6 be in its own sequence?


EDIT: I ran some tests and it doesn't seem to work that way :(
Each key maintains its own sequence. Pressing 5 and then 4 sends 5 to w1 and 4 to w1. Is there any way to get those keys to share the same sequence?

olipcs
04-30-2009, 03:22 AM
hi, yes in theory there is a possibility that they share the toggel, by using <SetToggle>, or with a variable, like this:


<HotKey 1-5>
<If togglestate is 1>
<SetVar togglestate 2>
<SendLabel w1>
<Key %Trigger%>
<Else If togglestate is 2>
<SetVar togglestate 3>
<SendLabel w2>
<Key %Trigger%>
<Else If togglestate is 3>
<SetVar togglestate 4>
<SendLabel w3>
<Key %Trigger%>
<Else If togglestate is 4>
<SetVar togglestate 5>
<SendLabel w4>
<Key %Trigger%>
<Else If togglestate is 5>
<SetVar togglestate 1>
<SendLabel w5>
<Key %Trigger%>
<Else>
<SetVar togglestate 2>
<SendLabel w1>
<Key %Trigger%>

..i hope that works, as i haven't tested it.

Freddie
04-30-2009, 04:52 AM
That final else is brilliant. I had to think for a long time to see why you made it 2. :)

thinus
04-30-2009, 05:08 AM
If that works I am switching to HKN.

Freddie
04-30-2009, 05:42 AM
This thread made me realize that links to SetToggle were missing from the website's pages about Toggle. I just added them.

olipcs
04-30-2009, 06:01 AM
That final else is brilliant. I had to think for a long time to see why you made it 2. :) Thanks, the idea came to me, when i was going to write the hole '..to make this work you have to initalize the variable somewhere else..' and than realized, that i could simply do it when none of the other <If>s is matched. It was a little bit like one of the simpsons 'D'oh'-moments, of "why didn't i think earlier about it'.

olipcs
04-30-2009, 07:38 AM
If that works I am switching to HKN. Btw.: I tested the above, it works perfectly!
- so welcome to HKN ;)

olipcs
04-30-2009, 09:57 AM
Btw.: if you want to reset the togglesequence to its beginning (or to any other step), you could simply define a hotkey for that like:


<Hotkey shift r>
<SetVariable togglestate 1>


or to reset to a specific togglesatae like this:


<Hotkey shift 1-5>
<SetVar togglestate %TriggerMainKey%>

thinus
04-30-2009, 10:00 AM
If that works I am switching to HKN. Btw.: I tested the above, it works perfectly!
- so welcome to HKN ;)

Can I have your babies? I'll be setting up scripts to match my current setup over the weekend :)