maurice cristen
asked on
I need a script to press automatically OK every 2 min
I need a script to press automatically OK every 2 min, see snapshot bellow and here the script i use, not working:
Set wshShell = CreateObject("WScript.Shell")
Do
ret = wshShell.AppActivate("Remote Desktop Connection")
If ret = True Then
wshShell.SendKeys "{ENTER}"
Exit Do
End If
WScript.Sleep 500
Loop
error.JPG
ASKER
ok i will try your script, u already adjust the script,you saw the snapshot and the title seems ok.Is a .vbs script right? how to make it run all the time? just click on it?
The IP is in the window title, so you need that also, changes below. Also, at least for testing, I added a message that will display if the window is not found...
»bp
Set wshShell = CreateObject("WScript.Shell")
Delay = 1000 * 60 * 2 ' two minutes
Title = "38.130.200.183 - Remote Desktop Connection"
Do
ret = wshShell.AppActivate(Title)
If ret = True Then
wshShell.SendKeys "{ENTER}"
Else
Wscript.Echo "Could not locate window: [" & Title & "]"
End If
WScript.Sleep Delay
Loop
»bp
ASKER
wshShell.AppActivate(Title ) , i added here the ip i will try a bit later , wife call me, urgent! hehe
i hope is working
i hope is working
ASKER
not working
Any error?
Does it exit, or stay running?
»bp
Does it exit, or stay running?
»bp
ASKER
i receive this: Could not locate windows: [38.130.200.183 - Remote Desktop Connection]
ASKER
38.130.200.183 is that rdp IP i need to press OK
While you have the Remote Desktop Connection running, open a DOS command window, and enter the following command. What does the Window Title: show?
»bp
tasklist /v /fo list /fi "imagename eq mstsc.exe"
»bp
ASKER
this is the result:
C:\Users\admin>tasklist /v /fo list /fi "imagename eq mstsc.exe"
Image Name: mstsc.exe
PID: 3436
Session Name: RDP-Tcp#3
Session#: 7
Mem Usage: 27,380 K
Status: Running
User Name: BSERVER\admin
CPU Time: 0:00:01
Window Title: 38.130.200.183 - Remote Desktop Connection
ASKER
are u there??
Well, I was able to Activate a RDP window, keep in mind it has to be visible, it can't be minimized. But even with that working, Sendkeys doesn't seem to work with RDP, nothing gets through to the remote terminal. Seems to me I may have heard that somewhere along the line, so no surprise there, it's a security thing I suspect.
Sorry, doesn't look like you can do what you wanted.
»bp
Sorry, doesn't look like you can do what you wanted.
»bp
ASKER
look here can u try to follow this tut? see if u can make it, my english is bad and i don't understand evry well,here a very interesting tut: http://3qilabs.com/autoit-and-basic-authentication-on-locked-machines/
Sorry, I don't have any experience with AutoIT.
»bp
»bp
ASKER
thx
Autoit is great for such things... I haven't used for about 10 years mind but goes along the lines of an .aut file:
inWaitActive("38.130.200.1 83 - Remote Desktop Connection")
Send("!N")
What I would suggest though is can you run the VB script or auto-it IN the RDP session instead?
Also why are you doing this, is it an app you need to click on, or to keep the RDP screen saver from kicking in or something?
If you run it in the RDP session you can look for the specific window with Autoit (or VBScript) and then send Enter or specifically press the button like a mouse click with Autoit.
Steve
inWaitActive("38.130.200.1
Send("!N")
What I would suggest though is can you run the VB script or auto-it IN the RDP session instead?
Also why are you doing this, is it an app you need to click on, or to keep the RDP screen saver from kicking in or something?
If you run it in the RDP session you can look for the specific window with Autoit (or VBScript) and then send Enter or specifically press the button like a mouse click with Autoit.
Steve
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
Ahh, so you didn't need an OK button on an app pressed you wanted to keep RDP connection from being dropped!
Make sure the title that shows at the top of the remote desktop window is exactly "Remote Desktop Connection", otherwise that won't work. Adjust to match exactly.
Open in new window
»bp