n30
n30

Reputation: 19

Autoit controlsend remote desktop

I have a remote desktop and i'm trying to run a simple script to prevent idle session timeout, which is 3 min (quite annoying). The script should, for example, press "A" key every 2.5 min or so.

Problem is, the remote desktop window is often inactive/minimized and:

1) if i try to run such a script "inside" the remote desktop, i still get disconnected, despite it actually works (continues to type or create/delete files etc even as the "idle timer expired" message is on screen). i believe the system wants some "external" action.

2) if i run the script on my PC, it doesn'do anything at all on the remote desktop (i had an open notebook there, and there was no typing):

ControlSend("[CLASS:TscShellContainerClass]", "", "[CLASS:OPContainerClass; INSTANCE:1]", "{A}")

I think the problem lies with the "controlid" part, which i got via autoit window info. If i set controlid as "" - it works, but only if the window is currently active.

I've seen a registry key solution, but doesn't seem to work for me.

If anyone has any ideas about fixing this, please, don't hold back:)

Upvotes: 1

Views: 1540

Answers (1)

Alex
Alex

Reputation: 153

I know it's late but here's the ONLY thing I could get to work; it involved activating the window. I tried ControlFocus but to no avail, so here's what I got.

You should be able to modify your script as needed.

#include<Array.au3>
OPT("WinTitleMatchMode",2)

$a = WinList("Remote Desktop Connection")

;_ArrayDisplay($A)

ConsoleWrite(UBound($A)& @CRLF)
FOR $N = 1 to $A[0][0]
    $hActiveWindow = WinGetHandle("")

    WinActivate($a[$N][1]) ;comment if using controlfocus
    ;ControlFocus($a[$N][1],"","") ;comment if using winactivate
    ControlSend($a[$N][1],"","","^+{ESC}")

    WinActivate($hActiveWindow)
Next

Upvotes: 1

Related Questions