FinalVersion Posted March 28, 2010 Share Posted March 28, 2010 How can I get only get Minimized and Visible windows? [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 28, 2010 Moderators Share Posted March 28, 2010 (edited) Under WinList() in the help file, there's actually a hint in the example. I threw this together rather quickly, I'm not sure if there's any issues with it, but there shouldn't be. expandcollapse popup#include <Array.au3> ; Used for _ArrayDisplay only Global Const $i_win_exists = 1 Global Const $i_win_visible = 2 Global Const $i_win_enabled = 4 Global Const $i_win_active = 8 Global Const $i_win_minimized = 16 Global Const $i_win_maximized = 32 ; Global $a_wins = _WinListByState("", "", $i_win_visible, $i_win_minimized) _ArrayDisplay($a_wins) Func _WinListByState($v_title, $s_text = "", $i_s1 = 0, $i_s2 = 0, $i_s3 = 0, $i_s4 = 0, $i_s5 = 0, $i_s6 = 0) Local $a_wlist = 0, $i_add = 0 If $v_title Or $s_text Then $a_wlist = WinList($v_title, $s_text) Else $a_wlist = WinList() EndIf If @error Or Not IsArray($a_wlist) Then Return SetError(1, 0, 0) If Not BitOR($i_s1, $i_s2, $i_s3, $i_s4, $i_s5, $i_s6) Then Return $a_wlist Local $a_winret[$a_wlist[0][0] + 1][2] = [[$a_wlist[0][0]]] ; State array Local $a_tmp[7] = [6, $i_s1, $i_s2, $i_s3, $i_s4, $i_s5, $i_s6] Local $a_state[7] = [6], $i_st_add = 0 For $i_st = 1 To $a_tmp[0] If $a_tmp[$i_st] Then $i_st_add += 1 $a_state[$i_st_add] = $a_tmp[$i_st] EndIf Next If $i_st_add < $a_tmp[0] Then ReDim $a_state[$i_st_add + 1] $a_state[0] = $i_st_add EndIf Local $i_state = 0 For $i_win = 1 To $a_wlist[0][0] $i_state = WinGetState($a_wlist[$i_win][1]) For $i_st = 1 To $a_state[0] If Not BitAND($i_state, $a_state[$i_st]) Then ContinueLoop 2 Next $i_add += 1 $a_winret[$i_add][0] = $a_wlist[$i_win][0] $a_winret[$i_add][1] = $a_wlist[$i_win][1] Next If Not $i_add Then Return SetError(2, 0, 0) If $i_add < $a_wlist[0][0] Then ReDim $a_winret[$i_add + 1][2] $a_winret[0][0] = $i_add EndIf Return $a_winret EndFunc Edited March 28, 2010 by SmOke_N removed consolewrite Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
FinalVersion Posted March 28, 2010 Author Share Posted March 28, 2010 That seems more necessary then for what I want is needed. $aList = WinList() For $i = 1 To $aList[0][0] If Not $aList[$i][0] = "" Then MsgBox(0, "", $aList[$i][0]) Endif Next I'm thinking adding a WinGetState into the for loop, check if it's minimized, visible or active, then output the message box if true. [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 28, 2010 Moderators Share Posted March 28, 2010 (edited) That seems more necessary then for what I want is needed. $aList = WinList() For $i = 1 To $aList[0][0] If Not $aList[$i][0] = "" Then MsgBox(0, "", $aList[$i][0]) Endif Next I'm thinking adding a WinGetState into the for loop, check if it's minimized, visible or active, then output the message box if true. Your request above is different than what you originally asked. Now you're asking for an "Or" statement rather than an "And" statement. Anyway, look at the code, as I said, both WinList() and my example offer a the method to achieve what you want. Post what you've tried after that. You're posted coded shows no attempt to even use WinGetState(). Edited March 28, 2010 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
FinalVersion Posted March 28, 2010 Author Share Posted March 28, 2010 It didn't include an example because I didn't think what I was going to write would work. And I was right, since WinGetState() returns all there values and adds them up. [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 28, 2010 Moderators Share Posted March 28, 2010 (edited) It didn't include an example because I didn't think what I was going to write would work. And I was right, since WinGetState() returns all there values and adds them up. Exactly, you could have gotten something out of the For/Next loop I was showing, you'll see it's checking BitAnd() values for the WinGetState(). So: ;psuedo code $i_state = WinGetState($a_array[$i][1]) If BitAnd($i_state, visible integer value) And (BitAnd($i_state, minimized integer value) Or BitAnd($i_state, active integer value)) Then ; You have a match EndIf Edited March 28, 2010 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
bo8ster Posted March 29, 2010 Share Posted March 29, 2010 You are a coding machine SmOke_N! Thanks for the script. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
FinalVersion Posted March 29, 2010 Author Share Posted March 29, 2010 (edited) Doesn't show visible windows for me, assuming visible windows are not minimized or active, there just behind the only active window. $aList = WinList() For $i = 1 To $aList[0][0] If $aList[$i][0] <> "" Then $iState = WinGetState($aList[$i][0]) If BitAnd($iState, 2) And (BitAnd($iState, 16) Or BitAnd($iState, 8)) Then MsgBox(0, "!", $aList[$i][0]) EndIf EndIf Next Edited March 29, 2010 by FinalVersion [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 29, 2010 Moderators Share Posted March 29, 2010 Doesn't show visible windows for me, assuming visible windows are not minimized or active, there just behind the only active window. $aList = WinList() For $i = 1 To $aList[0][0] If $aList[$i][0] <> "" Then $iState = WinGetState($aList[$i][0]) If BitAnd($iState, 2) And (BitAnd($iState, 16) Or BitAnd($iState, 8)) Then MsgBox(0, "!", $aList[$i][0]) EndIf EndIf Next Visible windows can be in minimized or active state. They just have not had their state set to hidden. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
FinalVersion Posted March 30, 2010 Author Share Posted March 30, 2010 What's the state for windows behind the active windows? Inactive? [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center] Link to comment Share on other sites More sharing options...
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