Jump to content
Sign in to follow this  
Wb-FreeKill

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..

<{POST_SNAPBACK}>

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)
     ;MsgBox(0,"test",$var[$i][0])
   EndIf
Next

GUISetState(@SW_SHOW)

While 1
   Sleep(25)
   $msg = GUIGetMsg()
   Select
      case $msg = $GUI_EVENT_CLOSE
         ExitLoop
      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)
            EndIf
            Else
              MsgBox(4096, "Nothing selected", "Please select a window to rename.", 3)
         EndIf
   EndSelect
WEnd


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

Phillip

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...