Authenticity Posted February 26, 2009 Posted February 26, 2009 expandcollapse popup#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
Floppy Posted February 27, 2009 Author Posted February 27, 2009 (edited) expandcollapse popup#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 Edited February 28, 2009 by FSoft
Floppy Posted February 28, 2009 Author Posted February 28, 2009 There is a problem: If I have 2 windows with the same name, the script shows only one windows in the combo...Any solution?
Authenticity Posted March 1, 2009 Posted March 1, 2009 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now