Jump to content

How to retrieve all open windows

Recommended Posts

I have the script witch find the open windows, and put them in the list..

Then i want to be able to click one of them in the list, then push a button, and rename that window..


Here's the rename the selected window part. You will still have to update the title in the GUI list after the window is renamed.

#include <GUIConstants.au3>

GUICreate("GUI", 400, 400)
GUICtrlCreateLabel("Visible Windows", 10, 5, 100, 20)
$list = GUICtrlCreateList("", 10, 20, 350, 350)
$b_Rename = GUICtrlCreateButton("Rename selected Window", 10, 370, 150, 20)

$var = WinList()
Dim $x = -1
For $i = 1 To $var[0][0]
   If $var[$i][0] = "" Then ContinueLoop
   If IsVisible($var[$i][1]) Then
      $x = $x + 1
      GUICtrlSetData($list, $var[$i][0] & "|")
     ;GUIctrlCreatelabel($var[$i][0], 10, ($x * 15) + 25, 400, 20)


While 1
   $msg = GUIGetMsg()
      case $msg = $GUI_EVENT_CLOSE
      case $msg = $b_Rename
         $sOldTitle = GUICtrlRead($list)
         If StringStripWS($sOldTitle, 3) <> "" Then
            $sNewTitle = InputBox("Rename selected Window", "Enter the new name for the selected window." &@lf& "Current Name:" &@lf& $sOldTitle)
            if @error = 0 And StringStripWS($sNewTitle, 3) <> "" Then
               WinSetTitle($sOldTitle, "", $sNewTitle)
              MsgBox(4096, "Nothing selected", "Please select a window to rename.", 3)

Func IsVisible($handle)
   If BitAND(WinGetState($handle), 2) Then
      Return 1
      Return 0
EndFunc  ;==>IsVisible


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

    No registered users viewing this page.

  • Create New...