Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

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 :)

Comment on How to set text to text boxes?
Download Code
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 http://web.archive.org/web/20080822214746/http://www.windows-spy.com/download/, 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 http://www.piotrkaluski.com/files/winguitest/docs/ch09s55.html. If you read the source https://metacpan.org/source/KARASIK/Win32-GuiTest-1.60/lib/Win32/GuiTest.pm#L791 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 (Pilgrim) 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?
Username:
Password:

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
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2014-07-13 14:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (250 votes), past polls