AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Toggle Visibility of Desktop Icons by DoubleClicking Desktop

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
EricCartman



Joined: 13 Oct 2008
Posts: 60
Location: South Park, Colorado

PostPosted: Fri Feb 27, 2009 1:48 pm    Post subject: Toggle Visibility of Desktop Icons by DoubleClicking Desktop Reply with quote

Overall, I found the Stardock app Fences to be a little more trouble than it is worth. It did, however, have one feature that I liked: double clicking the desktop would toggle the visibility of the desktop Icons. The following code mimics that feature.

Code:
#IfWinActive, ahk_class Progman
~LButton::
   KeyWait, LButton               ; Thank you, Lexikos.
   KeyWait, LButton, D T0.2      ; http://www.autohotkey.com/forum/viewtopic.php?t=25485
   If ErrorLevel
      Return
   Else
      {
         ControlGet, hwnd, Hwnd,, SysListView321, ahk_class Progman
         ToggleVisibility(hwnd)
      }
Return

ToggleVisibility(hwnd)
{
If DllCall("IsWindowVisible", UInt,hwnd)
   WinHide, ahk_id %hwnd%
Else
   WinShow, ahk_id %hwnd%
Return
}


One note is that this code will hide your desktop icons when you launch an app by double clicking a desktop icon. Fences does not do this. At first, I was trying to think of how to prevent this from happening, but I then decided that 99 times out of 100, I'd just be hiding the icons after I launched something anyway.
Back to top
View user's profile Send private message
lazygeek



Joined: 08 Feb 2009
Posts: 17

PostPosted: Fri Feb 27, 2009 5:51 pm    Post subject: Reply with quote

You can fix the hide-on-launch-app issue by checking if any icon is selected before performing the show/hide.
See SKAN's code at http://www.autohotkey.com/forum/viewtopic.php?t=41388
Back to top
View user's profile Send private message
EricCartman



Joined: 13 Oct 2008
Posts: 60
Location: South Park, Colorado

PostPosted: Fri Feb 27, 2009 7:12 pm    Post subject: Reply with quote

lazygeek wrote:
See SKAN's code at http://www.autohotkey.com/forum/viewtopic.php?t=41388


Sweet. Awesome. Glad to see that I re-invented the wheel.
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 7187

PostPosted: Fri Mar 06, 2009 9:27 pm    Post subject: Reply with quote

Using #InWinactive is better, only that it did not work for me when I tried.
I think I have isolated the problem to Zune Desktop Theme which activates a WorkerW class window when show desktop is done..

I have worked around it:

Code:
#IfWinActive, ahk_class WorkerW   ; workaround for
~LButton::Send !{Esc}{LButton 1}  ; Zune Desktop Theme
#IfWinActive                      ; http://en.wikipedia.org/wiki/Zune_desktop_theme

#IfWinActive, ahk_class Progman
~LButton Up::
 If ! ( A_PriorHotKey=A_ThisHotKey && A_TimeSincePriorHotkey<400 )
  Return
 ControlGet,Vis,Visible,,SysListView321,ahk_class Progman
 ControlGet,Selected,List,Selected,SysListView321,ahk_class Progman
 IfNotEqual,Selected,, Return
 IfEqual,cHwnd,,ControlGet, chwnd, Hwnd,, SysListView321,ahk_class Progman
 DllCall( "ShowWindow", UInt,cHwnd, UInt, Vis ? 0 : 5 )
Return
#IfWinActive

_________________
Suresh Kumar A N
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group