Created
October 6, 2023 08:47
-
-
Save michaelkc/c19c0b9a4d9b3d12f6875ede9f9b568b to your computer and use it in GitHub Desktop.
Keep RDP session alive in background
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#SingleInstance Force ; replace old instance immediately | |
SetTitleMatchMode, 2 | |
Loop | |
{ | |
WinGet, id, List, Remote Desktop Connection | |
Loop, %id% | |
{ | |
this_id := id%A_Index% | |
WinGetTitle, this_title, ahk_id %this_id% | |
; TrayTip, Found RDP session, %this_title%, 2, 17 | |
if A_TimeIdle >= 30000 | |
{ | |
WinGet,MinMaxState,MinMax,ahk_id %this_id% ; get the minimized/maximized state of the window | |
;If (MinMaxState!=0) ; -1 means it is minimized, 1 means it is maximized, 0 means it is neither | |
If (MinMaxState=-1) ; -1 means it is minimized, 1 means it is maximized, 0 means it is neither | |
{ | |
WinRestore,ahk_id %this_id% ; if it is minimized or maximized, restore it before moving | |
WinMove,ahk_id %this_id%,,2560,0 ; move it to its new location | |
} | |
} | |
ControlFocus, , ahk_id %this_id% | |
ControlSend , , {Shift}, ahk_id %this_id% | |
} | |
Sleep, 30001 | |
} | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment