Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

How to set text to text boxes?

by pradeep,krishna (Scribe)
on Feb 11, 2014 at 06:24 UTC ( #1074348=perlquestion: print w/replies, xml ) Need Help??
pradeep,krishna has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks...

I have used bellow code to open the server connection through 'Remote Desktop Connection'.

use Win32::GuiTest qw(FindWindowLike WaitWindow WMSetText PushChildBut +ton GetFocus SetFocus); system('"start %windir%\system32\mstsc.exe"'); $Win32::GuiTest::debug = 0; $c=WaitWindow("Remote Desktop Connection",$max_Sleep_time); @windows = FindWindowLike(0, "Remote Desktop Connection"); for (@windows) { $fc_hwnd = GetFocus( $_ ); PushChildButton ($_,Options); SetFocus($fc_hwnd); $set1 = WMSetText($fc_hwnd,"Servername"); $set2 = WMSetText($fc_hwnd+2,"USER_Name"); } sleep(5); PushChildButton( $_, "Co&nnect");

When PushChildButton ($_,Options); is executed the 'Computer' and 'User Name' Text boxes are activated. Using '$fc_hwnd' (control Id of 'Computer' text box taken from get focus at start) I am able to set the text for that textbox. I am not getting how to set text to 'User Name' Text box.

Assist me in solving this

Thanks in advance

Pradeep Krishna :)

Replies are listed 'Best First'.
Re: How to set text to text boxes?
by bulk88 (Priest) on Feb 11, 2014 at 07:04 UTC
    I'm not sure how RDC is implemented under the hood, but if I substitute VNC, you can't do that. A VNC window is a flat pixel canvass. The individual addressable controls you see are on the remote machine, not your machine. I dont think there are any User32.dll recognized buttons in that window for you to click. Try Winspector Spy, use the red gunscope thing, drag it over your RDC window. A red border around the selected control will show up. See if you can isolate individual controls out of that RDC window. If you can not, the entire large RDC window is the smallest addressable thing, and it is not "a button". Your only choice is to synthesize keyboard keys or X,Y coord mouse clicks inside that window. You also didn't check the return value of PushChildButton as per If you read the source you will see "the button" was clicked at 0,0. If your "button" is the entire window. The synthesized click landed nowhere near your human seen button in that window.
Re: How to set text to text boxes?
by jellisii2 (Hermit) on Feb 11, 2014 at 13:05 UTC
    This is yet another in a list of "how do I control a Windows PC remotely" items that you've submitted. I assume the app you're trying to mangle is only GUI based and you can't install code on the machine you're trying to control.

    I am curious if this could be an XY Problem? Context revealed may net novel ideas on how to address this sticky problem.

    Check the WaitWindow and SendKeys methods.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1074348]
Approved by Laurent_R
Front-paged by mtmcc
and nobody stirs...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2017-07-22 11:58 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (338 votes). Check out past polls.