AHK script does not work on VPS when RDP connection is closed

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
bernard9
Posts: 2
Joined: 07 Jun 2021, 06:54

AHK script does not work on VPS when RDP connection is closed

Post by bernard9 » 07 Jun 2021, 07:22

As title suggests I wrote a script which basically saves reddit notifications into a text file every x minutes for me. It's a simple script and works great during the time its launched on my laptop or on the VPS as long as I have an active RDP session.

However, as soon as I close the rdp session Send/SendEvent/SendInput of ^a, ^c, ^v and ^w fail to work. I've been able to google my way into other people having issues with VPS running scripts and it seems generally it is due to VPS not having a monitor.

Is there any workaround to make this work?

Solutions I tried but didn't help:
- converting script into the .exe and running it as a service
- switching from Send to SendEvent to SendInput
- Opening RDP from another VPS into the main VPS

Any ideas would be welcome! Thanks.

Script:

Code: Select all

MsgBox,, Warning, Pause what you're doing for a minute while the reddit followers script runs - Click OK to run the script, 30
Sleep, 2000
Run, https://www.reddit.com/notifications
Sleep, 1000
Send, {ENTER}
Sleep, 10000
Send {End}
Sleep, 1000
Send {End}
Sleep, 1000
Send {End}
Sleep, 1000
Send, ^a
Sleep, 1000
Send, ^c
Sleep, 1000
Run Notepad.exe
Sleep, 1000
Send, ^v
Sleep, 1000
Send, ^s
Sleep, 1000
Send, R.Followers Export - %A_Hour%.%A_Min%.%A_Sec% %A_DD%-%A_MM%-%A_YYYY%
Sleep, 3000
Send, {ENTER}
Sleep, 3000
Send, {ENTER}
Sleep, 1000
Send !{f4}
Sleep, 3000
Send, ^w
Sleep, 1000
MsgBox,, Warning, Scraping Complete Click OK to continue work, 30
return

Return to “Ask for Help (v1)”