Jump to content

desktop icons


ashley
 Share

Recommended Posts

If you don't need to do this every time the script runs you could:

1. Take a screenshot of your desktop and crop out any extra crap.

2. Embed this picture in a gui background

3. Place invisible buttons over each icon

Bam! Fake desktop.

Link to comment
Share on other sites

Something like this:

#include <GuiConstants.au3>
#include <A3LListView.au3>
Opt("GuiOnEventMode", 1)
Opt("RunErrorsFatal", 0)

$Gui = GuiCreate("List Desktop Icons Demo", @DesktopWidth, @DesktopHeight, 0, 0, -1, $WS_EX_TOPMOST)
GUISetOnEvent(-3, "Quit")

Global $hWnd_LV = ControlGetHandle("[CLASS:Progman]", "", "SysListView321")
Global $Buttons_IDs_Arr[1][2]

For $i = 0 To _ListView_GetItemCount($hWnd_LV) - 1
    $sIconText = _ListView_GetItemText($hWnd_LV, $i)
    $aPos = _ListView_GetItemPosition($hWnd_LV, $i)
    
    ReDim $Buttons_IDs_Arr[$i+2][2]
    $Buttons_IDs_Arr[$i+1][0] = GUICtrlCreateButton($sIconText, $aPos[0], $aPos[1], 32, 32, $BS_ICON)
    GUICtrlSetOnEvent(-1, "IconsEvent")
    GUICtrlSetTip(-1, $sIconText)
    
    $CurrentFile = GetFullFilePath(@DesktopDir, $sIconText)
    $Buttons_IDs_Arr[$i+1][1] = $CurrentFile
    
    If Not @error Then
        $IconArr = _GetFileIcon($CurrentFile)
        If Not @error And FileExists($IconArr[1]) Then
            GUICtrlSetImage(-1, $IconArr[1], $IconArr[2], 0)
        Else
            GUICtrlSetPos(-1, $aPos[0], $aPos[1], 40, 30)
            GUICtrlSetData(-1, StringLeft($sIconText, 5) & "..")
        EndIf
    Else
        GUICtrlSetPos(-1, $aPos[0], $aPos[1], 40, 30)
        GUICtrlSetData(-1, StringLeft($sIconText, 5) & "..")
    EndIf
Next

GUISetState()

While 1
    Sleep(100)
WEnd

Func IconsEvent()
    For $i = 1 To UBound($Buttons_IDs_Arr)-1
        If $Buttons_IDs_Arr[$i][0] = @GUI_CtrlId Then
            If StringRight($Buttons_IDs_Arr[$i][1], 3) = "lnk" Then
                $ShortcutInfoArr = FileGetShortcut($Buttons_IDs_Arr[$i][1])
                If IsArray($ShortcutInfoArr) Then ShellExecute($ShortcutInfoArr[0], "", @DesktopDir)
            Else
                ShellExecute($Buttons_IDs_Arr[$i][1], "", @DesktopDir)
            EndIf
            WinSetState($Gui, "", @SW_MINIMIZE)
            Return
        EndIf
    Next
EndFunc

Func GetFullFilePath($sPath, $sPartFile)
    Local $Search = FileFindFirstFile($sPath & "\" & $sPartFile & ".*")
    If $Search = -1 Then Return SetError(1, 0, $sPartFile)
    
    Local $NextFile = FileFindNextFile($Search)
    FileClose($Search)
    Return $sPath & "\" & $NextFile
EndFunc

Func _GetFileIcon($szFile)
    Local $Old_Opt_EES = Opt("ExpandEnvStrings", 1)
    Local $szRegDefault = "", $szDefIcon = "", $szExt, $szIconFile, $nIcon=0
    Local $RetArr[3]
    
    If _IsFolder($szFile) Then
        $szRegDefault = RegRead("HKCR\Folder", "")
        If $szRegDefault <> "" Then $szDefIcon = RegRead("HKCR\Folder\DefaultIcon", "")
    Else
        $szExt = StringRegExpReplace($szFile, '^.*\.', '.')
        
        If $szExt = ".lnk" Then
            Local $LnkInfoArr = FileGetShortcut($szFile)
            If Not @error Then
                Local $RetArr[3] = [2, $LnkInfoArr[4], $LnkInfoArr[5]]
                Return $RetArr
            EndIf
        EndIf
        
        If $szExt = $szFile Then
            $szExt = FileFindFirstFile($szFile & ".*")
            $szExt = StringRegExpReplace(FileFindNextFile($szExt), '^.*\.', '.')
            $szFile &= $szExt
        EndIf
        $szRegDefault = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & $szExt, "ProgID")
        If $szRegDefault = "" Then $szRegDefault = RegRead("HKCR\" & $szExt, "")
        If $szRegDefault <> "" Then $szDefIcon = RegRead("HKCR\" & $szRegDefault & "\DefaultIcon", "")
    EndIf
    If $szDefIcon = "" Then
        $szIconFile = "shell32.dll"
    ElseIf $szDefIcon <> "%1" Then
        If StringRegExpReplace($szFile, "^.*\\", "") = "shell32.dll" Then
            $szIconFile = $szFile
            $nIcon = 0
        Else
            $arSplit = StringSplit($szDefIcon, ",")
            If IsArray($arSplit) Then
                $szIconFile = $arSplit[1]
                If $arSplit[0] > 1 Then $nIcon = $arSplit[2]
            Else
                Opt("ExpandEnvStrings", $Old_Opt_EES)
                Return SetError(1, 0, $RetArr)
            EndIf
        EndIf
    ElseIf $szDefIcon = "%1" Then
        $szIconFile = $szFile
        $nIcon = 0
    EndIf
    Opt("ExpandEnvStrings", $Old_Opt_EES)
    Local $RetArr[3] = [2, $szIconFile, $nIcon]
    Return $RetArr
EndFunc

Func _IsFolder($name)
    Return StringInStr(FileGetAttrib($name), "D")
EndFunc

Func Quit()
    Exit
EndFunc

You will need to install the A3LLibrary from here.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

there not transaprent and the buttons are to small to see the whole pic

What for you need to display these buttons? and the buttons are not small, its the image that small :)

they arnet labled and not all pics show

Label can be added along with the image, search on forum for +image +label - about the all pics... yes, this is a problem, i do not know realy how to get icons from «My Computer» and such elements (the function _GetFileIcon isn't myne btw, i only have make some changes in it).

how would i see all the files in ALL prgrams in start menu in a listview

You need to read the Start Menu >> Programs directory to array, and then just create an LV item for each element ;) (see my previous post ho i did it with the desktop icons, only here you will need to read files to array).

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Ashley, is this for ShellOS? If so, it wouldn't be a very good feature, its your own OS, the user wanted a new OS, and your implementing it more like there old OS. :)

urm... yes it was for my Shell. Not any more i dont really like it so im gona script my own way of making desktop buttons.

And it 'OShell' not 'ShellOS'

Anyways hows your 'MicroOS coming along

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...