Sign in to follow this  
Followers 0
IanN1990

[Solved] Hide Desktop Icons/Folders/Files Windows 7

22 posts in this topic

#1 ·  Posted (edited)

Heya,

I really dislike stuff on my desktop as i enjoy looking at the impressive art-work others create but alas sometimes its needed. So i was wondering is there any way to hide desktop items but show them when the desktop is clicked?

I did a bit of forum searching but couldn't find anything that would work for windows  7.

**Edit Right-Click Desktop --> View --> Show Desktop Icons shows/hides them, if anyone can think of a way of emulating this function or sending the variables to windows to run it??

**Edit My OS Windows 7 Professional N (64 Bit)

AnswerA - JoHanatCent - Hides all desktop related things

ControlHide("Program Manager", "", "[CLASSNN:SHELLDLL_DefView1]")
Sleep(5000)
ControlShow("Program Manager", "", "[CLASSNN:SHELLDLL_DefView1]")

AnswerB - JohnOne - Hides only Icons/Folders/Files

_ToggleDesktopIcons()
Func _ToggleDesktopIcons()
Local $hwnd = WinGetHandle("Program Manager")
Local $sClass = "[CLASS:SysListView32; INSTANCE:1]"
$iVis = ControlCommand($hwnd, "", $sClass, "IsVisible", "")
If Not $iVis Then
  ControlShow($hwnd, "", $sClass)
Else
  ControlHide($hwnd, "", $sClass)
EndIf
EndFunc   ;==>_ToggleDesktopIcons
Edited by IanN1990

Share this post


Link to post
Share on other sites



I dont have XP so i would have no way of testing if it does or did work :D

Share this post


Link to post
Share on other sites

IanN1990,

Take a look at Fences. I have tried it and found it works well - and it is free for personal use. :D

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

I guess you could use RegFromApp and attach it to explorer, then hide and then unhide the icons to see whether it is writing the settings to the registry. If so, then you could set your program to write the appropreate value to the registry, and then re-start explorer. I used this for a program I wrote earlier this year for the techies at school to hand out to the students, for getting out of high contrast because they couldnt change their theme. It pretty quick and easy to do, so good luck.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Good news and Bad:

The Good news is it can be done.

The Bad news is I cannot remember how I did it.

The Story:

I was having a go, and nothing on the desktop was changing, I tried a fair few things and then gave up.

So then when I hit the corner button to bring desktop to the front all the icons disappeared.

The button was actually toggling the icons on and off and I was delighted, but then I started

farting around with the code to reverse it as it seemed to be permanent.

Because of that I tried a reboot to see if it was truly permanent, and it was not

but neither did the code I had left. I've tried to recreate it but it's mocking me.

The Info I was working off was an article on stackoverflow, in C#

Here is what I can remember from my procedure, it started off something like this...

#include <SendMessage.au3>
$hwnd = WinGetHandle("Program Manager")
$WM_COMMAND = 0x111
;$TOGGLEICONS  = DllStructCreate("INT_PTR")
$TOGGLEICONS  = DllStructCreate("ptr")
If @error Then
MsgBox(0, 0, 1)
Exit
EndIf
DllStructSetData($TOGGLEICONS,1,0x7402)
If @error Then
MsgBox(0, 0, 2)
Exit
EndIf
_SendMessage($hwnd,$WM_COMMAND,DllStructGetPtr($TOGGLEICONS),0)

and ended up something like this...

#include <SendMessage.au3>
_Main()
Func _Main()
    Local Const $Off = 0, $On = 1
    Opt("WinTitleMatchMode", 4)
    $hwnd = WinGetHandle('classname=Progman')
    _ToggleIcons($hWnd, $Off)
    ;Sleep ( 5000 )
    ;_ToggleIcons($hWnd, $On)
EndFunc
Func _ToggleIcons($hwnd, $OnOff)
    Local Const $WM_SYSCOMMAND = 0x111
    Local Const $toggleDesktopCommand  = 0x7402
    $SendMessage = _SendMessage($hWnd, $WM_SYSCOMMAND, $toggleDesktopCommand, $OnOff)
ConsoleWrite($SendMessage & @LF)
    If @error Then
        MsgBox(0,"_ToggleIcons", "_SendMessage Error: " & @error)
        Exit
    EndIf
EndFunc

With a number of different attempts between

Along the way I also tried the registry key HKCUsoftwaremicrosftwindowscurrentversionpolicies

adding the key "Explorer" and a dword value of 1 named "NoDesktop"

Sorry I never twigged when the code had worked, but maybe you can get something from my misery.

EDIT:

The reg key works, in that it disables desktop, hiding all icons, but you need to reboot.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Does this not work?

ControlHide("Program Manager", "", "[CLASSNN:SHELLDLL_DefView1]")
Sleep(5000)
ControlShow("Program Manager", "", "[CLASSNN:SHELLDLL_DefView1]")

Share this post


Link to post
Share on other sites

But it totally disable the shell.

Here's a modification.

_ToggleDesktopIcons(0)

Func _ToggleDesktopIcons($State)
If $State Then
  ControlShow("Program Manager", "", "[CLASS:SysListView32; INSTANCE:1]")
Else
  ControlHide("Program Manager", "", "[CLASS:SysListView32; INSTANCE:1]")
EndIf
EndFunc

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

So in the end, can be something like this

_ToggleDesktopIcons()

Func _ToggleDesktopIcons()
Local $hwnd = WinGetHandle("Program Manager")
Local $sClass = "[CLASS:SysListView32; INSTANCE:1]"
$iVis = ControlCommand($hwnd, "", $sClass, "IsVisible", "")
If Not $iVis Then
  ControlShow($hwnd, "", $sClass)
Else
  ControlHide($hwnd, "", $sClass)
EndIf
EndFunc   ;==>_ToggleDesktopIcons

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Sorry for not replying sooner as i was a bit busy with uni, thanks JoHantaCent for the starting idea and to JohnOne for improving. Your code works very well and i think should be added to the example scripts as it could help other people :D

Though i only had a few minutes to work on it, i went for

while 1
sleep(500)
if winactive("[Class:Progman]") Then
ControlShow("Program Manager", "", "[CLASS:SysListView32; INSTANCE:1]")
Else
ControlHide("Program Manager", "", "[CLASS:SysListView32; INSTANCE:1]")
EndIf
WEnd

So the desktop icons are hidden, until i click the desktop and then they show, which works very nicely. Thanks to everyone that took part in this topic :oops:

Edited by IanN1990

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Though i hate reopening topics there is a small problem :)

I found the script completely stops working if i was to change my desktop wallpaper. After using the Info Tool i find Program Manager is replaced by WorkerW, any ideas on how i could hide/show this to remove/show the desktop icons ?

Info

>>>> Window <<<<

Title:

Class: WorkerW

Position: -1920, 0

Size: 5760, 1080

Style: 0x96000000

ExStyle: 0x00000080

Handle: 0x000305AC

>>>> Control <<<<

Class: SysListView32

Instance: 1

ClassnameNN: SysListView321

Name:

Advanced (Class): [CLASS:SysListView32; INSTANCE:1]

ID: 1

Text: FolderView

Position: 0, 0

Size: 5760, 1080

ControlClick Coords: 2321, 116

Style: 0x56003A40

ExStyle: 0x00000000

Handle: 0x00010118

>>>> Mouse <<<<

Position: 401, 116

Cursor ID: 0

Color: 0x081005

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<

FolderView

>>>> Hidden Text <<<<

Edited by IanN1990

Share this post


Link to post
Share on other sites

IanN1990,

Take a look at Fences. I have tried it and found it works well - and it is free for personal use. :)

M23

I use this too since I use Win7 and is really simple and nice!

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

If it turns that, that becomes the only way this idea can be put then i would look into it but i prefer finding coding solutions rather then using third-party software. Otherwise i would end up with hundreds of .exes rather then one coded exe i can understand and can tinker with :)

For most reasons the code posted above does work, and does allow changing of wallpapers "If u right click a picture and click set a wallpaper", but for some reason if u change a wallpaper via Right click desktop --> Personalize then it changes the desktop to the WorkerW which the code cant show/hide and thus the problem happens ;)

Edited by IanN1990

Share this post


Link to post
Share on other sites

I just changed my desktop background via right click personalize and it remains program manager, with the code still working fine.

Please explain how you are getting this workerW (which sounds like a different thrad name) exactly fron the personalize menu.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

I right click the desktop, click personalize, click "my theme(1)" which is a unsaved theme, then click the bottom "desktop background" which then shows available desktop backgrounds "from my picture location", i click a picture "it previews the desktop" and then i save.

The desktop is now on WorkerW rather then Program Manager

I have Windows 7 Proffesional N ( 64 Bit )

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

Well my whole code is over 700 lines ;) but the code that focuses on the desktop is here

;HideDesktop
if WinExists("Personalization") Then
ControlShow("Program Manager", "", "[CLASS:SysListView32; INSTANCE:1]")
Else
if winactive("[Class:Progman]") Then
$hide=0
$loop = 0
ControlShow("Program Manager", "", "[CLASS:SysListView32; INSTANCE:1]")
$pos1 = MouseGetPos()
$loop1 = $loop1 + $num
if $loop1 = 15 Then
$loop1 = 0
sleep(500)
$pos2 = MouseGetPos()
if $pos1[0] = $pos2[0] Then
if $pos1[1] = $pos2[1] Then
WinActivate("Friends")
ControlHide("Program Manager", "", "[CLASS:SysListView32; INSTANCE:1]")
EndIf
EndIf
EndIf
Else
if $hide=0 then
$loop = $loop + $num
if $loop = 10 Then
$hide=1
ControlHide("Program Manager", "", "[CLASS:SysListView32; INSTANCE:1]")
EndIf
EndIf
EndIf
EndIf

Also i have rebooted, "not running my script at all" doing the same right-click desktop and the workerW still appears

If it turns out to be some weird bug with my system i made this temp patch. Checks to see if the preview window is opened "which is causing the problem", closes it and opens up the folder from which i can set desktop that way. Not perfect perhaps but still allows for the so the original code provided to work without a problerm :)

if WinExists("Desktop Background") Then
WinClose("Desktop Background")
ShellExecuteWait("D:Pictures01¦ Wallpapers & Display PicturesTri-Screen Wallpapers")
WinSetTrans("Tri-Screen Wallpapers", "", 0)
sleep(100)
WinSetTrans("Tri-Screen Wallpapers", "", 0)
WinMove("Tri-Screen Wallpapers", "", 0, 0)
WinSetState("Tri-Screen Wallpapers", "", @SW_MAXIMIZE)
WinSetTrans("Tri-Screen Wallpapers", "", 255)
EndIf
Edited by IanN1990

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

if i run the code from post #10 it hides the stuff on the desktop. Running the code again shows the stuff, but if i was to change the wallpaper via right-clicking the desktop. The code no longer works

Edited by IanN1990

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0