JohnBailey Posted January 25, 2007 Posted January 25, 2007 How do you access specific "child Windows" such as that which occurs with Overwrite confirmation? Opt("TrayIconDebug", 1) Run ("notepad.exe","",@SW_HIDE) WinWait("Untitled -") ControlSetText("Untitled -", "", "Edit1", "Saving in the background is cool!" ) ControlSend ( "Untitled - ", "", "Edit1", "{CTRLDOWN}s{CTRLUP}") WinWait("Save As") WinSetState("Save As","",@SW_HIDE) WinWait("Save As") ControlSend ( "Save As", "", "Edit1", @DesktopDir&"\AUTOIT.txt"&"{ENTER}") WinWait("Save As") ControlSend ( "Save As", "", "Edit1", "{ALTDOWN}y{ALTUP}") Sleep(1000) ;ProcessClose ("notepad.exe") A decision is a powerful thing
Valuater Posted January 25, 2007 Posted January 25, 2007 #1 from.... Welcome to Autoit 1-2-3 Using active window expandcollapse popup; This is a demonstration for Communicating with other Windows. #cs This include is not requred, as no GUI's are needed. #include <GuiConstants.au3> #ce ; Wait time after each action - mili-seconds. $Wait = 5500 ; 5.5 seconds ; First we will open notepad. Sleep($Wait) Run("Notepad.exe") WinWaitActive("Untitled -") $variable = '; Wait until the window is active.' Send($variable & @CRLF) $variable = '; @CRLF - Carriage Return Line Feed, so everything is not on one line.' Send($variable & @CRLF) Sleep($Wait) $variable = '; Lets use the Window Handle for controlling Notepad.' Send($variable & @CRLF) Sleep($Wait) $Note_win = WinGetHandle("Untitled -", "") $variable = '; Resize the Notepad window, and move it, see help for details.' Send($variable & @CRLF) Sleep($Wait) WinMove($Note_win, "", 500, 200, 300, 350) $variable = '; Important, The Send Command Only works with the active windows focused control.' Send($variable & @CRLF) Sleep($Wait) $variable = '; Now for some Control keys.' Send($variable & @CRLF) Sleep($Wait) $variable = '; Lets copy all the text, cut, and paste it back. Alt-E-A, Alt-E-T, Ctrl-V ' Send($variable & @CRLF) Send("!EA") Sleep($Wait) Send("!ET") Sleep($Wait) Send("^V") $variable = '; Now lets Close the Notepad. Alt-F-X, Right, and Enter' Send($variable & @CRLF) Sleep($Wait) Send("!FX") Sleep($Wait) Send("{RIGHT}") Sleep($Wait) Send("{ENTER}") ; there is no GUI or loop in this Demo. Exit 8)
Valuater Posted January 25, 2007 Posted January 25, 2007 (edited) #2 from... Welcome to Autoit 1-2-3 Using ControlSend() expandcollapse popup; This is a demonstration for AU3Info and Notepad using ControlSend. ; Wait time after each action. $Wait = 5000 AutoItSetOption("WinTitleMatchMode", 4) ; see "options" in help for title match mode ; From Au3Info we can get $Win_Title = "Untitled - Notepad" $Win_Text = "" $Control_ID = "Edit1" Sleep($Wait) ; re-size the info window WinMove("AutoIt v3 Active Window Info", "", 200, 100, 250, 300) ; Now lets open notepad. Sleep($Wait) Run("Notepad.exe") WinWaitActive("Untitled - Notepad") $variable = '; Wait until the window is active.' ControlSend($Win_Title, $Win_Text, $Control_ID, $variable & @CRLF) Sleep($Wait) $variable = '; Change the Title Name to AutoIt 1-2-3' ControlSend($Win_Title, $Win_Text, $Control_ID, $variable & @CRLF) $New_Title = "Welcome to AutoIt 1-2-3" WinSetTitle($Win_Title, $Win_Text, $New_Title) Sleep($Wait) $variable = '; Lets use the Window Handle for controlling Notepad.' ControlSend($New_Title, $Win_Text, $Control_ID, $variable & @CRLF) Sleep($Wait) $Note_win = WinGetHandle("Untitled -", "") $variable = '; Resize the Notepad window, and move it, see help for details.' ControlSend($New_Title, $Win_Text, $Control_ID, $variable & @CRLF) Sleep($Wait) WinMove($Note_win, "", 500, 100, 400, 500) $variable = '; Important, The ControlSend Command works with the control, Not the active window.' ControlSend($New_Title, $Win_Text, $Control_ID, $variable & @CRLF) Sleep($Wait) $variable = '; Now for a test, lets Hide the Notepad.' ControlSend($New_Title, $Win_Text, $Control_ID, $variable & @CRLF) Sleep($Wait) WinSetState($Note_win, "", @SW_HIDE) $variable = '; Lets send some text to the hidden window ' ControlSend($New_Title, $Win_Text, $Control_ID, $variable & @CRLF) Sleep($Wait) $variable = '; Lets bring back Notepad and check it to be sure. ' ControlSend($New_Title, $Win_Text, $Control_ID, $variable & @CRLF) WinSetState($Note_win, "", @SW_SHOW) Sleep($Wait) $variable = '; Now lets Close the Windows. However the control IDs are Hidden' ControlSend($New_Title, $Win_Text, $Control_ID, $variable & @CRLF) Sleep($Wait) WinClose("AutoIt v3 Active Window Info") ; Win Close ControlSend($New_Title, "", "","!FX") Sleep($Wait) ControlClick("Notepad", "The text in the Untitled file has changed", "Button2") ; Control Click ; there is no GUI or loop in this Demo. Exit ooohhh... i see an error.... opps!!! 8) Edited January 25, 2007 by Valuater
JohnBailey Posted January 30, 2007 Author Posted January 30, 2007 Valuater, I can't seem to get altdown s altup to work with ControlSend $wait = WinWaitActive("File Download","",30) If $wait = 1 Then $passThrough = 0 Sleep(500) $Win_Title = "File Download" $Win_Text = "" $Control_ID = "Edit1" $variable = '{altdown}s{altup}' ControlSend($Win_Title, $Win_Text, $Control_ID, $variable) ;send("{altdown}s{altup}") $wait = WinWaitActive("Save As","",25) If $wait = 1 Then $Win_Title = "Save As" $Win_Text = "" $Control_ID = "Edit1" $variable = $accountFileName&'{enter}' ControlSend($Win_Title, $Win_Text, $Control_ID, $variable) ;send($accountFileName&"{enter}") Else failed("downloadAccount","Activity File Download for "& $accountFileName,$accountName) EndIf A decision is a powerful thing
JohnBailey Posted January 30, 2007 Author Posted January 30, 2007 ANSWER:The first action taking place in my script above is trying to "activate" a button not a text field. As a result, the Control ID must be "Button2" in the above example. It can stay "Edit1" for the second ControlSend because it is "activating" a text field.It works. I don't know for sure if the reason I explained above is right. A decision is a powerful thing
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now