Jump to content

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


Recommended Posts

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

Link to comment
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

Link to comment
Share on other sites

: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
Link to comment
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
 Share

  • Recently Browsing   0 members

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