Jump to content

Recommended Posts

Posted (edited)

Take notepad for example, and you have about 5 notepad windows open, and you have a script that you want to work on all of them when each one becomes active.

I think you can do it with these:

WinWaitActive("")

WinWait("")

But i'm not exactly sure how to use them.

Please help.

Thanks! :)

--

nevermind figured it out

sorry for the inconvenience

Edited by The Great 'Awesoma-Powa!'
Posted

Lesson #9 from "Welcome to Autoit 1-2-3

; 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

8)

NEWHeader1.png

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...