Sign in to follow this  
Followers 0
dwaynek

how to get Visible Text info from multiple windows which have same titles?

5 posts in this topic

so i know i can use WinGetText to obtain Visible Text info from a window but what if i have multiple windows with the exact same name? how do i get Visible Text info from each window and how would i be able to use that info to manipulate each window individually (eg if i want to move each window to a different location on the screen)?

Share this post


Link to post
Share on other sites



hi dwaynek,

Use windows handles to manipulate windows rather than their titles. Here's a quick ex: :huh2:

;simulate some open windows
Run("notepad.exe")
Run("notepad.exe")
WinWait("Untitled - Notepad")

Local $aSomeText[3] = [2, "This is some text", "This is some different text"]

;get list with titles and handles
$hArray = WinList("Untitled - Notepad")

ConsoleWrite($hArray[0][0] & " notepad windows found" & @CRLF)

;write some stuff
For $i = 1 To $hArray[0][0]
    ControlSetText($hArray[$i][1], "", "[CLASS:Edit; INSTANCE:1]", $aSomeText[$i])
Next

Hope this helps ;),

-smartee

Share this post


Link to post
Share on other sites

great! is there a way to move each window using handles? because WinMove doesn't take a handle as a parameter.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

:huh2: Glad to help

..is there a way to move each window using handles? because WinMove doesn't take a handle as a parameter.

;) Yes it does, Here's another example :alien::
;open some notepad windows
Run("notepad.exe")
Run("notepad.exe")

;Wait on notepads to open
Do
    $hArray = WinList("Untitled - Notepad")
    Sleep(250)
Until $hArray[0][0] > 1
ConsoleWrite($hArray[0][0] & " notepad windows found" & @CRLF)

Local $aSomeText[3] = [2, "This is some text", "This is some different text"]

;write and move some stuff more visually
For $i = 1 To $hArray[0][0]
    WinActivate($hArray[$i][1])
    WinWaitActive($hArray[$i][1])
    WinMove($hArray[$i][1], "", 100 * $i, 50 * $i, 500, 400, 10)
    ControlSend($hArray[$i][1], "", "[CLASS:Edit; INSTANCE:1]", $aSomeText[$i])
    Sleep(1000)
Next

Hope this helps :ph34r:

-smartee

EDIT: Removed an unnecessary call WinList()

Edited by smartee

Share this post


Link to post
Share on other sites

awesome! that's exactly what i needed! you da man!!

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