DonationCoder.com Forum

DonationCoder.com Software => Coding Snacks => Finished Programs => Topic started by: guerillablood on March 22, 2014, 07:43 PM

Title: DONE: AutoHotKey solution for Desktop ListView
Post by: guerillablood on March 22, 2014, 07:43 PM
Hi all!

I'm looking for an a way to emulate the function of this freeware (http://jimcofer.com/personal/2007/07/05/download-deskview/).

Preferably something that would run at the start of a script and could be toggled on and off. It'd also be great if I could integrate it into my own AHK script, if possible. I know there is already an AHK script called DesktopHomes (http://www.autohotkey.com/board/topic/85868-desktophomes-change-desktop-locations-and-icons/) that does this, even though I plundered through the source, I couldn't find the bit of code for the function that I want.

Thanks in advance!
Title: Re: DONE: AutoHotKey solution for Desktop ListView
Post by: skwire on March 23, 2014, 01:11 PM
Preferably something that would run at the start of a script and could be toggled on and off. It'd also be great if I could integrate it into my own AHK script, if possible.
-guerillablood (March 22, 2014, 07:43 PM)

Here you go.

Code: Autohotkey [Select]
  1. LV_VIEW_ICON      := 0 ; Default
  2. LV_VIEW_DETAILS   := 1 ; Flat font and columns don't work right.
  3. LV_VIEW_SMALLICON := 2 ; Correct font, columns are okay.
  4. LV_VIEW_LIST      := 3 ; Flat font and columns are too far apart.
  5. LV_VIEW_TILE      := 4 ; Flat font, columns are okay, and there is extra text detail.
  6. LVM_SETVIEW       := 0x108E
  7. LVM_GETVIEW       := 0x108F
  8.  
  9. #1::
  10. {
  11.     If ( Toggle ) ; LV_VIEW_SMALLICON & LV_VIEW_TILE work the best.
  12.     {
  13.         ControlGet, myDesktopWindow, HWND,, SysListView321, ahk_class Progman
  14.         SendMessage, % LVM_SETVIEW, % LV_VIEW_SMALLICON, 0, , % "ahk_id " . myDesktopWindow
  15.     }
  16.     Else ; Set back to default.
  17.     {
  18.         ControlGet, myDesktopWindow, HWND,, SysListView321, ahk_class Progman
  19.         SendMessage, % LVM_SETVIEW, % LV_VIEW_ICON, 0, , % "ahk_id " . myDesktopWindow
  20.     }
  21.     Toggle := !Toggle
  22. }
  23. Return

Here are some screenshots showing the different modes under a Windows 8 VM:

LV_VIEW_ICON
[ You are not allowed to view attachments ]

LV_VIEW_DETAILS
[ You are not allowed to view attachments ]

LV_VIEW_SMALLICON
[ You are not allowed to view attachments ]

LV_VIEW_LIST
[ You are not allowed to view attachments ]

LV_VIEW_TILE
[ You are not allowed to view attachments ]
Title: Re: DONE: AutoHotKey solution for Desktop ListView
Post by: IainB on March 23, 2014, 04:04 PM
That's rather nifty.     :up:
Title: Re: DONE: AutoHotKey solution for Desktop ListView
Post by: guerillablood on March 23, 2014, 11:50 PM
Thank you so much Skwire! Your work never ceases to impress. It's a shame that LV_VIEW_DETAILS doesn't function properly, but LV_VIEW_SMALLICON functions perfectly, just as I wanted!

Skwire, I don't suppose you could provide an efficient method of having a scheme run at the start of the script and have the hotkey toggle be reversed so it reverts to the default setting, could you? Or just syntax to get the list view to execute with a script?
Title: Re: DONE: AutoHotKey solution for Desktop ListView
Post by: skwire on March 24, 2014, 03:29 PM
Thank you so much Skwire! Your work never ceases to impress. It's a shame that LV_VIEW_DETAILS doesn't function properly, but LV_VIEW_SMALLICON functions perfectly, just as I wanted!
-guerillablood (March 23, 2014, 11:50 PM)

Actually, when you think about it, LV_VIEW_DETAILS does function properly.  That is, in details mode in Windows Explorer, you only ever get one column.

Skwire, I don't suppose you could provide an efficient method of having a scheme run at the start of the script and have the hotkey toggle be reversed so it reverts to the default setting, could you? Or just syntax to get the list view to execute with a script?
-guerillablood (March 23, 2014, 11:50 PM)

Add the following at the top of your script before the first "Return":

Code: Autohotkey [Select]
  1. DesktopToggle := True
  2. ToggleDesktopView( DesktopToggle )

Then add the following hotkey and function somewhere else in the script:

Code: Autohotkey [Select]
  1. #1::
  2. {
  3.     DesktopToggle := !DesktopToggle
  4.     ToggleDesktopView( DesktopToggle )
  5. }
  6. Return
  7.  
  8. ToggleDesktopView( _Toggle )
  9. {
  10.     LV_VIEW_ICON      := 0 ; Default
  11.     LV_VIEW_DETAILS   := 1 ; Flat font and columns don't work right.
  12.     LV_VIEW_SMALLICON := 2 ; Correct font, columns are okay.
  13.     LV_VIEW_LIST      := 3 ; Flat font and columns are too far apart.
  14.     LV_VIEW_TILE      := 4 ; Flat font, columns are okay, and there is extra text detail.
  15.     LVM_SETVIEW       := 0x108E
  16.     LVM_GETVIEW       := 0x108F
  17.     If ( _Toggle ) ; LV_VIEW_SMALLICON & LV_VIEW_TILE work the best.
  18.     {
  19.         ControlGet, myDesktopWindow, HWND,, SysListView321, ahk_class Progman
  20.         SendMessage, % LVM_SETVIEW, % LV_VIEW_SMALLICON, 0, , % "ahk_id " . myDesktopWindow
  21.     }
  22.     Else ; Set back to default.
  23.     {
  24.         ControlGet, myDesktopWindow, HWND,, SysListView321, ahk_class Progman
  25.         SendMessage, % LVM_SETVIEW, % LV_VIEW_ICON, 0, , % "ahk_id " . myDesktopWindow
  26.     }
  27. }
Title: Re: DONE: AutoHotKey solution for Desktop ListView
Post by: guerillablood on March 25, 2014, 02:14 AM
Absolutely perfect! Thank you so much Skwire! It assimilates right in with my existing master script.

Unrelated, but interestingly enough the first version would not play nicely with my alt dragging and window shading code in some manner depending on it's placement in the script. Placing it before or between either of those scripts would break the shading and cause the alt dragging to jump erratically. Placing it after them would prevent the listview from launching. Not quite sure why though.

At any rate, the script is functioning just as I want. The autostart toggle bit, along with it's initial purpose, fixed that entirely by me just splitting the autostart toggle up from the initial script around my other functions. No hiccups whatsoever.

Actually, when you think about it, LV_VIEW_DETAILS does function properly.  That is, in details mode in Windows Explorer, you only ever get one column.

Very true, but that doesn't *really* work in an environment where you don't have a scroll bar, unless you have a large vertical area or very few files on your desktop.  ;)
Title: Re: DONE: AutoHotKey solution for Desktop ListView
Post by: skwire on March 25, 2014, 02:38 PM
Absolutely perfect! Thank you so much Skwire! It assimilates right in with my existing master script.
-guerillablood (March 25, 2014, 02:14 AM)


Right on.  I'm glad it's working for you.   :Thmbsup:

Very true, but that doesn't *really* work in an environment where you don't have a scroll bar, unless you have a large vertical area or very few files on your desktop.  ;)
-guerillablood (March 25, 2014, 02:14 AM)

Agreed.   :)

I'll move this to the Finished section.
Title: Re: DONE: AutoHotKey solution for Desktop ListView
Post by: RonJon on May 25, 2014, 01:13 PM
Would it be very difficult to make this into a windows program, not using autohotkey?

I would love to have the details view on my windows 7 desktop.
Title: Re: DONE: AutoHotKey solution for Desktop ListView
Post by: skwire on May 25, 2014, 03:34 PM
I think you're asking if I can compile this into an executable (a .exe file), right?  If so, sure, I can do that.
Title: Re: DONE: AutoHotKey solution for Desktop ListView
Post by: RonJon on May 25, 2014, 04:16 PM
Yes, that is exactly what I am requesting.
Title: Re: DONE: AutoHotKey solution for Desktop ListView
Post by: skwire on May 26, 2014, 07:54 PM
Yes, that is exactly what I am requesting.

I incorporated the functionality shown in this thread with another tool I wrote in this thread (https://www.donationcoder.com/forum/index.php?topic=37723.0).  Perhaps that will work for you?