Sign in to follow this  
Followers 0
LoWang

ControlClick unrealiable when used over RDP?

5 posts in this topic

#1 ·  Posted (edited)

Hello, I made myself a little GUI script with an EditBox and a button and I use it quite frequently. To avoid having to look for the window and click into it I also made a command line utility (called rdp.exe) which upon launch does

ControlSetText("RDPconnect","","Edit1",$cmdline[1])
ControlClick("RDPconnect","","Button1")

The GUI program window title is RDPConnect. I am connected via RDP to some server and connect via another RDP to other servers. My idea is to save a few seconds and mouse work when I am in command line so I type rdp hostname and it fills it into this GUI and clicks Button1. The problem is, that sometimes it does not work, sometimes it does... It looks like the Edit1 is always filled successfully, but the button quite often does not get clicked or receives focus but not the actual click (I can see the dotted rectangle around it). Interesting thing is that it can be like twice not working and for the third time it suddenly works. I guess I should add sleep() before ControlClick, but 200ms seems to be not enough. Anybody has experience with this? It seems that send() also has problems when ran locally on a remote server via RDP and sometimes does not send all chars.

Edited by LoWang

Share this post


Link to post
Share on other sites



Is this an AutoIt GUI? If so, don't use Control* commands to work with it, use the internal commands to do it, GUICtrlSetData, GUICtrlRead, etc.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

allright, how do I use GUICtrlSetData to change GUICtrl in another process?

Share this post


Link to post
Share on other sites

Keep using the Control* Commands. Add some https://www.autoitscript.com/autoit3/docs/functions/ControlFocus.htm and some timeouts. Most likely the text you enter is to quick so control is not getting enabled.

so flow would be

1. Activate Window https://www.autoitscript.com/autoit3/docs/functions/WinActivate.htm

2. Set focus to textbox

3. Set SendKeyDelay

4. use send instead of controlsettext

5. Click the button (maybe even first setfocusto the button)

slow down typing shows you initially if the concept will work

https://www.autoitscript.com/autoit3/docs/functions/AutoItSetOption.htm#SendKeyDelay

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thanks, but as I said. ControlSetText seems to work every time. The only problem is the controlclick. I just wonder what is the minumum sleep() pause or controlfocus or whatever to use to make a reliable script :-\ It is quite flakey

Edited by LoWang

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0