MadBoy Posted February 13, 2008 Share Posted February 13, 2008 Hello, I was wondering if anyone got an idea how to do exactly same thing as Right clicking on desktop and choosing: - Arrange Icons by Name, Size, Type, Modified. I've seen the IconMap's and couple of other threads on the forum but they have a bit diffrent purpose. So if anyone got an idea how to bite this so i wouldn't have to redevelop wheel i would be greatfull. I know i can simulate mouse movements but it's not what i am looking for Non movement related script. I've done some testing and it doesn't look that good So lemme know if you have beter ideas #include <GuiConstantsEx.au3> #include <GuiListView.au3> _SortIconsOnTheDesktop() Func _SortIconsOnTheDesktop() Local $hWnd_LV = ControlGetHandle("Program Manager", "", "SysListView321") Local $user_desktop_icons_count = _GUICtrlListView_GetItemCount($hWnd_LV) Local $array[$user_desktop_icons_count][3] ;_GUICtrlListView_Arrange ($hWnd_LV,0) For $a = 0 to $user_desktop_icons_count - 1 $sIconText = _GUICtrlListView_GetItemText($hWnd_LV, $a) ; _ListView_GetItemText( $hWnd_LV, $nIdx ) $aPos = _GUICtrlListView_GetItemPosition($hWnd_LV, $a);_ListView_GetItemPosition( $hWnd_LV, $nIdx ) ;IniWrite( $sINI, "Icons", $sIconText, $aPos[0] & ";" & $aPos[1] ) $array[$a][0] = $sIconText $array[$a][1] = $aPos[0] $array[$a][2] = $aPos[1] Next _ArrayDisplay($array) EndFunc ;==>_SortIconsOnTheDesktop My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
Siao Posted February 14, 2008 Share Posted February 14, 2008 Simple way, but not generic at all (as the IDs aren't likely to be the same for every Windows version): Const $WM_COMMAND = 0x0111 ;;"Arrange Icons By" popup menu IDs for WinXP: $iByName = 30210 $iBySize = 30211 $iByType = 30212 $iByModified = 30213 ;;example $hDesk = WinGetHandle('[CLASS:Progman]') DllCall('user32.dll','int','SendMessage', 'hwnd',$hDesk, 'uint',$WM_COMMAND, 'wparam',$iByModified, 'lparam',0) Also you could sort the actual listview - not surprisingly it has 4 columns. Get header handle, get column item rectangle and ControlClick to sort it. Problem is you'd have to switch to Details view for this to work... Or you could write a function to sort it. "be smart, drink your wine" Link to comment Share on other sites More sharing options...
MadBoy Posted February 14, 2008 Author Share Posted February 14, 2008 Thanks Siao, as always correct. I'm not worried much about older systems. The only system i would like to support more is probably Windows Vista. Is there any place to get those numbers for other systems? Const $WM_COMMAND = 0x0111 _SortIconsOnTheDesktop() Func _SortIconsOnTheDesktop($sort_by = 1) ; 1 = Name, 2 = Size, 3 = Type, 4 = Modified (works for WinXP only) Local $hDesk, $sorting If @OSVersion = "WIN_XP" Then Local $iByName = 30210 Local $iBySize = 30211 Local $iByType = 30212 Local $iByModified = 30213 ElseIf @OSVersion = "WIN_VISTA" Then MsgBox(0, "Not supported", "This system is not yet supported by this program.") Return SetError(1, 0, -1) Else MsgBox(0, "Not supported", "This system is not supported by this program.") Return SetError(1, 0, -1) EndIf Select Case $sort_by = 1 $sorting = $iByName Case $sort_by = 2 $sorting = $iBySize Case $sort_by = 3 $sorting = $iByType Case $sort_by = 4 $sorting = $iByModified Case Else MsgBox(0, "Wrong Value", "Wrong option.") Return SetError(1, 0, -2) EndSelect $hDesk = WinGetHandle('[CLASS:Progman]') DllCall('user32.dll', 'int', 'SendMessage', 'hwnd', $hDesk, 'uint', $WM_COMMAND, 'wparam', $sorting, 'lparam', 0) EndFunc ;==>_SortIconsOnTheDesktop My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
MadBoy Posted February 14, 2008 Author Share Posted February 14, 2008 Also you could sort the actual listview - not surprisingly it has 4 columns.Get header handle, get column item rectangle and ControlClick to sort it. Problem is you'd have to switch to Details view for this to work...Or you could write a function to sort it.I was thinking about that. But i think with sorting of ListView i would move around My Documents, My Computer, My Network Places and Recycle Bin (by Name) to diffrent places then the way they are Sorted when using the method you gave me in your post. Since it always puts the 4 icons mentioned in their "correct" positions My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
yehia Posted February 15, 2009 Share Posted February 15, 2009 how did u got the popup menu IDs? ;;"Arrange Icons By" popup menu IDs for WinXP: $iByName = 30210 $iBySize = 30211 $iByType = 30212 $iByModified = 30213 cause i wanna get the IDs for show in groups and view popup menu thanks My Scripts:IE New UDFsElastic images moving under mouse (with a happy valentine's example)_FileRemoveLine 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