Tunnel hotkeys without VNC to remote computer

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
TXShooter
Posts: 165
Joined: 13 Dec 2017, 09:27

Tunnel hotkeys without VNC to remote computer

13 Dec 2017, 11:05

I'm new to this forum and pretty new to AHK. I was introduced to it just the other day by 'sumpm1' in a different forum and I really like AHK... I'm imagining all kinds of possibilities now because of it.

In that other forum I am attempting to do something that I thought maybe AHK could do. However, trying to pin down the exact verbiage to research it in Google, and even here in this forum, has been a challenge. I tried using search terms on this forum: script network lan control send receive . The results were zero.

What I'm trying to do: I have have an application on PC1 that will be launched and ran via AHK script 4 times a week using Windows Task Scheduler. That script part is fine and I will be testing the scheduler functionality later today.

(This computer (PC1) has to be where it is because of a USB connection, and will not be accessible except via VNC across the internet at other times. I could go into great and tumultuous detail about the whys and hows of what's going on, but that would take about 20 to 30 comments and about 5 different sub-threads to explain half of it, which would completely distract from the purpose of my coming to this forum, not to mention a lot of time wasted. If you really want to see where I am coming from... here's the thread on that other forum: https://forum.cockos.com/showthread.php?t=200213)

My issue is that I need to make some key presses at unpredictable times in order to 'mark' on my computer when a function in the real world occurs, and I need to do that via another computer on the same network, but without using VNC (it creates latency issues due to the video bandwidth).

There is someone in a different part of the building that also captures these events using different software (Audacity) on his computer (PC2) for a similar but different function than I do, and he's doing it with that program's hotkeys. I was hoping to build a script that would capture his hotkeys, split them to continue performing their actions, and pipe it across the network to do the 'marking' on my computer software (Reaper).

Sooo. is there a simple way to maybe accomplish this? I found some stuff using AHK from several years ago, but to be honest some of it was over my head, and I got the impression it wasn't complete. I can study through it if I have to... I was just hoping someone else has a better, faster, and more modern way. (A further application like this could be to tunnel the keyboard and mouse to the remote PC to maybe control a slideshow on a projector... just a thought on how this could be expanded.)

Sorry for the long post, and Many thanks,
TXShooter
John316
Posts: 13
Joined: 15 Dec 2017, 08:53

Re: Tunnel hotkeys without VNC to remote computer

15 Dec 2017, 11:54

Hello,

2 suggestions..
1) You could make a "send" and "receive" ahk script that talks/listens over an ssh connection. I just tested this with Putty and Freesshd and it works. Put the "send" script on the PC that needs to send/start the whole process. Then put the "receive" script on the PC that needs to automate keystrokes.

My "send" test script was this...

Code: Select all

SetTitleMatchMode, 2 	; A window's title can contain WinTitle anywhere inside it to be a match
DetectHiddenWindows, On 	; Hidden windows are detected
WinActivate, PuTTY 			; Bring PuTTY to the front
Sleep, 1000 				; wait 1 second
send, echo command >> hi.txt 	; send the keystrokes -- echo command
Sleep, 1000 				; wait 1 second
Send, {enter} 				; Send the Enter key
My "receive" script was this...

Code: Select all

runcount = 0 						; variable to keep track of the usage amount
Loop 							; loop
{
	if runcount = 1 					; check to see if the command was sent already
	{
		continue 					; go to the end of the loop skipping the other code
	}
	IfExist, hi.txt 					; if the file hi.txt exist then put the contents into a variable
	{ 							
		fileread, var, hi.txt
		IfInString, var, command 		; check if the command you wanted to send was there
		{
			runcount = 1 			; store in a variable that the command ran
			gosub, cmd 			; go to the subroutine cmd
		}
	}
	else 							; otherwise wait 1 second
		sleep, 1000
}
cmd: 							; label to jump to
Run, notepad.exe	 				; start notepad to act on it
Sleep, 5000 						; wait 5 seconds (a better way is [WinWait, Notepad])
send, m 							; send the letter m to notepad
return
Option 2)
Host a text based file on the internet (Apache server will work -- Maybe Dropbox). Then have your PCs "listen" with a script using something like

Code: Select all

UrlDownloadToFile
to keep checking for the updated command. For example, if the hosted text file was an .ini type file you could have the "listening" scripts checking the sections for specific words like Send, Run, Sleep, etc... Once the "listening" script reads a new command it can execute it based on what .ini section was read (Send, Run, Sleep). I've done something like that before and it worked well but I used it for updating my ahk script.

There's most likely a better way to do this but I know these work. The second option I think would be more reliable. I hope this helps..

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: aitaixy, Anput, dangoscrub, doodles333, joedf, Nerafius and 118 guests