PDA

View Full Version : Setup of script on server/client



Fuzzyboy
01-14-2009, 07:04 AM
I've been wondering for a while how this worked on HKN. If I load a script A on the HKN server and another script B on the HKN client, how are the keystrokes interpreted by the client? Does HKN ignore any scripts present on the client PC or does a key (i.e. F1) sent by the server gets interpreted on the client?

olipcs
01-14-2009, 07:36 AM
Honestly I don't know exactly, because I'm not using more than one computer and i'm obviously not Freddie ;)

But from my experience with HKN it does the following:

1. All 'structures' like 'If' and 'Toggle' are only evaluated on the PC you pressed the key on
2. All lines after an 'SendPC xxx.xxx.xxx.xxx' are directly send to the specified PC and executed on them

So for a realy simple hotkey like on PC1 (which is not 192.168.1.66):
<HotKey 1>
<SendPC 192.168.1.66>
<SendFocusWin>
<Key 1>

HKN would simply send the commands <SendFocusWin> and <Key 1> to the PC 192.168.1.66.
This would simply result in an '1' in the active window of PC 192.168.1.66 .

But what you wantetd to know is:
What happens if the hkn-file of PC2 192.168.1.66 has an Hotkey-definition like:

<HotKey 1>
<SendPC Local>
<SendFocusWin>
<Key 2>

In this case if '1' is pressed on PC1 it would not result in sending a '2' to pc2 beccause PC2 only recieves the commands <SendFocusWin> and <Key 1>, and not a command to trigger <HotKey 1>.

If you want that the <HotKey> on PC2 is actualy triggered you can do this by using this on PC1:

<HotKey 1>
<SendPC 192.168.1.66>
<DoHotkey Hotkey 1>

so by using this, on PC1 PC2 should receive a '2'.
Thats my 2 cents, but I think we better wait for freddie to clean up the mess i told you...

Fuzzyboy
01-14-2009, 09:03 AM
Ok, so basically, the server PC sends the interpreted keypres directly to the clients without interpreting the script on the client pc? I assume this means that the script on the client pc is only used if the key is pressed on the client pc. For instance if we have the following scripts:

On the server:

<Hotkey F1>
<sendpc local>
<key F1>
<sendpc 192.168.1.99>
<key F2>

On the client:

<Hotkey F1>
<sendpc local>
<key F1>

I press key F1 on the server PC's keyboard, which will result in F1 being sent to the active window on the server pc and F2 to the active window on the client PC.

I press F1 on the client PC's keyboard, which will result in F1 being sent sent to the active window on the client pc and nothing else. Correct?

olipcs
01-14-2009, 09:53 AM
Correct? I think, yes :)
And as mentioned above if you want to actualy trigger the Hotkey on the client you would use a <DoHotKey> ('http://hotkeynet.com/ref/dohotkey.html') .

Freddie
01-14-2009, 10:44 AM
I assume this means that the script on the client pc is only used if the key is pressed on the client pc.
As usual, Olipcs answered everything correctly while I was fast asleep in my laggard time zone. :) A hotkey definition in the client's script is used only if (1) you press the trigger on the client's keyboard or (2) if you send <DoHotkeyKey> to that PC.

The basic idea is (1) keystrokes injected by a hotkey cannot trigger other hotkeys but (2) if you *want* one hotkey to trigger another, you can do that with <DoHotkey>.

You can also execute code that is contained in a remote PC's script by putting that code in a user-defined command (subroutine).

By the way this isn't only true with multiple PCs. It's also true on a single PC with a single script.

The program's designed like this to prevent a runaway vicious circle in which one hotkey would trigger a second, which would trigger the first, which would trigger the second, etc.