PDA

View Full Version : Broadcast all keys mode



thinus
04-30-2009, 11:03 PM
I don't see a broadcast mode option for HKN but it seems achievable within a script:



// global variable to store the current broadcast mode
<SetVar BroadcastMode 0>

// always pass keys
<Hotkey ScrollLockOn A-Z, 0-9, Plus, Minus, F1-F12 except W, A, S, D, Q, E>
<SendLabel myApp>
<Key %Trigger%>

// pass keys only if broadcast mode enabled
<Hotkey ScrollLockOn W, A, S, D, Q, E>
<If BroadcastMode is 1>
<SendLabel myApp>
<Key %Trigger%>

// toggle broadcast mode when Pause is pressed
<Hotkey Pause>
<Toggle>
<SetVar BroadcastMode 1>
<Toggle>
<SetVar BroadcastMode 0>


Is this the correct way to go about it or is there a built-in feature for this?

Freddie
05-01-2009, 12:20 AM
Usually when people ask about broadcasting they want to send all key events (press and releases) to various windows. But I'm not sure if that's what you're asking because your script seems to be more concerned with turning hotkeys on and off. Since I'm not sure I'll answer both questions.

The easiest way to broadcast many key combinations (it won't be all of them) is like this:



<MovementHotkey AllMainKeys; Alt AllMainKeys; Ctrl AllMainKeys>
<SendLabel ....>
<Key %Trigger%>

That definition creates about three hundred hotkeys for almost all unmodified keys and Ctrl and Alt combinations. I used MovementHotkey for this definition because a movement hotkey sends presses and releases separately. In contrast, regular hotkeys send a press and release immediately when you press a trigger. MovementHotkeys are closer to what I understand to be "broadcasting."

If you're asking the other question -- how to turn this sort of thing off and on -- the program gives you many choices.

Instead of creating a variable like you're doing in the script, you can simply do this:



<Hotkey Pause>
<ToggleHotkeys>

The method used in the sample scripts is to add "ScrollLockOn" to all the definitions. This turns the scroll lock key into a toggle, and the scroll lock light on the keyboard becomes an indicator of whether hotkeys are on.

You can also make two separate hotkeys with <TurnHotkeysOff> and <TurnHotkeysOn>.

You can also define hotkeys so they only work when a certain application is in the foreground, which in a sense turns them on and off automatically.

thinus
05-01-2009, 01:22 AM
Usually when people ask about broadcasting they want to send all key events (press and releases) to various windows. But I'm not sure if that's what you're asking because your script seems to be more concerned with turning hotkeys on and off. Since I'm not sure I'll answer both questions.

Lets see if I can be a bit clearer.

I need to operate in three different modes:
Pass a specified list of keys to my windows
Pass all keys to my windows
Pass keys only to the window with focus


And I need to be able to easily switch between these modes. The ScrollLockOn in my script switches between mode 1 and mode 3. The Pause key in my example script switches mode 2 on and off. So for mode 1 behaviour I would have a list with W, A, S, D excluded but when I switch to mode 2 I need to pass W, A, S, D.

In WoW I frequently use the command line when doing quests, for instance if the quest gives you an item called Hollow Skull and requires you to use it somewhere I would type on the command line "/use Hollow Skull" and I'd like to type that in all windows. When I am moving with my other characters on follow I don't want to pass w, a, s, d however.

Freddie
05-01-2009, 01:36 AM
What key(s) would you like to use to select or toggle these modes?

thinus
05-01-2009, 01:48 AM
ScrollLockOff - mode 3, pass keys only to window with focus
ScrollLockOn, PauseOff - mode 1, pass limited set of keys to windows
ScrollLockOn, PauseOn - mode 2, pass all keys to windows

PauseOff, PauseOn is toggled by pressing the Pause key.

Freddie
05-01-2009, 02:11 AM
With this script, Pause turns your hotkeys off and on. ScrollLock switches between the two key lists. (Your mode 3 is hotkeys off.)

I reversed the keys from what you described because I can do it faster and I have to go to bed. You can do it your way too but it's more work.

This is the whole script. As you can see it's quite short. If any of the keys control movement you can separate them out and use MovementHotkey for them, or you can just use MovementHotkey for everything.



<Hotkey Pause>
<ToggleHotkeys>

<KeyList BigList AllMainKeys>
<KeyList LilList A, B, C, D>

<Label ....>
<Label ....>

<Hotkey ScrollLockOn BigList; ScrollLockOn Alt BigList; ScrollLockOn Ctr lBigList>
<SendLabel ...>
<Key %Trigger%>

<Hotkey ScrollLockOff LilList>
<SendLabel ...>
<Key %Trigger%>