Sodori Posted June 2, 2015 Share Posted June 2, 2015 Hi! My list view sorts funny, it goes:112134225624836488And so fourth, instead of sorting it like common folks would! I can imagine I could fix this by adding zeroes in front to match the highest numbers string length (like 001). But I'd like it to instead sort it like any grade A maths teacher would:123101520Any ideas? Also, how hard would it be to make a selected item in the list copyable. Just instead of straight copy that line, instead have it activate a script to use ClipPut() to make the user copy a certain string based on what list object they selected? This is a episode folder scanner, so if I copied missing episode 9. Instead of "Episode 9" being in clipboard, have "[something, something] & 9" in clipboard.Here is my koda script so you can see my GUI:#Region ### START Koda GUI section ### Form= $LesGUI = GUICreate("Linas Episode Scanner", 274, 242, 192, 124, -1, BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE)) $IDirectory = GUICtrlCreateInput("", 8, 8, 225, 21) $browse = GUICtrlCreateButton("...", 240, 8, 30, 21) $Season = GUICtrlCreateLabel("Season #", 8, 56, 50, 17, $SS_CENTER) $ISeason = GUICtrlCreateInput("Null", 8, 80, 50, 21) $EpisodeS = GUICtrlCreateLabel("Episode Start", 103, 56, 67, 17, $SS_CENTER) $EpisodeE = GUICtrlCreateLabel("Episode End", 200, 56, 64, 17) $IEpisodeS = GUICtrlCreateInput("Null", 113, 80, 50, 21) $IEpisodeE = GUICtrlCreateInput("Null", 200, 80, 65, 21) $BExit = GUICtrlCreateButton("Exit", 192, 208, 75, 25) $BRefresh = GUICtrlCreateButton("Refresh", 192, 176, 75, 25) $BTop = GUICtrlCreateButton("Stay On Top", 192, 144, 75, 25) $LEpisodesMissing = GUICtrlCreateLabel("Missing Episodes:", 8, 112, 88, 17) $ListMissing = GUICtrlCreateList("", 8, 136, 153, 97) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted June 2, 2015 Share Posted June 2, 2015 Just messing around, not sure if itst a solution any better than what you had or if it even works in your situation but its a proof of concept #Include <Array.au3> Local $aTest[8] = ["1", "2", "3", "12", "134", "14", "256", "8"] Local $aTest2[8] For $i = 0 to UBound($aTest) -1 $aTest2[$i] = Hex($aTest[$i]) Next _ArrayDisplay($aTest) _ArrayDisplay($aTest2) _ArraySort($aTest2) For $i = 0 to UBound($aTest) -1 $aTest[$i] = Dec($aTest2[$i]) Next _ArrayDisplay($aTest) _ArrayDisplay($aTest2) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 3, 2015 Moderators Share Posted June 3, 2015 Sodori,By default the list control has the $LB_SORT style which forces a sort of the items and also assumes that they are in string format, which leads to the rather unexpected order you see. So you need to remove that style from the list when you create it and sort the values as numbers before adding them to the list:#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> ; Array of values as strings Global $aList_String[8] = ["1", "2", "3", "12", "134", "14", "256", "8"] ; And sorted as strings _ArraySort($aList_String) ; Array of values as numbers Global $aList_Number[8] = [1, 2, 3, 12, 134, 14, 256, 8] ; And sorted as numbers _ArraySort($aList_Number) $hGUI = GUICreate("Test", 500, 500) ; Create lists without the sort style $cList_String = GUICtrlCreateList("", 10, 10, 230, 300, BitOr($WS_BORDER, $WS_VSCROLL)) $cList_Number = GUICtrlCreateList("", 260, 10, 230, 300, BitOr($WS_BORDER, $WS_VSCROLL)) ; Add items to the lists For $i = 0 To 7 GUICtrlSetData($cList_String, $aList_String[$i]) GUICtrlSetData($cList_Number, $aList_Number[$i]) Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEndAll clear?M23 Sodori 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Sodori Posted June 6, 2015 Author Share Posted June 6, 2015 Much thanks Melba23! How easy do you think it would be for a trigger event upon copying a single item (i.e. selecting a single variable and pressing CTRL+C, with said variable included with the trigger)? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 6, 2015 Moderators Share Posted June 6, 2015 Sodori,I would use a Accelerator key like this:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <WinAPI.au3> ; Array of values as strings Global $aList_String[8] = ["1", "2", "3", "12", "134", "14", "256", "8"] ; And sorted as strings _ArraySort($aList_String) ; Array of values as numbers Global $aList_Number[8] = [1, 2, 3, 12, 134, 14, 256, 8] ; And sorted as numbers _ArraySort($aList_Number) $hGUI = GUICreate("Test", 500, 500) ; Create lists without the sort style $cList_String = GUICtrlCreateList("", 10, 10, 230, 300, BitOr($WS_BORDER, $WS_VSCROLL)) $cList_Number = GUICtrlCreateList("", 260, 10, 230, 300, BitOr($WS_BORDER, $WS_VSCROLL)) ; Add items to the lists For $i = 0 To 7 GUICtrlSetData($cList_String, $aList_String[$i]) GUICtrlSetData($cList_Number, $aList_Number[$i]) Next $cDummy = GUICtrlCreateDummy() GUISetState() Local $aAccelKeys[1][2] = [["^c", $cDummy]] GUISetAccelerators($aAccelKeys) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cDummy Switch _WinAPI_GetFocus() Case GUICtrlGetHandle($cList_String) ConsoleWrite(GUICtrlRead($cList_String) & @CRLF) Case GUICtrlGetHandle($cList_Number) ConsoleWrite(GUICtrlRead($cList_Number) & @CRLF) EndSwitch EndSwitch WEndM23 Sodori 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Sodori Posted June 7, 2015 Author Share Posted June 7, 2015 Again, my deepest thanks! Now it's just that "send you a beer button" missing My GF will be stocked when she sees what I've done for her!! ^^ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 7, 2015 Moderators Share Posted June 7, 2015 Sodori,Glad I could help.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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