Paulie Posted May 4, 2006 Posted May 4, 2006 How could i make a script the hides desktop icons when run, I have a program with a progressbar and what i want is it to divide 100 by the number of destop icons and then when the progresbar hits that value hide the icon. and then at the end of the script, show them all again in the same places i want the script to hide icons in increments EXAMPLE: 10 destop icons 100/10=10 hide a ramdom destop icon when progress bar hits 10%,20%,30%,40%,50% etc.
Xenobiologist Posted May 4, 2006 Posted May 4, 2006 How could i make a script the hides desktop icons when run, I have a program with a progressbar and what i want is it to divide 100 by the number of destop icons and then when the progresbar hits that value hide the icon. and then at the end of the script, show them all again in the same placesi want the script to hide icons in incrementsEXAMPLE:10 destop icons100/10=10hide a ramdom destop icon when progress bar hits 10%,20%,30%,40%,50% etc.HI, just a thought. You could use a macro to get the path, where the icons are saved in and then you can set the attribute to HIDDEN. FileSetAttrib()So long,Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
Paulie Posted May 4, 2006 Author Posted May 4, 2006 You could use a macro to get the path,How exactly would i go about doing that?
cdkid Posted May 4, 2006 Posted May 4, 2006 Using @DeskTopDir and FileFindFirst/NextFile with a *.lnk filter. ~cdkid AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Valuater Posted May 4, 2006 Posted May 4, 2006 (edited) 1 Get the directory @Desktopdir 2 Get a list FileListtoarray 3 Set attributes FileSetAttrib 8) geez... i am getting slow... lol Edited May 4, 2006 by Valuater
Paulie Posted May 4, 2006 Author Posted May 4, 2006 1 Get the directory@Desktopdir2 Get a listFileListtoarray3 Set attributesFileSetAttrib8)geez... i am getting slow... lolI'm having trouble figuring out FileListToArray doesn't seem to be in the help file(unless im looking in the wrong place)could i maybe get a sample code :"> , i'm not to good with files in AutoIt
Valuater Posted May 4, 2006 Posted May 4, 2006 #Include <File.au3> #Include <Array.au3> $FileList=_FileListToArray(@DesktopDir) If (Not IsArray($FileList)) and (@Error=1) Then MsgBox (0,"","No Files\Folders Found.") Exit EndIf _ArrayDisplay($FileList,"$FileList") straight from beta help 8)
plastix Posted May 4, 2006 Posted May 4, 2006 Try this... took a little while, but working ok here. The biggest problem is dynamically refreshing the screen. Using EnvUpdate() works, but is slow. {F5} to desktop works here... an alternative is to flash up a transparent gui and remove it repeatedly... [these methods are commented out in RefreshDesktop() function] In addition to @DesktopDir, there may be 'All Users' desktop files in @DesktopCommonDir - so these are included. Finally, if your system is set to 'show' hidden files, then they won't actually vanish... so modify registry setting to hide hidden files (settings are restored on exit etc). Its a start...expandcollapse popupGlobal Const $GUI_EVENT_CLOSE = -3 Global Const $GUI_EVENT_MINIMIZE = -4 Global Const $GUI_EVENT_RESTORE = -5 Global Const $GUI_EVENT_MAXIMIZE = -6 Global Const $GUI_ENABLE = 64 Global Const $GUI_DISABLE = 128 Global Const $GUI_SHOW = 16 Global Const $GUI_HIDE = 32 Global Const $PBS_SMOOTH = 1 Global Const $SS_NOTIFY = 0x0100 Global Const $WS_GROUP = 0x00020000 Global Const $WS_VSCROLL = 0x00200000 Global Const $WS_BORDER = 0x00800000 Global Const $WS_POPUP = 0x80000000 Global Const $WS_DLGFRAME = 0x00400000 Global Const $WS_EX_TOPMOST = 0x00000008 #NoTrayIcon Opt("TrayMenuMode",1) Global $toggle,$ShowHide = 1,$progressgui,$progress_banner,$flash $hideitem = TrayCreateItem("Hide Desktop Icons") TrayCreateItem("") $aboutitem = TrayCreateItem("About") TrayCreateItem("") $exititem = TrayCreateItem("Exit") TraySetState() ;=============================================================================== $progressgui = GUICreate("Hide Desktop Icons Progress Banner",450,44,(@DesktopWidth-450)/2, (@DesktopHeight-44)/2,$WS_POPUP + $WS_DLGFRAME,$WS_EX_TOPMOST) GUISetBkColor(0xFFFBF0) $progress_banner = GUICtrlCreateProgress(20, 10, 410, 24,$PBS_SMOOTH) ;GUICtrlSetBkColor(-1, 0xFFFBF0) GUICtrlSetData($progress_banner,0) GUISetState(@SW_HIDE,$progressgui) ;=============================================================================== $flash = GUICreate("",@DesktopWidth,@DesktopHeight,0,0) $trans = GUICtrlCreatePic("",0,0,@DesktopWidth,@DesktopHeight) GUICtrlSetBkColor($trans,0x00000020) GUISetState(@SW_HIDE,$flash) ;=============================================================================== While 1 $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $hideitem If $ShowHide = 1 Then $ShowHide = 0 TrayItemSetText($hideitem,"Show Desktop Icons") HideIcons() Else $ShowHide = 1 TrayItemSetText($hideitem,"Hide Desktop Icons") ShowIcons() EndIf Case $msg = $aboutitem Msgbox(64,"About","Hello There") Case $msg = $exititem Exit EndSelect WEnd Exit Func HideIcons() RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced","HIDDEN","REG_DWORD","2") $userdesktopfiles = _FileListToArray(@DesktopDir) $commondesktopfiles = _FileListToArray(@DesktopCommonDir) $total_files = $userdesktopfiles[0] + $commondesktopfiles[0] GUISetState(@SW_SHOW,$progressgui) For $i = 1 To $userdesktopfiles[0] FileSetAttrib(@DesktopDir & "\" & $userdesktopfiles[$i], "+H", 1) GUICtrlSetData($progress_banner,($i / $total_files) * 100) RefreshDesktop() Sleep(200) Next For $i = 1 To $commondesktopfiles[0] FileSetAttrib(@DesktopCommonDir & "\" & $commondesktopfiles[$i], "+H", 1) GUICtrlSetData($progress_banner,($i + $userdesktopfiles[0] / $total_files) * 100) RefreshDesktop() Sleep(200) Next GUISetState(@SW_HIDE,$progressgui) EndFunc Func RefreshDesktop() ;GUISetState(@SW_SHOW,$flash) ;GUISetState(@SW_HIDE,$flash) ControlSend('Program Manager', '', '', '{F5}') ;EnvUpdate() EndFunc Func ShowIcons() FileSetAttrib(@DesktopDir & "\*.*", "-H", 1) FileSetAttrib(@DesktopCommonDir & "\*.*", "-H", 1) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced","HIDDEN","REG_DWORD",$toggle) EnvUpdate() EndFunc Func OnAutoItStart() $toggle = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced","HIDDEN") EndFunc Func OnAutoItExit() RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced","HIDDEN","REG_DWORD",$toggle) ShowIcons() EndFunc ;=============================================================================== ; ; Description: lists all files and folders in a specified path (Similar to using Dir with the /B Switch) ; Syntax: _FileListToArray($sPath, $sFilter = "*", $iFlag = 0) ; Parameter(s): $sPath = Path to generate filelist for ; $iFlag = determines weather to return file or folders or both ; $sFilter = The filter to use. Search the Autoit3 manual for the word "WildCards" For details ; $iFlag=0(Default) Return both files and folders ; $iFlag=1 Return files Only ; $iFlag=2 Return Folders Only ; ; Requirement(s): None ; Return Value(s): On Success - Returns an array containing the list of files and folders in the specified path ; On Failure - Returns an empty string "" if no files are found and sets @Error on errors ; @Error=1 Path not found or invalid ; @Error=2 Invalid $sFilter ; @Error=3 Invalid $iFlag ; ; Author(s): SolidSnake <MetalGearX91 at Hotmail dot com> ; Note(s): The array returned is one-dimensional and is made up as follows: ; $array[0] = Number of Files\Folders returned ; $array[1] = 1st File\Folder ; $array[2] = 2nd File\Folder ; $array[3] = 3rd File\Folder ; $array[n] = nth File\Folder ; ; Special Thanks to Helge and Layer for help with the $iFlag update ;=============================================================================== Func _FileListToArray($sPath, $sFilter = "*", $iFlag = 0) Local $hSearch, $sFile, $asFileList[1] If Not FileExists($sPath) Then SetError(1) Return "" EndIf If (StringInStr($sFilter, "\")) or (StringInStr($sFilter, "/")) or (StringInStr($sFilter, ":")) or (StringInStr($sFilter, ">")) or (StringInStr($sFilter, "<")) or (StringInStr($sFilter, "|")) or (StringStripWS($sFilter, 8) = "") Then SetError(2) Return 0 EndIf If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then SetError(3) Return "" EndIf $asFileList[0] = 0 $hSearch = FileFindFirstFile($sPath & "\" & $sFilter) If $hSearch = -1 Then SetError(0) Return 0 EndIf While 1 $sFile = FileFindNextFile($hSearch) If @error Then ExitLoop If $iFlag = 1 Then If StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") <> 0 Then ContinueLoop EndIf If $iFlag = 2 Then If StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") = 0 Then ContinueLoop EndIf ReDim $asFileList[UBound($asFileList) + 1] $asFileList[0] = $asFileList[0] + 1 $asFileList[UBound($asFileList) - 1] = $sFile WEnd FileClose($hSearch) SetError(0) If $asFileList[0] = 0 Then Return "" Return $asFileList EndFunc ;==>_FileListToArray
Paulie Posted May 5, 2006 Author Posted May 5, 2006 Plastix that code is a monster. But it is still incredidbly cool I was wondering though is there a way to incorperate it into this script s it works without the GUI progressbar? Right now it just ides all the icons right in the beginning, but i'd rather it hide one by one expandcollapse popupopt("WinTitleMatchMode",4) WinMinimizeAll() WinSetState("Classname=Shell_TrayWnd", "", @SW_HIDE) WinSetState("Program Manager", "", @SW_HIDE) ;******************************************* Beep (200,2000) $answer1 = Msgbox (48, "Crital Error", "Error #1143396- A critical error has occured. Wiping physical memory") If $answer1=1 Then Blockinput(1) ProgressOn("Physical Memory Dump","Dumping Physical Memory...","Dumping...") Local $x = 0, $Drive[5] = ['', 'C:\', 'D:\', 'E:\', 'F:\'], $Percent[4] = ['', '40', '65', '85'], $Finished[5] = ['', 0, 0, 0, 0] Local $Store = @CRLF & 'Current Drive: ' & $Drive[1] For $i = 1 to 100 $x = $x + Random(1, 7, 1) Sleep(Random(100, 1500)) If $i + $x >= 100 Then ExitLoop ProgressSet($i + $x, ($i + $x) & "%" & $Store) If $i + $x <= $Percent[2] And $i + $x > $Percent[1] And $Finished[2] = 0 Then $Store = @CRLF & 'Current Drive: ' & $Drive[2] $Finished[2] = 1 ElseIf $i + $x <= $Percent[3] And $i + $x > $Percent[2] And $Finished[3] = 0 Then $Store = @CRLF & 'Current Drive: ' & $Drive[3] $Finished[3] = 1 ElseIf $i + $x > $Percent[3] And $Finished[4] = 0 Then $Store = @CRLF & 'Current Drive: ' & $Drive[4] $Finished[4] = 1 EndIf Next ProgressSet('100%', 'Memory Dump Completed', 'Finished') Sleep(4000) ProgressOff() Blockinput(0) ProgressSet(100 , "Done", "Complete") sleep(500) ProgressOff() MsgBox(0, "Dump Complete", "Dump Completed, Files erased") Sleep(1000) WinMinimizeAllUndo() WinSetState("Classname=Shell_TrayWnd", "", @SW_SHOW) WinSetState("Program Manager", "", @SW_SHOW) endIf Thanks for the time you spent on my question
Bert Posted May 5, 2006 Posted May 5, 2006 (edited) Dumb question: Why do you need to do this? Edited May 5, 2006 by vollyman The Vollatran project My blog: http://www.vollysinterestingshit.com/
Paulie Posted May 5, 2006 Author Posted May 5, 2006 Dumb question: Why do you need to do this? Check the script in the previous post made by me, Its a fake joke program that acts like its dumpin the physical memmory on you computer, and runs a progress bar and everything, for someone new to the computer, this would be pretty convincing, but to make it more convincing, i want it to pick off desktop icons on by one to looke like files are being deleted. Question to others, why doesn't this script work? #include <file.au3> #include <Array.au3> Hotkeyset("{ESC}", "Terminate") Dim $i=1 $delay = Random(300, 1000) $array1 = _FileListToArray(@DesktopDir) If @Error=1 then Msgbox(0, "No Files","No Files/Folders Found.") Exit Else Do FileSetAttrib($array1[$i], "+H") Sleep($delay) $i = $i+1 Sleep($delay) Until $i = $array1[0] EndIf Terminate() Func Terminate() Do FileSetAttrib($array1[$i], "-H") Sleep($delay) $i = $i+1 Sleep($delay) Until $i = $array1[0] Exit 0 EndFunc
photonbuddy Posted June 17, 2006 Posted June 17, 2006 Try this... took a little while, but working ok here. The biggest problem is dynamically refreshing the screen. Using EnvUpdate() works, but is slow. {F5} to desktop works here... an alternative is to flash up a transparent gui and remove it repeatedly... [these methods are commented out in RefreshDesktop() function] I am using your code, and it works great except for 1 annoying problem When I re-enable the icons, Windows performs an 'Arrange All' by name, moving my icons from where they have been placed. Any ideas on how to fix this problem?
Zedna Posted June 17, 2006 Posted June 17, 2006 (edited) I am using your code, and it works great except for 1 annoying problem When I re-enable the icons, Windows performs an 'Arrange All' by name, moving my icons from where they have been placed. Any ideas on how to fix this problem? I'm using WinTidy for it - something like this: If @DesktopWidth = 800 Then $pid = Run("c:\Program Files\WinTidy\WinTidy.exe 800 /Q" ,'', @SW_HIDE) While ProcessExists($pid) If WinExists("WinTidy","The restored") Then ControlClick("WinTidy","The restored","Button1") Sleep(100) WEnd EndIf Edited June 17, 2006 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
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