exodius Posted October 18, 2006 Share Posted October 18, 2006 I can't figure out why it is that this script won't hide and show the windows based on the window handles... expandcollapse popup#include <GUIConstants.au3> GUICreate("Window ReOrder", 620, 333, 192, 125) $ListView1 = GUICtrlCreateListView("Window # | Window Name | Window Handle", 16, 8, 490, 310) $MoveUp = GUICtrlCreateButton("Move Up", 520, 32, 91, 33) $MoveDown = GUICtrlCreateButton("Move Down", 520, 80, 91, 33) $MakeChanges = GUICtrlCreateButton("Make Changes", 520, 128, 91, 33) $var = WinList() Dim $list Dim $Count = 1 For $i = 1 to $var[0][0] If $var[$i][0] <> "" AND IsVisible($var[$i][1]) And $var[$i][0] <> "Program Manager" Then GUICtrlCreateListViewItem ( $count & "|" & $var[$i][0] & "|" & $var[$i][1], $ListView1) $count = $count + 1 EndIf Next GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $MoveUp If GUICtrlRead ($ListView1) > 7 And GUICtrlRead ($ListView1) < $count + 7 - 1 Then If StringInStr ( GUICtrlRead(GUICtrlRead($ListView1)), "|" ) Then If StringInStr ( GUICtrlRead(GUICtrlRead($ListView1) - 1), "|" ) Then $Selection = GuiCtrlRead ( $ListView1 ) $SelectionData = GUICtrlRead(GUICtrlRead($ListView1)) $SelectionDataSplit = StringSplit($SelectionData, "|" ) $SelectionDataWinNum = $SelectionDataSplit[1] - 1 $SelectionDataName = $SelectionDataSplit[2] $SelectionDataHandle = $SelectionDataSplit[3] $SelectionData = $SelectionDataWinNum & "|" & $SelectionDataName & "|" & $SelectionDataHandle $ToMove = GuiCtrlRead ( $ListView1 ) - 1 $ToMoveData = GUICtrlRead(GUICtrlRead($ListView1)- 1) $ToMoveDataSplit = StringSplit($ToMoveData, "|" ) $ToMoveDataWinNum = $ToMoveDataSplit[1] + 1 $ToMoveDataName = $ToMoveDataSplit[2] $ToMoveDataHandle = $ToMoveDataSplit[3] $ToMoveData = $ToMoveDataWinNum & "|" & $ToMoveDataName & "|" & $ToMoveDataHandle GuiCtrlSetData ( $ToMove, $SelectionData ) GUICtrlSetData ( $Selection, $ToMoveData ) ControlSend ( "Window ReOrder", "", $ListView1, "{Up}" ) EndIf EndIf EndIf Case $msg = $MoveDown If GUICtrlRead ($ListView1) >= 7 And GUICtrlRead ($ListView1) <= $count + 7 - 1 Then If StringInStr ( GUICtrlRead(GUICtrlRead($ListView1)), "|" ) Then If StringInStr ( GUICtrlRead(GUICtrlRead($ListView1) + 1), "|" ) Then $Selection = GuiCtrlRead ( $ListView1 ) $SelectionData = GUICtrlRead(GUICtrlRead($ListView1)) $SelectionDataSplit = StringSplit($SelectionData, "|" ) $SelectionDataWinNum = $SelectionDataSplit[1] + 1 $SelectionDataName = $SelectionDataSplit[2] $SelectionDataHandle = $SelectionDataSplit[3] $SelectionData = $SelectionDataWinNum & "|" & $SelectionDataName & "|" & $SelectionDataHandle $ToMove = GuiCtrlRead ( $ListView1 ) + 1 $ToMoveData = GUICtrlRead(GUICtrlRead($ListView1)+ 1) $ToMoveDataSplit = StringSplit($ToMoveData, "|" ) $ToMoveDataWinNum = $ToMoveDataSplit[1] - 1 $ToMoveDataName = $ToMoveDataSplit[2] $ToMoveDataHandle = $ToMoveDataSplit[3] $ToMoveData = $ToMoveDataWinNum & "|" & $ToMoveDataName & "|" & $ToMoveDataHandle GuiCtrlSetData ( $ToMove, $SelectionData ) GUICtrlSetData ( $Selection, $ToMoveData ) ControlSend ( "Window ReOrder", "", $ListView1, "{Down}" ) EndIf EndIf EndIf Case $msg = $MakeChanges For $x = 1 To $count + 10 If StringInStr ( GUICtrlRead($x), "|" ) Then $MakeChangesSplit = StringSplit ( GUICtrlRead($x), "|" ) WinSetState ( $MakeChangesSplit[3], "", @SW_HIDE ) EndIf Next For $x = 7 To $count + 10 If StringInStr ( GUICtrlRead($x), "|" ) Then $MakeChangesSplit = StringSplit ( GUICtrlRead($x), "|" ) WinSetState ( $MakeChangesSplit[3], "", @SW_SHOW ) EndIf Next EndSelect WEnd Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc Link to comment Share on other sites More sharing options...
tresa Posted October 18, 2006 Share Posted October 18, 2006 to work with handle did you set opt(WinTitleMatchMode,4)? Link to comment Share on other sites More sharing options...
exodius Posted October 18, 2006 Author Share Posted October 18, 2006 (edited) to work with handle did you setopt(WinTitleMatchMode,4)?Setting that doesn't seem to make a difference... Edited October 18, 2006 by exodius Link to comment Share on other sites More sharing options...
HardCopy Posted October 18, 2006 Share Posted October 18, 2006 (edited) Setting that doesn't seem to make a difference... Quite right, using window handles does not matter what mode you choose. Its irrelevant However, your problem lies in the block of code below., specifically the loop and GUICtrlRead command. What GuiCtrl are you trying to read?, as you have it currently, you are trying to read a control as defined in your $x variable, shouldnt it be $Listview1 ?? i.e GuiCtrlRead(GuiCtrlRead($Listview1)) returns selected item only You need to use the _GUICtrlListViewGet functions, check out the help file. I believe, using guictrlread on a listview on returns ONLY the currently selected item. Not what you want it to do. Sorry cant help specifically, I am knackered Tired, but that is where your problem could lie. but there again im so tired i may be wrong too. Good Luck HardCopy Case $msg = $MakeChanges For $x = 1 To $count + 10 If StringInStr ( GUICtrlRead($x), "|" ) Then $MakeChangesSplit = StringSplit ( GUICtrlRead($x), "|" ); <<<<---- here WinSetState ( $MakeChangesSplit[3], "", @SW_HIDE ) EndIf Next For $x = 7 To $count + 10 If StringInStr ( GUICtrlRead($x), "|" ) Then $MakeChangesSplit = StringSplit ( GUICtrlRead($x), "|" ); <<<<----- here WinSetState ( $MakeChangesSplit[3], "", @SW_SHOW ) EndIf Next EndSelect Edited October 18, 2006 by HardCopy Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad Link to comment Share on other sites More sharing options...
exodius Posted October 18, 2006 Author Share Posted October 18, 2006 Wow, that is so totally what I was doing wrong... And I can see a lot more elegant way to do a lot of what I was doing. Thanks! Link to comment Share on other sites More sharing options...
exodius Posted October 19, 2006 Author Share Posted October 19, 2006 Wow, that is so totally what I was doing wrong... And I can see a lot more elegant way to do a lot of what I was doing. Thanks! So this is the product of HardCopy's observations... but I still can't get it to hide/show the windows at the end to make it put them in order for me! Can anyone else see anything blatantly wrong that I'm doing? expandcollapse popup#include <GUIConstants.au3> #Include <GuiListView.au3> GUICreate("Window ReOrder", 620, 333, 192, 125) $ListView1 = GUICtrlCreateListView("Window Name | Window Handle", 16, 8, 490, 310) $Top = GUICtrlCreateButton("Move to Top", 520, 8, 91, 33) $MoveUpTwo = GUICtrlCreateButton("Move Up Two", 520, 50, 91, 33) $MoveUp = GUICtrlCreateButton("Move Up", 520, 92, 91, 33) $MoveDown = GUICtrlCreateButton("Move Down", 520, 132, 91, 33) $MoveDownTwo = GUICtrlCreateButton("Move Down Two", 520, 174, 91, 33) $Bottom = GUICtrlCreateButton("Move to Bottom", 520, 216, 91, 33) $MakeChanges = GUICtrlCreateButton("Make Changes", 520, 285, 91, 33) $var = WinList() Dim $list Dim $Count = 1 For $i = 1 to $var[0][0] If $var[$i][0] <> "" AND IsVisible($var[$i][1]) And $var[$i][0] <> "Program Manager" Then GUICtrlCreateListViewItem ( $var[$i][0] & "|" & $var[$i][1], $ListView1) EndIf Next _GUICtrlListViewSetColumnWidth($ListView1, 0, 389) _GUICtrlListViewSetItemSelState($ListView1, 0) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Top $Position = _GUICtrlListViewGetCurSel($ListView1) $Current = _GUICtrlListViewGetItemText($ListView1, $Position) _GUICtrlListViewDeleteItem($ListView1, _GUICtrlListViewGetCurSel($ListView1)) _GUICtrlListViewInsertItem($ListView1, 0, $Current) _GUICtrlListViewSetItemSelState($ListView1, 0) Case $msg = $MoveUpTwo If _GUICtrlListViewGetCurSel($ListView1)-2 > -1 Then $Position = _GUICtrlListViewGetCurSel($ListView1) $Current = _GUICtrlListViewGetItemText($ListView1, $Position) _GUICtrlListViewDeleteItem($ListView1, _GUICtrlListViewGetCurSel($ListView1)) _GUICtrlListViewInsertItem($ListView1, $Position - 2, $Current) _GUICtrlListViewSetItemSelState($ListView1, $Position - 2) EndIf Case $msg = $MoveUp $Position = _GUICtrlListViewGetCurSel($ListView1) $Current = _GUICtrlListViewGetItemTextArray ($ListView1, $Position) $New = _GUICtrlListViewGetItemTextArray ($ListView1, $Position-1) _GUICtrlListViewSetItemText($ListView1, $Position, 0, $New[1]) _GUICtrlListViewSetItemText($ListView1, $Position, 1, $New[2]) _GUICtrlListViewSetItemText($ListView1, $Position-1, 0, $Current[1]) _GUICtrlListViewSetItemText($ListView1, $Position-1, 1, $Current[2]) _GUICtrlListViewSetItemSelState($ListView1, $Position - 1) Case $msg = $MoveDown If _GUICtrlListViewGetCurSel($ListView1)+1 < _GUICtrlListViewGetItemCount($ListView1) Then $Position = _GUICtrlListViewGetCurSel($ListView1) $Current = _GUICtrlListViewGetItemTextArray ($ListView1, $Position) $New = _GUICtrlListViewGetItemTextArray ($ListView1, $Position+1) _GUICtrlListViewSetItemText($ListView1, $Position, 0, $New[1]) _GUICtrlListViewSetItemText($ListView1, $Position, 1, $New[2]) _GUICtrlListViewSetItemText($ListView1, $Position+1, 0, $Current[1]) _GUICtrlListViewSetItemText($ListView1, $Position+1, 1, $Current[2]) _GUICtrlListViewSetItemSelState($ListView1, $Position + 1) EndIf Case $msg = $MoveDownTwo If _GUICtrlListViewGetCurSel($ListView1)+2 < _GUICtrlListViewGetItemCount($ListView1) Then $Position = _GUICtrlListViewGetCurSel($ListView1) $Current = _GUICtrlListViewGetItemText($ListView1, $Position) _GUICtrlListViewDeleteItem($ListView1, _GUICtrlListViewGetCurSel($ListView1)) _GUICtrlListViewInsertItem($ListView1, $Position + 2, $Current) _GUICtrlListViewSetItemSelState($ListView1, $Position + 2) EndIf Case $msg = $Bottom $Position = _GUICtrlListViewGetCurSel($ListView1) $Current = _GUICtrlListViewGetItemText($ListView1, $Position) _GUICtrlListViewDeleteItem($ListView1, _GUICtrlListViewGetCurSel($ListView1)) _GUICtrlListViewInsertItem($ListView1, _GUICtrlListViewGetItemCount($ListView1), $Current) _GUICtrlListViewSetItemSelState($ListView1, _GUICtrlListViewGetItemCount($ListView1)) Case $msg = $MakeChanges For $x = 0 To _GUICtrlListViewGetItemCount($ListView1)-1 $MakeChangesSplit = _GUICtrlListViewGetItemTextArray ( $ListView1, $x ) WinSetState ( $MakeChangesSplit[2], "", @SW_HIDE ) Next For $x = 0 To _GUICtrlListViewGetItemCount($ListView1)-1 $MakeChangesSplit = _GUICtrlListViewGetItemTextArray ( $ListView1, $x ) WinSetState ( $MakeChangesSplit[2], "", @SW_SHOW ) Next EndSelect WEnd Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc Link to comment Share on other sites More sharing options...
Blue_Drache Posted October 19, 2006 Share Posted October 19, 2006 Quite right, using window handles does not matter what mode you choose. Its irrelevantBusted.RemarksThis function is for use with the advanced WinTitleMatchMode options that allow you to use classnames and handles to specify windows rather than "title" and "text".Once you have obtained the handle you can access the required window even if its title changes. Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
exodius Posted October 19, 2006 Author Share Posted October 19, 2006 Busted.Was any of this post actually directed at me? Link to comment Share on other sites More sharing options...
HardCopy Posted October 19, 2006 Share Posted October 19, 2006 Was any of this post actually directed at me?LoL no...was at me!!My statement i made was a little misleading when another responder said try:Opt("WinTitleMatchMode",4), i said it was irrelevant, but what that came over as was, u dont need to use itWhat i should of said, was that which ever option parameter you use, when addressing using window handles as you are, it doesnt matter which option you use 1,2,3 or 4. So now u have made some changes, include it at the top see if that does indeed now work.HardCopy Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad Link to comment Share on other sites More sharing options...
Blue_Drache Posted October 19, 2006 Share Posted October 19, 2006 Sorry for the confusion, exodius Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
exodius Posted October 19, 2006 Author Share Posted October 19, 2006 Sorry for the confusion, exodiusIt's all good... although when I tried switching the WinTitleMatchMode it didn't help... Link to comment Share on other sites More sharing options...
HardCopy Posted October 19, 2006 Share Posted October 19, 2006 (edited) It's all good... although when I tried switching the WinTitleMatchMode it didn't help... Ok add wintitlematchmode,4 at top change your code section makechanges to this: we were missing the HWnd command,because handles are not either strings or numbers. doh!!! Case $msg = $MakeChanges For $x = 0 To _GUICtrlListViewGetItemCount($ListView1)-1 $MakeChangesSplit = _GUICtrlListViewGetItemTextArray ( $ListView1, $x ) WinSetState (HWnd($MakeChangesSplit[2]), "", @SW_HIDE ) Next For $x = 0 To _GUICtrlListViewGetItemCount($ListView1)-1 $MakeChangesSplit = _GUICtrlListViewGetItemTextArray ( $ListView1, $x ) WinSetState (HWnd($MakeChangesSplit[2]), "", @SW_SHOW ) Next HardCopy Edited October 19, 2006 by HardCopy Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad Link to comment Share on other sites More sharing options...
exodius Posted October 19, 2006 Author Share Posted October 19, 2006 Okadd wintitlematchmode,4 at topchange your code section makechanges to this:we were missing the HWnd command,because handles are not either strings or numbers. doh!!!HardCopyThat did the trick! Thanks a lot, I didn't know that it was necessary to use the HWnd command with handles... I knew of it, and now that you mention it, it makes sense... maybe that little tidbit of info needs added to the Winlist and WinGetHandle pages in the helpfile.At any rate, thanks a bunch hardcopy! Now I don't suppose you'd have any idea on how to get a listing of the windows in the order that they appear on the toolbar would ya? Link to comment Share on other sites More sharing options...
HardCopy Posted October 19, 2006 Share Posted October 19, 2006 That did the trick! Thanks a lot, I didn't know that it was necessary to use the HWnd command with handles... I knew of it, and now that you mention it, it makes sense... maybe that little tidbit of info needs added to the Winlist and WinGetHandle pages in the helpfile.At any rate, thanks a bunch hardcopy! Now I don't suppose you'd have any idea on how to get a listing of the windows in the order that they appear on the toolbar would ya? No, sorry, I Don't But u can apparently, dictate the order you want them to appear, by hiding then showing them againsee here: LinkHardCopy Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad Link to comment Share on other sites More sharing options...
exodius Posted October 19, 2006 Author Share Posted October 19, 2006 No, sorry, I Don't But u can apparently, dictate the order you want them to appear, by hiding then showing them againsee here: LinkHardCopyIt's all good, that very action is exactly what this script is geared towards. It'd be nice if this script could present them to you in the order they're already in so if you just wanted to move a single window for example then it wouldn't be as much work.. I'm starting to think there isn't a way to know.. or at least if there is no one's aware of it. But hey I do appreciate all of your help on this, you defintely got me past the snags that I'd ran into. Thanks! 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