Jump to content

[SOLVED] Get all windows


Floppy
 Share

Recommended Posts

#include <GuiConstants.au3>
#include <GuiComboBox.au3>
#include <WinAPI.au3>
#include <Array.au3>
#include <Constants.au3>
#include <windowsConstants.au3>
Opt('MustDeclareVars', 1)

Dim $hUser32 = DllOpen('user32.dll')

GUICreate("Test", 390, 250)
GUICtrlCreateLabel("Perform:", 20, 45, 310, 20)
Dim $do_combo = GUICtrlCreateCombo("", 20, 60, 350, 100, 0x0003)
Dim $test = GUICtrlCreateButton("only a test", 100, 150)
GUISetState()

While 1
    Local $m = GUIGetMsg()
    
    Select
        Case $m = $GUI_EVENT_CLOSE
            ExitLoop
            
        Case $m = $test
            Local $aWin = WinList()
            Local $iEx_Style, $iStyle
            Local $i
            GUICtrlSetData($do_combo, '')
            
            For $i = 1 To $aWin[0][0]
                
                $iEx_Style = BitAND(GetWindowLong($aWin[$i][1], $GWL_EXSTYLE, $hUser32), $WS_EX_TOOLWINDOW)
                $iStyle = BitAND(WinGetState($aWin[$i][1]), 2)
                
                If Not $iEx_Style And $iStyle Then
                    GUICtrlSetData($do_combo, $aWin[$i][0])
                EndIf
            Next
        EndSelect
WEnd

DllClose($hUser32)

Func GetWindowLong($hWnd, $iIndex, $hUser = 'user32.dll')
    Local $Ret = DllCall($hUser, 'int', 'GetWindowLong', 'hwnd', $hWnd, 'int', $iIndex)
    If Not @error Then Return $Ret[0]
    Return SetError(-1, 0, -1)
EndFunc   ;==>GetWindowLong

Link to comment
Share on other sites

#include <GuiConstants.au3>
#include <GuiComboBox.au3>
#include <WinAPI.au3>
#include <Array.au3>
#include <Constants.au3>
#include <windowsConstants.au3>
Opt('MustDeclareVars', 1)

Dim $hUser32 = DllOpen('user32.dll')

GUICreate("Test", 390, 250)
GUICtrlCreateLabel("Perform:", 20, 45, 310, 20)
Dim $do_combo = GUICtrlCreateCombo("", 20, 60, 350, 100, 0x0003)
Dim $test = GUICtrlCreateButton("only a test", 100, 150)
GUISetState()

While 1
    Local $m = GUIGetMsg()
    
    Select
        Case $m = $GUI_EVENT_CLOSE
            ExitLoop
            
        Case $m = $test
            Local $aWin = WinList()
            Local $iEx_Style, $iStyle
            Local $i
            GUICtrlSetData($do_combo, '')
            
            For $i = 1 To $aWin[0][0]
                
                $iEx_Style = BitAND(GetWindowLong($aWin[$i][1], $GWL_EXSTYLE, $hUser32), $WS_EX_TOOLWINDOW)
                $iStyle = BitAND(WinGetState($aWin[$i][1]), 2)
                
                If Not $iEx_Style And $iStyle Then
                    GUICtrlSetData($do_combo, $aWin[$i][0])
                EndIf
            Next
        EndSelect
WEnd

DllClose($hUser32)

Func GetWindowLong($hWnd, $iIndex, $hUser = 'user32.dll')
    Local $Ret = DllCall($hUser, 'int', 'GetWindowLong', 'hwnd', $hWnd, 'int', $iIndex)
    If Not @error Then Return $Ret[0]
    Return SetError(-1, 0, -1)
EndFunc   ;==>GetWindowLong
Thank you...it works :P Edited by FSoft
Link to comment
Share on other sites

Change the button case to this:

Case $m = $test
            Local $aWin = WinList()
            Local $iEx_Style, $iStyle
            Local $i, $sStrings = ''
            
            GUICtrlSetData($do_combo, '')
           
            For $i = 1 To $aWin[0][0]
                $iEx_Style = BitAND(GetWindowLong($aWin[$i][1], $GWL_EXSTYLE, $hUser32), $WS_EX_TOOLWINDOW)
                $iStyle = BitAND(WinGetState($aWin[$i][1]), 2)
               
                If Not $iEx_Style And $iStyle Then
                    $sStrings &= $aWin[$i][0] & '|'
                EndIf
            Next
            GUICtrlSetData($do_combo, StringTrimRight($sStrings, 1))
EndSelect
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...