Sign in to follow this  
Followers 0
corgano

Smarticon project

8 posts in this topic

#1 ·  Posted (edited)

About Smarticon project 1.4.9

This is the result of a project to make desktop icons support multiple files. Smart icon project creates an icon on the desktop and allows you to register programs or files to the right click menu of the icon.

Posted Image

How it works

Smarticon manager (SIman.exe) Allows you to easly create Smarticons with no need advanced computer skills. Smarticons are written into the registry and appear on your desktop as normal icons. Launching files is acomplished with the smarticon opener (SIopener.exe), to allow for any file type to be supported

Features

-Easy to set up icons

-Allows for custom icons

-Opens any type of file

-Unlimited files per icon

-1000 icon maximum

-Registry entries are easily identifiable and editable

~Click and drag files now works! you can click and drag a file directly into the right list, adding it to the icon. This supports multiple items

Links

32 Bit: Installer - zip archive

64 Bit: Installer - zip archive

See all versions

This is the original thread, with an example I extrapolated from

Source code

This is the source, version 1.4.9

SIman.au3:

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>


If @OSType = "Vista" OR @OSType = "2008" OR @OSType = "2008R2" OR @OSType = "Win7" Then
    #requireadmin
EndIf


Global $SIOP = @scriptdir & "\SIOpener.exe"
if FileExists($SIOP) = 0 Then
    FileCopy(@scriptdir & "\SIOpener.exe",$SIOP,8)
    If @error Then
        MsgBox(0,"Error","The smart icon opener was not found. Smart icons will not be able to open files, and self delete will not work.")
    EndIf
EndIf


#Region ### START Koda GUI section ### Form=
$GUI = GUICreate("Smart Icon Manager 1.4.8", 522, 231, 186, 117,-1,$WS_EX_ACCEPTFILES)
GUICtrlCreateGroup("Smart Icon Properties", 8, 8, 249, 217)
$Ilist = GUICtrlCreateList("", 16, 24, 113, 188)
GUICtrlCreateLabel("SI Name:", 144, 24, 48, 17)
GUICtrlCreateLabel("SI Tooltip:", 144, 72, 52, 17)
GUICtrlCreateLabel("SI Icon:", 144, 120, 41, 17)
$Iname = GUICtrlCreateInput("", 136, 40, 113, 21)
$Itool = GUICtrlCreateInput("", 136, 88, 113, 21)
$Ibrowse = GUICtrlCreateButton("Browse...", 136, 144, 57, 25, $WS_GROUP)
$Inew = GUICtrlCreateButton("New", 136, 184, 57, 25, $WS_GROUP)
$Idel = GUICtrlCreateButton("Del", 192, 184, 57, 25, $WS_GROUP)
$Iicon = GUICtrlCreateIcon("", "" + 1, 200, 120, 49, 49,$WS_GROUP)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Smart Icon Files ("&"No Icon Selected"&")", 264, 8, 249, 217)
$fList = GUICtrlCreateList("", 272, 24, 113, 188)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlCreateLabel("File path:", 400, 72, 60, 17)
GUICtrlCreateLabel("Item Name:", 400, 24, 60, 17)
$Fname = GUICtrlCreateInput("", 392, 40, 113, 21)
$Fpath = GUICtrlCreateInput("", 392, 88, 113, 21)
$Fbrowse = GUICtrlCreateButton("Browse...", 392, 112, 115, 25, $WS_GROUP)
$Fmdel = GUICtrlCreateButton("Make Self Delete", 392, 152, 57, 33, BitOR($BS_MULTILINE,$WS_GROUP))
$Fmedit = GUICtrlCreateButton("Make Self Edit", 448, 152, 57, 33, BitOR($BS_MULTILINE,$WS_GROUP))
$fnew = GUICtrlCreateButton("New", 392, 184, 57, 25, $WS_GROUP)
$fdel = GUICtrlCreateButton("Del", 448, 184, 57, 25, $WS_GROUP)


global $selicon, $selname, $seltool, $selimag[2], $selfunc, $selfnam, $selfpat
getinfo()
setinfo()

GUIRegisterMsg (0x233,"foo") ; IMPORTANT needed for drag and drop

;~ GUICtrlSetData($ffunc, _scanfunc($selicon))
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
;==================================================================================================================================
;
;==================================================================================================================================
        Case $Ilist
            getinfo(GUICtrlRead($Ilist))
            setinfo()

        case $Iname
            iconcreate($selicon, GUICtrlRead($Iname), GUICtrlRead($Itool), $selimag[0]&','&$selimag[1])

        case $Itool
            iconcreate($selicon, GUICtrlRead($Iname), GUICtrlRead($Itool), $selimag[0]&','&$selimag[1])

        case $iBrowse
            $selimag = selecticon()
            GUICtrlSetImage($Iicon,$selimag[0],$selimag[1])
            consolewrite($selimag[0]&','&$selimag[1]&@CRLF)
            iconcreate($selicon, GUICtrlRead($Iname), GUICtrlRead($Itool), $selimag[0]&','&$selimag[1])
        case $inew
            $selicon = iconcreate()
            getinfo($selicon)
            setinfo()

        case $idel
            RegDelete ("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $selicon & "-0000-0000-000000000002}")
            RegDelete ("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{00000000-" & $selicon & "-0000-0000-000000000002}")

            getinfo(stringleft(_scan(),4))
            setinfo()
;==================================================================================================================================
;
;==================================================================================================================================
        case $fnew
            $selfunc = addfunc($selicon, "New item", "")

            getinfo($selicon,$selfunc)
            setinfo()

        case $fdel
            delfunc($selicon, $selfunc)
            getinfo($selicon)
            setinfo()

        case $fname
            delfunc($selicon, $selfunc)
            $selfunc = addfunc($selicon, GUICtrlRead($fname), GUICtrlRead($fpath))
            getinfo($selicon,$selfunc)
            setinfo()

        case $fpath
            $selfunc = addfunc($selicon, GUICtrlRead($fname), GUICtrlRead($fpath))

        case $fbrowse
            $path = FileOpenDialog("Select target file",@DesktopDir,"All (*.*)")
            if not @error Then
                GUICtrlSetData($fpath,$path)
                $selfunc = addfunc($selicon, GUICtrlRead($fname), GUICtrlRead($fpath))
            EndIf

        Case $flist
            getinfo($selicon,GUICtrlRead($flist))
            setinfo()

        Case $fmdel
            $selfunc = addfunc($selicon, "~Delete", 'del.123" "' & $selicon)
            getinfo($selicon)
            setinfo()

        Case $fmedit
            $selfunc = addfunc($selicon, "~Edit...", @ScriptFullPath)
            getinfo($selicon)
            setinfo()

    EndSwitch
WEnd

Func foo($hWnd, $msgID, $wParam, $lParam)
    Local $nSize, $pFileName, $filepath
    Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 255)
    For $i = 0 To $nAmt[0] - 1
        $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0)
        $nSize = $nSize[0] + 1
        $pFileName = DllStructCreate("char[" & $nSize & "]")
        DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize)
        $filepath = DllStructGetData($pFileName, 1)
        if stringright($filepath,4) = ".lnk" Then
            $filepath = FileGetShortcut($filepath)
            $filepath = $filepath[0]
        EndIf
        $t = StringReplace(StringTrimLeft($filepath,StringInStr($filepath,"\",0,-1))," - Shortcut.lnk","")
        $selfunc = addfunc($selicon, $t,$filepath )
        getinfo($selicon,$selfunc)
        setinfo()

        $pFileName = 0
    Next
EndFunc

func getinfo($id1 = "", $id2 = "")
    $selicon = $id1
    if $selicon = "" then $selicon = stringleft(_scan(),4)
    $selname = RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $selicon & "-0000-0000-000000000002}", "")
    $seltool = RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $selicon & "-0000-0000-000000000002}", "InfoTip")
    $s = RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $selicon & "-0000-0000-000000000002}\DefaultIcon", "")
    $s = stringsplit($s,",")
    $selimag[0] = $s[1]
    if $s[0] > 1 then
        $selimag[1] = -$s[2] - 1
    Else
        $selimag[1] = -1
    EndIf
    $selfunc = $id2
    If $selfunc = "" Then
        $temp = StringSplit(_scanfunc($selicon),"|")
        $selfunc = $temp[1]
    EndIf
    $selfnam = stringtrimleft(RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $selicon & "-0000-0000-000000000002}\Shell\" & $selfunc , ""),1)
    $selfpat = stringreplace(stringreplace(RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $selicon & "-0000-0000-000000000002}\Shell\" & $selfunc & "\Command", ""),"Explorer /root, ",""),'"'&$SIOP&'" ',"")
    if StringLeft ($selfpat,1) = '"' Then $selfpat = stringtrimleft ($selfpat,1)
    if Stringright($selfpat,1) = '"' Then $selfpat = stringtrimright($selfpat,1)
EndFunc

func setinfo()

    GUICtrlSetData($Ilist, "")
    GUICtrlSetData($Ilist, _scan(), $selicon)
    GUICtrlSetData($Iname,$selname)
    GUICtrlSetData($Itool,$seltool)
    GUICtrlSetImage($Iicon,$selimag[0],$selimag[1]+1)
    if $selname = "" then $selname = "No Icon Selected"
    GUICtrlSetData($Group2,"Smart icon Files ("&$selname&")")

    GUICtrlSetData($flist, "")
    GUICtrlSetData($flist, _scanfunc($selicon),$selfunc)
    GUICtrlSetData($Fname, $selfnam)
    GUICtrlSetData($Fpath, $selfpat)
EndFunc

func selecticon()
    $temp = DllCall("shell32.dll", "int", "PickIconDlg", "hwnd", 0, "wstr", "", "int", 1000, "int*",0)
    If $temp[2] = "%SystemRoot%\syswow64\SHELL32.dll" or  $temp[2] = "%SystemRoot%\system32\SHELL32.dll" Then
        if @OSArch = "x64" then
            $selimag[0] = stringreplace($temp[2],"%SystemRoot%\syswow64\SHELL32.dll","Shell32.dll")
        Else
            $selimag[0] = stringreplace($temp[2],"%SystemRoot%\system32\SHELL32.dll","Shell32.dll")
        EndIf
        $selimag[1] = -$temp[4]
    EndIf
    $selimag[1] = -$temp[4] -1

    Return $selimag
EndFunc

;==============================================================================================
;                                   start icon functions
;==============================================================================================
Func iconcreate($CLSID = "find", $title = "title", $tip = "tooltip", $icon = "")
    If $icon = "" Then $Icon = StringRegExpReplace(@ScriptFullPath, '(?m)(^\[[^\]]*+\]|(?<!\\)(\\)(?![\\\r]))', '\1\2')
    if $clsid = "find" then
        for $number = 2001 to 2999
            RegEnumKey("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $number & "-0000-0000-000000000002}", 1)
            If @error Then
                $clsid = $number
                ExitLoop
            EndIf
        Next
    EndIf

    RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $CLSID & "-0000-0000-000000000002}")
    RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $CLSID & "-0000-0000-000000000002}", "", "REG_SZ", $title)
    RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $CLSID & "-0000-0000-000000000002}", "InfoTip", "REG_SZ", $tip)
    RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $CLSID & "-0000-0000-000000000002}", "NeverShowExt", "REG_SZ", "")

    RegWrite ("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $CLSID & "-0000-0000-000000000002}\DefaultIcon")
    RegWrite ("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $CLSID & "-0000-0000-000000000002}\DefaultIcon", "", "REG_SZ", $Icon)

    RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $CLSID & "-0000-0000-000000000002}\Shell")

    RegWrite("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{00000000-" & $CLSID & "-0000-0000-000000000002}")
    Return $CLSID
EndFunc   ;==>iconcreate

Func _scan()
    Local $number, $i = 0, $list

    $number = 2000

    Do
        RegEnumKey("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $number & "-0000-0000-000000000002}", 1)
        If @error Then
            $number = $number + 1
        Else
            $list &= $number & "|"
            $number = $number + 1
            $i += 1
        EndIf
    Until $number = 2068
    $list = Stringtrimright($list,1)

    Return $list
EndFunc   ;==>_scan
;==============================================================================================
;
;==============================================================================================
Func delfunc($ID, $name)
    RegDelete("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $name)
EndFunc   ;==>delfunc

Func addfunc($ID, $name, $path)
    $temp = StringSplit($path,".")
    $ext = "." & $temp[$temp[0]]
    ConsoleWrite($path &@crlf)
    if StringLeft ($path,1) = '"' Then $path = stringtrimleft ($path,1)
    if Stringright($path,1) = '"' Then $path = stringtrimright($path,1)
    $path = '"'& $SIOP & '" "' & $path &'"'
    ConsoleWrite($path &@crlf)
    RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $name)
    RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $name, "", "REG_SZ", "&" & $name)
    RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $name & "\Command")
    RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $name & "\Command", "", "REG_SZ", $path)
    Return $name
EndFunc   ;==>addfunc

Func _scanFunc($ID)
    Local $list = "", $num = 1
;~     ConsoleWrite("entering loop: scanfunc. ")
    For $i = 1 to 10
        $what = RegEnumkey("HKEY_CLASSES_ROOT\CLSID\{00000000-"&$ID&"-0000-0000-000000000002}\Shell", $i)
        If @error Then exitloop
        $list &= $what&"|"
    Next
    StringTrimright($list,2)
;~     ConsoleWrite($i - 1 & " results found" & @CRLF & $list & @CRLF)
    Return $list
EndFunc   ;==>_scanFunc

SIopener.au3:

Opt("TrayIconHide",1)
If $cmdline[0] = 1 Then
    if stringright($cmdline[1],3) = "exe" Then
        $workingdir = StringLeft($cmdline[1],StringInStr($cmdline[1], "\", 0, -1))
        shellexecute($cmdline[1],"",$workingdir)
    Else
        shellexecute($cmdline[1])
    EndIf
ElseIf $cmdline[1] = "del.123" Then
    RegDelete ("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $CmdLine[2] & "-0000-0000-000000000002}")
    RegDelete ("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{00000000-" & $CmdLine[2] & "-0000-0000-000000000002}")
    if @error Then
        MsgBox(0,"Error","Icon with ID " & $CmdLine[2] & " could not be deleted or does not exsist.")
    Else
        MsgBox(0,"Success","Icon with ID " & $CmdLine[2] & " was removed. Refreash to see results")
    EndIf
EndIf
Exit

Thank you's:

Mat - wrote the original icon script, it would make an autoit icon on desktop with preset functions. He also gave feedback on earlier versions of the script.

Matt (a different one!) and Mr Ham sammich - Tested it on XP 32bit and win 7 64bit, found and helped me fix errors, gave feedback.

1.4.5

EDIT1-updated script with a couple fixes - thanks Mat

EDIT2-Added self edit and self delete items (buttons were there, but didn't do anything. this is fixed)

1.4.6

EDIT3-Now comes in 64 bit, installers and zip archives are available!

EDIT4-Fixed missing default icon, Fixed spelling errors, Added admin check for UAC systems (post vista) - Thanks (a different) Matt, Mr Ham sammich

1.4.8

EDIT5-Click and dragging has been added, check features for details. EDIT on EDIT5:....and now it actually works!

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites



Is this what you intended? Only I think you mean to use $CmdLine[1] inside the RegDeletes.

ElseIf $cmdline[2] = "del.123" Then
    RegDelete ("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $CmdLine[2] & "-0000-0000-000000000002}")
    RegDelete ("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{00000000-" & $CmdLine[2] & "-0000-0000-000000000002}")
    if @error Then
        MsgBox(0,"Error","Icon with ID " & $CmdLine[2] & " could not be deleted or does not exsist.")
    Else
        MsgBox(0,"Success","Icon with ID " & $CmdLine[2] & " was removed. Refreash to see results")
    EndIf
EndIf

Also this does not need a split:

$workingdir = stringtrimright($cmdline[1],stringlen($temp[$temp[0]]))

You can use StringInStr("Testing", "t", 0, -1) to get the last occurence:

$workingdir = StringLeft($cmdline[1],StringInStr($cmdline[1], "\", 0, -1))

Other than that, good work :mellow: It's good to see an idea taken further. I've added a link to it from the first post of the other thread, this is the fourth version now :P

Mat

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

@ first thing, I actually meant this:

ElseIf $cmdline[1] = "del.123" Then
    RegDelete ("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $CmdLine[2] & "-0000-0000-000000000002}")
    RegDelete ("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{00000000-" & $CmdLine[2] & "-0000-0000-000000000002}")
    if @error Then
        MsgBox(0,"Error","Icon with ID " & $CmdLine[2] & " could not be deleted or does not exsist.")
    Else
        MsgBox(0,"Success","Icon with ID " & $CmdLine[2] & " was removed. Refreash to see results")
    EndIf
EndIf

So if you execute SIopener.exe with "del.123 2001", it would delete icon 2001

@second thing, Thanks, it works a lot better then the string split method.

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites

@ first point, i actually meant this:

ElseIf $cmdline[1] = "del.123" Then
    RegDelete ("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $CmdLine[2] & "-0000-0000-000000000002}")
    RegDelete ("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{00000000-" & $CmdLine[2] & "-0000-0000-000000000002}")
    if @error Then
        MsgBox(0,"Error","Icon with ID " & $CmdLine[2] & " could not be deleted or does not exsist.")
    Else
        MsgBox(0,"Success","Icon with ID " & $CmdLine[2] & " was removed. Refreash to see results")
    EndIf
EndIf

So if you execute SIopener.exe with "del.123 2001", it would delete icon 2001

@second thing, Thanks, it works a lot better then the string split method.

Ah right... I thought it was a bit odd having a parameter for an argument followed by the argument :mellow: "exsist" also looks out of place (chrome spellchecker coming in handy)

It's a small trick that is going to be released along with a few others when I finish off some examples for some more string functions. I think it's annoying that you need statements like that to do what what most languages have built in ("test".LastIndexOf('t') etc.)

Mat

Share this post


Link to post
Share on other sites

You could create stringex.au3 include, or add to it if it already exists.


0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites

UPDATE:

~64 Bit version now available!

~Installers and zip archives now have readme's!

I am taking suggestions for features and new names ("smarticon" has been used too much on this forum)


0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites

UPDATE:

~Click and drag files now works! you can click and drag a file directly into the right list, adding it to the icon. This supports multiple items

~Fixed installer path bug for the installers

~Checks for Admin privileges to be run on UAC-enabled computers


0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

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