The Touch-Portal page to control PointerFocus, got even better with direct network communication to PointerFocus!
A couple of days ago, I wrote a post titled Whoo! How powerful Touch-Portal, AutoHotKey and PointerFocus turned out to be! That post describes a solution where I can control PointerFocus-features such as highlight, spotlight and magnify, by triggering the global hotkeys in PointerFocus (F8 to F12) . It worked very good, for the most part. However, it stumbled a little inside Visual Studio CODE (remember, the previous post targeted another sibling IDE, Visual Studio 2019).
In the PointerFocus page https://www.pointerfocus.com/androidapp.html I saw an Android-application acting as a remote control to PointerFocus. In order to work, you have to turn on the PointerFocus’ Remote Server in it’s settings, like shown below. Also note how I now have turned OFF the global hotkeys;
If you are interested, please read on
Below you see the Android-interface. When you first start the app, you are prompted for the IP-address where PointerFocus is running. Remember, you see that in PointerFocus’ Options dialog as show first in this post.
The Android-app works beautifully!
What if I could do the same from my own app?
I wrote a mail asking politely for more information about the protocol that exists between the Android-app and the PointerFocus-app on Windows. Again Mr. Chang was the recipient, and just like the previous mail-time, he responded within a day! I just love when software authors respond like this!!
I was also given permission to blog about the protocol. Here it is:
PointerFocus on Windows listen for UDP messages on port 11000.
The messages are plain text, where all commands are prefixed with the password. Remember that the password is optional. If not used, it will be blank.
The commands are:
<optional password or blank>:highlight:
<optional password or blank>:spotlight:
<optional password or blank>:magnify:
The command above are the ones I have implemented so-far. However, you have more (as you can spot from the Android-app);
<optional password or blank>:pageup:
<optional password or blank>:pagedown:
<optional password or blank>:leftclick:
<optional password or blank>:rightclick:
<optional password or blank>:touchdown:
<optional password or blank>:touchmove:x,y
<optional password or blank>:touchup:
What does the source code look like this time?
Again I have created a little AutoHotKey-script. You find that in the Download-section below. I follow the same code-style as in the first post, and the main changes are:
Marked by yellow, you see how I build the string to send accoding to the format from Mr. Chang.
Marked by red, you see 4 lines creating a UDP-socket, connecting to it on port 11000, and send off the text. Finally we disconnect.
The above code wouldn’t be possible (not at least without huge investigations and lots of trial and error) without the splendid Socket.ahk code from
Philip Taylor (G33kDude). His socket class can be found here; https://github.com/G33kDude/Socket.ahk/blob/master/Socket.ahk
Just as for the previous post, I have also converted the RelayCommandsToPointerFocus.ahk to an executable exe-file. Now I use the new exe file in my Touch-Portal buttons, like this;
The new RelayCommandsToPointerFocus works even better that the first RelayKeysToPointerFocus, since it now communicates via UPD directly. I have not have one “crash” with other global hotkeys since!
Hope this can be helpful!
Download
You may download a zip file containing the AutoHotKey-script, EXE-file and Touch-Portal page here.