Jump to content

Enhanced Icons V1.1 + V2 by smashly + another version by corgano!


Mat
 Share

Recommended Posts

  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi,

I did a rewrite of your code to make it a little more functional to use the gui.

Made it so the user can bounce back and forth between Edit and Uninstall tabs to accomplish what they want.

It's not fool proof or error free or finished, but it's a little better then it was even though the code is now twice as long..lol

Updated 18/Sep/09:

Added: Context Menus to Edit and Uninstall listviews.

Added: Drag items Up or Down in the Edit listview to arrange things easily.

Removed: Add Item(s), Delete Selected, Move Down, Move Up, Uninstall Selected and Uninstall All buttons.

(All these buttons have been replaced by context menus and drag items, which speeds up the use of the gui for the user.)

Fixed: Presets crash caused when saving a preset with a name that has the partial match to other presets in the list.

(replaced _GUICtrlComboBox_FindString() with _GUICtrlComboBox_FindStringExact())

Other: Mild internal changes in the code for the gui.

Updated 17/Sep/09:

Changed: Examples combobox is now called Presets

(Preset still has the basic 4 examples, that can now be loaded/edited/deleted/saved by the user from within the Gui).

Added: Save Preset and Delete Preset buttons.

(This way a user can load/save their own defined preset quickly for easy edit/create of a desktop icon.)

Added: Auto Size the listview columns on the fly.(Makes it a little easier and quicker to see and edit things with less effort.)

Added: Minimal size the Gui can be resized down to (Makes it so the Controls don't overlap each other).

Changed: Default width and height of the Gui (mainly to fit the 2 new preset buttons).

Updated 16/Sep/09:

Added: Examples ComboBox to the bottom of the Edit tab, contains 4 examples.

Select an example and it'll load the fields with the data ready for a user to edit or straight out create an icon.

Changed: Url example to use Mat's method of "Rundll32.exe Url,FileProtocolHandler" to launch a Url (tidy way to do it Mat :D)

Fixed: Text in the in place edit being chopped off at the bottom when in XP. (shrunk the font when in xp/2003/2000)

Tested it in English Win XP x86, English Win 7 x64 with AutoIt v3.3.0.0 & v3.3.1.1 x86 & x64

Original 10/Sep/09

Added: Resizable GUI

(Static small one size gui blows when trying to work with multi column listviews that contain long names/text/comands/paths/UUIDs/..etc.)

Added: Preview Icon to the Edit tab so a user can get an idea of what the desktop icon will be like.

(It shows the name underneath, info tip when hovered over, right click to see the dummy context menu. Updates the Preview as the user changes the fields)

Added: Double click in place edit of the Context Text & Command items in the Edit tab

Added: Multi Select Context items in the Edit tab for easy removal of unwanted context entries.

Added: Move UP/Down buttons in Edit tab to get the Context Menu in the order you like easily.

(currrently only single selected items can be moved up or down.)

Added: Clear/Cancel Edit button sets Edit tab fields to blank or Cancels an Edit and sets the fields blank.

Added: Create/Edit button in Edit tab.

(depends on if your Editing or Creating a new icon as to what the button does)

Added: Double click an installed item in the Uninstall tab to send it to the Edit Tab

Added: Multi Select Uninstall items for uninstalling multiple or single installed icons

Added: Icons to the Uninstall listview, to maybe make it easier for a user to spot the icon they want to uninstall or edit

Added: Icon File column to Uninstall listview

Added: First Context Menu Item Text & Item Command column to Uninstall listview

Added: Uninstall Selected button to uninstall tab

Added: a tag to the the namespace key in the registry when an icon is created, this way the uninstall only shows what I've added.

Added: refresh desktop on add or remove of icons.

Added: other behind the scenes stuff, but enuff dribble, have a play and see.

Cheers

Edit Updated 18/Sep/09:

EDI.au3

Edited by smashly
Link to comment
Share on other sites

Hi,

really cool stuff! :D

Tried to tidy my crowded desktop for presentations prior your script solution through (some) folders on the desktop containing the links you now offer through the context menue.

By the way: Using your example entries, I get an error message 'Der Pfad "e" ist nicht vorhanden oder verweist auf kein Verzeichnis.' which is roughly translated 'Path "e" not existing or does not point to a folder' (German Win XP SP3). After I removed the "e," in the sample entries, everything was fine:

Func LoadExample()
    GUICtrlSetData($aInput[0], "Enhanced Explorer Shortcut")
    GUICtrlSetData($aInput[1], "My cool Enhanced Desktop Icon shorcut")
    GUICtrlSetData($aInput[2], @SystemDir & "\shell32.dll,8")
    GUICtrlCreateListViewItem("Explorer at " & @HomeDrive & "|explorer.exe " & @HomeDrive, $iLV1)
    GUICtrlCreateListViewItem("Explorer at Windows|explorer.exe " & @WindowsDir, $iLV1)
    GUICtrlCreateListViewItem("Explorer at System|explorer.exe " & @SystemDir, $iLV1)
EndFunc   ;==>LoadExample

Ciao,

Martin

Link to comment
Share on other sites

Hi,

really cool stuff! :D

Tried to tidy my crowded desktop for presentations prior your script solution through (some) folders on the desktop containing the links you now offer through the context menue.

By the way: Using your example entries, I get an error message 'Der Pfad "e" ist nicht vorhanden oder verweist auf kein Verzeichnis.' which is roughly translated 'Path "e" not existing or does not point to a folder' (German Win XP SP3). After I removed the "e," in the sample entries, everything was fine:

Func LoadExample()
    GUICtrlSetData($aInput[0], "Enhanced Explorer Shortcut")
    GUICtrlSetData($aInput[1], "My cool Enhanced Desktop Icon shorcut")
    GUICtrlSetData($aInput[2], @SystemDir & "\shell32.dll,8")
    GUICtrlCreateListViewItem("Explorer at " & @HomeDrive & "|explorer.exe " & @HomeDrive, $iLV1)
    GUICtrlCreateListViewItem("Explorer at Windows|explorer.exe " & @WindowsDir, $iLV1)
    GUICtrlCreateListViewItem("Explorer at System|explorer.exe " & @SystemDir, $iLV1)
EndFunc   ;==>LoadExample

Ciao,

Martin

Hi, yep your correct that e, should have been "/e," and it does work withothout it.

Good spotting :D

I should of mentioned I've only run the script on English Win7 x64 with autoit x86 & x64 v3.3.0.0 and beta v3.3.1.1.

Funny how win 7 lets me pass dodgy parameters without error..lol

Cheers

That LoadExample() function really wasn't needed, I just used it to save me time in loading the fields in the edit tab while writing the script..

Remove the function all together if you like...

Link to comment
Share on other sites

...That LoadExample() function really wasn't needed, I just used it to save me time in loading the fields in the edit tab while writing the script..

Remove the function all together if you like...

...but is very useful to start with.

What about changing the 'Uninstall' tab name to 'Update' or 'Manage Icons' and add an <Edit> Button beside the two existing ones. Took me some time to find the double-click allows to edit :D

OT: Did you notice the time-zone difference of your and my location is some hours and 30 minutes ? :D Did you edit the time in the quote tag?

Ciao,

Martin

Link to comment
Share on other sites

Hi,

You can name the tab names to anything you like yourself very easily.

Just change the words in:

$aTab[3] = [0, "Edit", "Uninstall"]

I couldn't see the point in an edit button..

To send an item to the the edit tab you'd have to select the item first, then move the mouse to click an edit button.

I prefer to double click the mouse at the one spot while it's there, hence the double click an item.

I did add a tooltip to the Uninstall listview that tells you to double click to send to edit tab :D

Nope I didn't change the time in the quote tag when I edited.

Cheers

Link to comment
Share on other sites

KK... you win :D, nice to see an idea of mine being used

Lets see corganos then! I'll link to the above post in the first one...

MDiesel

Srry for the long wait. I have not had much time lately. It is almost done.

It is based off your original example, Very simple. you can delete off the main program, but it also makes a self deleting remove script.

And here you go:

#include <Array.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Form1", 218, 190, 192, 124, BitOR($WS_SYSMENU, $WS_CLIPSIBLINGS))
GUISetBkColor(0xABCDEF)

$ButtonNew = GUICtrlCreateButton("New", 136, 12, 75, 25, $WS_GROUP)
$ButtonEdit = GUICtrlCreateButton("Edit", 136, 44, 75, 25, $WS_GROUP)
$ButtonDelete = GUICtrlCreateButton("Delete", 136, 76, 75, 25, $WS_GROUP)

$List1 = GUICtrlCreateList("", 0, 8, 129, 149)
$temp = StringSplit(_scan(),"|")
GUICtrlSetData($List1, StringTrimRight(_scan(), 1),$temp[1])

$ButtonExit = GUICtrlCreateButton("Exit", 136, 128, 75, 25, $WS_GROUP)

GUISetState(@SW_SHOW)

WinSetTrans($Form1, "", 255)
_WinAPI_SetLayeredWindowAttributes($Form1, 0xABCDEF)
#EndRegion ### END Koda GUI section ###


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ButtonExit
            Exit

        Case $ButtonNew
            $C = _getid()
            iconcreate($C, "New icon", "OMG PIE")
            remover($C)
            menu($C)
            GUICtrlSetData($List1, "")
            GUICtrlSetData($List1, StringTrimRight(_scan(), 1))
        Case $ButtonEdit
            menu(GUICtrlRead($List1))
;~      Case $ButtonDelete

    EndSwitch
WEnd


Func menu($ID)
    $name = RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}", "")
    $tooltip = RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}", "InfoTip")

    $Form2 = GUICreate("Editing:" & $name, 274, 214, 199, 147)
    GUISetBkColor(0xABCDEF)
    $ButtonNew = GUICtrlCreateButton("New", 144, 56, 59, 25, $WS_GROUP)
    $Buttondel = GUICtrlCreateButton("Delete", 208, 56, 59, 25, $WS_GROUP)
    $FuncList = GUICtrlCreateList("", 8, 56, 129, 149)
    $temp = StringSplit(_scanfunc($ID),"|")
    GUICtrlSetData($FuncList, _scanfunc($ID),$temp[1])
    $Label2 = GUICtrlCreateLabel("Function List", 40, 40, 64, 15)
    $Label1 = GUICtrlCreateLabel("Name", 144, 88, 32, 15)
    $Label3 = GUICtrlCreateLabel("Path", 144, 128, 26, 17)
    $Label4 = GUICtrlCreateLabel("Name", 24, 0, 32, 17)
    $Label5 = GUICtrlCreateLabel("Tooltip", 152, 0, 36, 17)

    $Inputname = GUICtrlCreateInput("run notepad", 144, 104, 121, 21)
    $Inputpath = GUICtrlCreateInput("notepad.exe", 144, 144, 121, 21)
    $Inputtool = GUICtrlCreateInput($tooltip, 144, 16, 121, 21)
    $Inputiconname = GUICtrlCreateInput($name, 16, 16, 121, 21)
    $Buttondone = GUICtrlCreateButton("done", 144, 176, 59, 25, $WS_GROUP)
    $Buttonapply = GUICtrlCreateButton("apply", 208, 176, 59, 25, $WS_GROUP)

    $f = GUICtrlRead($FuncList)
    GUICtrlSetData($inputname,StringReplace(RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $F, ""),"&",""))
    GUICtrlSetData($inputpath,RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $F & "\Command", ""))

    GUISetState(@SW_SHOW)

    WinSetTrans($Form2, "", 255)
    _WinAPI_SetLayeredWindowAttributes($Form2, 0xABCDEF)


    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete($Form2)
                ExitLoop
            Case $Buttondone
                iconcreate($ID, GUICtrlRead($Inputiconname), GUICtrlRead($Inputtool));this will OVERWRITE the current one, thus, refreshing the infromation
                GUIDelete($Form2)
                ExitLoop

            Case $Buttondel
                delfunc($ID, GUICtrlRead($FuncList))
                GUICtrlSetData($FuncList, "")
                GUICtrlSetData($FuncList, _scanFunc($ID))

            Case $ButtonNew
                $F = getfuncid($id)
                addfunc($ID, $f, GUICtrlRead($Inputname), GUICtrlRead($Inputpath))
                GUICtrlSetData($FuncList, "")
                GUICtrlSetData($FuncList, _scanFunc($ID))

            Case $Buttonapply
                iconcreate($ID, GUICtrlRead($Inputiconname), GUICtrlRead($Inputtool))
                addfunc($ID, GUICtrlRead($FuncList), GUICtrlRead($Inputname), GUICtrlRead($Inputpath))
                GUICtrlSetData($FuncList, "")
                GUICtrlSetData($FuncList, _scanFunc($ID))

            Case $FuncList
                $f = GUICtrlRead($FuncList)
                GUICtrlSetData($inputname,StringReplace(RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $F, ""),"&",""))
                GUICtrlSetData($inputpath,RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $F & "\Command", ""))

        EndSwitch
    WEnd
EndFunc   ;==>menu


;small reference of test functions

;~ $C = _getid()
;~ iconcreate($c,"this is a test","OMG PIE")
;~ addfunc(1000,1,"poop","notepad.exe")
;~ delfunc(1000, 3)
;~ $list = _scan()

;==============================================================================================
;                                       ;start icon functions
Func iconcreate($CLSID, $title, $tip);creates icon

    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}\Shell")

    RegWrite("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{00000000-" & $CLSID & "-0000-0000-000000000002}")

EndFunc   ;==>iconcreate

Func remover($ID);creates the remove.au3
    $i = 1
    Do
        If FileExists(@ScriptDir & "\Remove" & $i & ".au3") = True Then $i += 1
    Until FileExists(@ScriptDir & "\Remove" & $i & ".au3") = False

    FileWrite(@ScriptDir & "\Remove" & $i & ".au3", "RegDelete (""HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}"")" & @CRLF & _
            "RegDelete (""HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{00000000-" & $ID & "-0000-0000-000000000002}"")" _
             & @CRLF & "MsgBox (48, ""Complete"", ""The autoit Icon has been removed"")" & @CRLF & "EnvUpdate ( )" & @CRLF & @CRLF & @CRLF & _
            "   _AutoDestroy()" & @CRLF & _
            "" & @CRLF & _
            "Func _AutoDestroy()" & @CRLF & _
            "" & @CRLF & _
            "Do" & @CRLF & _
            "$destroFileTemp= 'destroy.bat'" & @CRLF & _
            "$destroFileTemp = @MIN & @SEC & $destroFileTemp" & @CRLF & _
            "Until FileExists($destroFileTemp) = 0" & @CRLF & _
            "" & @CRLF & _
            "$file = FileOpen($destroFileTemp, 1)" & @CRLF & _
            "FileWriteLine($file, 'del Remove" & $i & ".au3')" & @CRLF & _
            "FileWriteLine($file, 'del ' & $destroFileTemp)" & @CRLF & _
            "FileClose($file)" & @CRLF & _
            "" & @CRLF & _
            "Run(@ScriptDir & '\' & $destroFileTemp)" & @CRLF & _
            "Exit" & @CRLF & _
            "EndFunc")
EndFunc   ;==>remover
Func _getid()
    Local $number, $key

    $number = 2000
    $key = 4.233246236767861237865417265162354675234
    ConsoleWrite("entering while loop: Getid" & @CRLF)
    While 1
        RegEnumKey("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $number & "-0000-0000-000000000002}", 1)
        If @error Then
            $key = $number
            ExitLoop
        Else
            $number = $number + 1
        EndIf
    WEnd
    ConsoleWrite("exiting while loop: getid. " & $key & " returned" & @CRLF)
    Return $key
EndFunc   ;==>_getid

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

    $number = 2000

    ConsoleWrite("entering do loop: scan" & @CRLF)
    Do
        RegEnumKey("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $number & "-0000-0000-000000000002}", 1)
        If @error Then
            $number = $number + 1
        Else
            $list[$i] = $number
            ConsoleWrite($list[$i] & @CRLF)
            $number = $number + 1
            $i += 1
        EndIf
    Until $number = 2468
    ConsoleWrite("exiting do loop: scan. " & $i & " icons found" & @CRLF)

    $list = StringReplace(_ArrayToString($list), "||", "")
    Return $list
EndFunc   ;==>_scan
;==============================================================================================
;                                   end icon functions

;                                   start function functions
;==============================================================================================
Func getfuncid($ID)
    Local $i = 1, $num = 4.2345432534252345
    ;=======get first available slot to write the func

    ConsoleWrite("entering while loop: getfuncid" & @CRLF)
    While 1
        RegEnumKey("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $i, 1)

        If @error Then
            $num = $i
            ExitLoop
        Else
            $i += 1
        EndIf

    WEnd
    ConsoleWrite("exiting while loop: getfuncid. " & $num & " returned" & @CRLF)
    Return $num
EndFunc

Func delfunc($ID, $num)
    ConsoleWrite("function " & RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $num, "") & " has been deleted")
    RegDelete("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $num)
EndFunc   ;==>delfunc

Func addfunc($ID, $num, $name, $path)
    RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $num)
    RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $num, "", "REG_SZ", "&" & $name)
    RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $num & "\Command")
    RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $num & "\Command", "", "REG_SZ", $path)
EndFunc   ;==>addfunc

Func _scanFunc($ID)
    Local $num, $i = 00, $list[1000]

    $num = 1

    ConsoleWrite("entering do loop: scanfunc" & @CRLF)
    Do
        RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $num, "")
;~                  "HKEY_CLASSES_ROOT\CLSID\{00000000-2000-0000-0000-000000000002}\Shell\01"
        If @error Then
        Else
            $list[$i] = $num
            ConsoleWrite($list[$i] & @CRLF)
            $i += 1
        EndIf
        $num += 1
    Until $num = 123
    ConsoleWrite("exiting do loop: scanfunc. " & $i & " functions in icon " & $ID & " found" & @CRLF)

    $list = StringReplace(_ArrayToString($list), "||", "")
    Return $list
EndFunc   ;==>_scanFunc
;                           end function functions
;==============================================================================================











Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False)
    ; #############################################
    ; You are NOT ALLOWED to remove the following lines
    ; Function Name: _WinAPI_SetLayeredWindowAttributes
    ; Author(s): Prog@ndy
    ; #############################################
    If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03

    If Not $isColorRef Then
        $i_transcolor = Hex(String($i_transcolor), 6)
        $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
    EndIf
    Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages)
    Select
        Case @error
            Return SetError(@error, 0, 0)
        Case $Ret[0] = 0
            Return SetError(4, _WinAPI_GetLastError(), 0)
        Case Else
            Return 1
    EndSelect
EndFunc   ;==>_WinAPI_SetLayeredWindowAttributes

PLEASE note that this is a test version. if you find issues then please let me know. The lists list them by ID#, not by name, and if anyone feels like changeing it go ahead.

The difference in mine is that it writes them all to the same area, makeing them easy to manage. Any suggestions would help

~corgano out

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

more errors on MDiesle's script....

C:\Users\David\Desktop\icon 2.au3(161,104) : WARNING: $pGUID: possibly used before declaration.
            GUICtrlCreateListViewItem (GUICtrlRead ($hName) & "|" & GUICtrlRead ($hInfo) & "|" & $pGUID,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\David\Desktop\icon 2.au3 - 0 error(s), 1 warning(s)
->21:29:03 AU3Check ended.rc:1
>Running:(3.3.0.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Users\David\Desktop\icon 2.au3"    
C:\Users\David\Desktop\icon 2.au3 (237) : ==> Array variable subscript badly formatted.:
Local $aArray[$Count]
Local $aArray[^ ERROR

But it was able to see the icon made with my script. May be that was the cause of the error, editing an icon from a different program.

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

I don't see how...

$Count = _GUICtrlListView_GetItemCount ($hList2)
   Local $aArray[$Count]

is the code... the helpfile says:

Return Value

Success: The number of items

so maybe when there are no items... the return is invalid, so $count is not a number?

MDiesel

If $Count = 0 and you try to declare an array with 0 it will error..

eg: Local $aArray[0] would cause an error.

So check to see if $Count > 0 before declaring the array.

Cheers

Link to comment
Share on other sites

Ah right! That makes sense... Someone got that error before, but I hadn't thought that far, and had ignored it...

corgano...

1) you've got a duplicate winapi function in there. (read 4)

_WinAPI_SetLayeredWindowAttributes

2) delete doesn't change the listview.

3) that layered window is clever... but slightly off putting I think.[/opinion]

4) back to 1. you need an #include-once, becouse that function was added in the beta release (thats why I got duplicate). "Added #868".

5) This is a general thing which applies to mine aswell. the command line needs to be easier to put togethor... how about a wizard?

6) @Earlier post... Thats why I don't check that stuff! $pGUID possibly used before being declared is just them not looking at the way the program runs. its not an error, and if you read the script, you'll see that.

MDiesel

Link to comment
Share on other sites

I accadently my whole post when I updated my script, srry!

#include <Array.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=

$GUImain = GUICreate("Form1", 218, 190, 192, 124, BitOR($WS_SYSMENU, $WS_CLIPSIBLINGS))
;~ GUISetBkColor(0xABCDEF)

    $ButtonNew = GUICtrlCreateButton("New", 136, 12, 75, 25, $WS_GROUP)
    $ButtonEdit = GUICtrlCreateButton("Edit", 136, 44, 75, 25, $WS_GROUP)
    $ButtonDelete = GUICtrlCreateButton("Delete", 136, 76, 75, 25, $WS_GROUP)
$List1 = GUICtrlCreateList("", 0, 8, 129, 149)
$temp = StringSplit(_scan(),"|")
GUICtrlSetData($List1, _scan(),$temp[1])

$ButtonExit = GUICtrlCreateButton("Exit", 136, 128, 75, 25, $WS_GROUP)

;~ WinSetTrans($GUImain, "", 255)
;~ _WinAPI_SetLayeredWindowAttributes($GUImain, 0xABCDEF)
GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###


While 1
    $MMsg = GUIGetMsg()
    Switch $MMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ButtonExit
            Exit

        Case $ButtonNew
                ConsoleWrite("error" & @crlf)
            $ID = _getid()
            iconcreate($ID)
;~          remover($ID);now obsolete
            Editicon($ID)
            GUICtrlSetData($List1, "")
            GUICtrlSetData($List1, _scan())

        Case $ButtonEdit
            Editicon(GUICtrlRead($List1),"Editing Icon: "& RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & GUICtrlRead($List1) & "-0000-0000-000000000002}", ""))

        Case $ButtonDelete
            RegDelete ("HKEY_CLASSES_ROOT\CLSID\{00000000-" & GUICtrlRead($List1) & "-0000-0000-000000000002}")
            RegDelete ("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{00000000-" & GUICtrlRead($List1) & "-0000-0000-000000000002}")
            GUICtrlSetData($List1, "")
            GUICtrlSetData($List1, _scan())


    EndSwitch
WEnd


Func Editicon($id,$title = "new icon")

    $GUIicon = GUICreate($title, 380, 164, 192, 124)
;~  GUISetBkColor(0xABCDEF)

    $ILabel4 = GUICtrlCreateLabel("Functions", 148, 4, 50, 17)
        $IButtonNew = GUICtrlCreateButton("New", 136, 24, 75, 25, $WS_GROUP)
        $IButtonEdit = GUICtrlCreateButton("Edit", 136, 56, 75, 25, $WS_GROUP)
        $IButtonDelete = GUICtrlCreateButton("Delete", 136, 88, 75, 25, $WS_GROUP)
    $IFuncList = GUICtrlCreateList("", 0, 8, 129, 149)
    $Itemp = StringSplit(_scanfunc($ID),"|")
    GUICtrlSetData($IFuncList, _scanfunc($ID),$Itemp[1])

    $IButtonApply = GUICtrlCreateButton("Apply", 136, 128, 75, 25, $WS_GROUP)

    $ILabel1 = GUICtrlCreateLabel('Icon Name ("" for none)', 240, 12, 117, 17)
    $IInputName = GUICtrlCreateInput(RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}", ""), 228, 28, 133, 21)

    $ILabel2 = GUICtrlCreateLabel("Icon Tooltip", 240, 60, 60, 17)
    $IInputTooltip = GUICtrlCreateInput(RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}", "InfoTip"), 228, 76, 133, 21)

    $ILabel3 = GUICtrlCreateLabel("Icon Image", 240, 108, 57, 17)
    $IButtonIcon = GUICtrlCreateButton(RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\DefaultIcon", ""), 228, 124, 133, 21, 0)

;~  WinSetTrans($GUIicon, "", 255)
;~  _WinAPI_SetLayeredWindowAttributes($GUIicon, 0xABCDEF)
    GUISetState(@SW_SHOW)

    While 1
        $IMsg = GUIGetMsg()
        Switch $IMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete($GUIicon)
                ExitLoop

            Case $iButtonApply
                iconcreate($ID, GUICtrlRead($IInputName), GUICtrlRead($IInputTooltip));this will OVERWRITE the current one, thus, refreshing the infromation
                GUIDelete($GUIicon)
                ExitLoop

            Case $IButtonDelete
                delfunc($ID, GUICtrlRead($IFuncList))
                GUICtrlSetData($IFuncList, "")
                GUICtrlSetData($IFuncList, _scanFunc($ID))

            Case $IButtonEdit
                Editfunc($ID, GUICtrlRead($IFuncList), "Editing function " &    RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & GUICtrlRead($List1) , "") & " in " & RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}", ""))
                GUICtrlSetData($IFuncList, "")
                GUICtrlSetData($IFuncList, _scanFunc($ID))

            Case $IButtonNew
                $F = getfuncid($id)
                Editfunc($ID, $f)
                GUICtrlSetData($IFuncList, "")
                GUICtrlSetData($IFuncList, _scanFunc($ID))

            Case $IButtonIcon
                $Ret = DllCall("shell32.dll", "int", "PickIconDlg", "hwnd", 0, "wstr", "", "int", 1000, "int*", 0)
                If $Ret[2] <> "" Then GUICtrlSetData ($IButtonIcon, FileGetShortName ($Ret[2]) & "," & $Ret[4] + 1)

        EndSwitch
    WEnd

EndFunc

Func Editfunc($ID, $fID, $title = "New func")

    $GUIfunc = GUICreate($title, 159, 164, 300, 204)
;~  GUISetBkColor(0xABCDEF)
    $FInputname = GUICtrlCreateInput(RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $fID, ""), 12, 28, 133, 21)
    $FLabel1 = GUICtrlCreateLabel("Function Name", 24, 12, 76, 17)

    $FLabel2 = GUICtrlCreateLabel("Path (", 24, 60, 32, 17)
        $FRadio2 = GUICtrlCreateRadio("Folder )", 92, 59, 53, 17)
        $FRadio1 = GUICtrlCreateRadio("File", 56, 59, 34, 17)
            GUICtrlSetState(-1, $GUI_CHECKED)
    $FButtonPath = GUICtrlCreateButton(RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $fID & "\Command", ""), 12, 76, 133, 42, $BS_MULTILINE)

    $FButtonApply = GUICtrlCreateButton("Apply", 12, 120, 61, 25, 0)
    $FButtonCancil = GUICtrlCreateButton("Cancil", 84, 120, 61, 25, 0)
    GUISetState(@SW_SHOW)

    While 1
        $FMsg = GUIGetMsg()
        Switch $FMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete($GUIfunc)
                ExitLoop

            Case $FButtonCancil
                GUIDelete($GUIfunc)
                ExitLoop

            Case $FButtonPath
                If GUICtrlRead($FRadio1) = $GUI_CHECKED Then
                    $path = FileOpenDialog("Select target file",@DesktopDir,"All (*.*)")
                Else
                    $path = FileSelectFolder("Select target folder","",7,@DesktopDir)
                EndIf
                GUICtrlSetData($FButtonPath,$path)


            Case $FButtonapply
                addfunc($ID, $fID, GUICtrlRead($FInputname), GUICtrlRead($Fbuttonpath))
                GUIDelete($GUIfunc)
                ExitLoop

        EndSwitch
    WEnd


EndFunc

;~ ;small reference of test functions

;~ $C = _getid()
;~ iconcreate($c,"this is a test","OMG PIE")
;~ addfunc(1000,1,"poop","notepad.exe")
;~ delfunc(1000, 3)
;~ $list = _scan()

;==============================================================================================
;                                       ;start icon functions
Func iconcreate($CLSID, $title = "title", $tip = "tooltip", $icon = "")
    $Icon = StringRegExpReplace(@AutoItExe, '(?m)(^\[[^\]]*+\]|(?<!\\)(\\)(?![\\\r]))', '\1\2')

    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}")

EndFunc   ;==>iconcreate

Func remover($ID);creates the remove.au3
    $i = 1
    Do
        If FileExists(@ScriptDir & "\Remove" & $i & ".au3") = True Then $i += 1
    Until FileExists(@ScriptDir & "\Remove" & $i & ".au3") = False

    FileWrite(@ScriptDir & "\Remove" & $i & ".au3", "RegDelete (""HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}"")" & @CRLF & _
            "RegDelete (""HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{00000000-" & $ID & "-0000-0000-000000000002}"")" _
             & @CRLF & "MsgBox (48, ""Complete"", ""The autoit Icon has been removed"")" & @CRLF & "EnvUpdate ( )" & @CRLF & @CRLF & @CRLF & _
            "   _AutoDestroy()" & @CRLF & _
            "" & @CRLF & _
            "Func _AutoDestroy()" & @CRLF & _
            "" & @CRLF & _
            "Do" & @CRLF & _
            "$destroFileTemp= 'destroy.bat'" & @CRLF & _
            "$destroFileTemp = @MIN & @SEC & $destroFileTemp" & @CRLF & _
            "Until FileExists($destroFileTemp) = 0" & @CRLF & _
            "" & @CRLF & _
            "$file = FileOpen($destroFileTemp, 1)" & @CRLF & _
            "FileWriteLine($file, 'del Remove" & $i & ".au3')" & @CRLF & _
            "FileWriteLine($file, 'del ' & $destroFileTemp)" & @CRLF & _
            "FileClose($file)" & @CRLF & _
            "" & @CRLF & _
            "Run(@ScriptDir & '\' & $destroFileTemp)" & @CRLF & _
            "Exit" & @CRLF & _
            "EndFunc")
EndFunc   ;==>remover

Func _getid()
    Local $number, $key

    $number = 2000
    $key = 4.233246236767861237865417265162354675234
    ConsoleWrite("entering while loop: Getid" & @CRLF)
    While 1
        RegEnumKey("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $number & "-0000-0000-000000000002}", 1)
        If @error Then
            $key = $number
            ExitLoop
        Else
            $number = $number + 1
        EndIf
    WEnd
    ConsoleWrite("exiting while loop: getid. " & $key & " returned" & @CRLF)
    Return $key
EndFunc   ;==>_getid

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

    $number = 2000

    ConsoleWrite("entering do loop: scan" & @CRLF)
    Do
        RegEnumKey("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $number & "-0000-0000-000000000002}", 1)
        If @error Then
            $number = $number + 1
        Else
            $list[$i] = $number
            ConsoleWrite($list[$i] & @CRLF)
            $number = $number + 1
            $i += 1
        EndIf
    Until $number = 2468
    ConsoleWrite("exiting do loop: scan. " & $i & " icons found" & @CRLF)

    $list = StringReplace(_ArrayToString($list), "||", "")
    Return $list
EndFunc   ;==>_scan
;==============================================================================================
;                                   end icon functions

;                                   start function functions
;==============================================================================================
Func getfuncid($ID)
    Local $i = 1, $num = 4.2345432534252345
    ;=======get first available slot to write the func

    ConsoleWrite("entering while loop: getfuncid" & @CRLF)
    While 1
        RegEnumKey("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $i, 1)

        If @error Then
            $num = $i
            ExitLoop
        Else
            $i += 1
        EndIf

    WEnd
    ConsoleWrite("exiting while loop: getfuncid. " & $num & " returned" & @CRLF)
    Return $num
EndFunc

Func delfunc($ID, $num)
    ConsoleWrite("function " & RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $num, "") & " has been deleted")
    RegDelete("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $num)
EndFunc   ;==>delfunc

Func addfunc($ID, $num, $name, $path)
    RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $num)
    RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $num, "", "REG_SZ", "&" & $name)
    RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $num & "\Command")
    RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $num & "\Command", "", "REG_SZ", $path)
EndFunc   ;==>addfunc

Func _scanFunc($ID)
    Local $num, $i = 00, $list[1000]

    $num = 1

    ConsoleWrite("entering do loop: scanfunc" & @CRLF)
    Do
        RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $num, "")
;~                  "HKEY_CLASSES_ROOT\CLSID\{00000000-2000-0000-0000-000000000002}\Shell\01"
        If @error Then
        Else
            $list[$i] = $num
            ConsoleWrite($list[$i] & @CRLF)
            $i += 1
        EndIf
        $num += 1
    Until $num = 123
    ConsoleWrite("exiting do loop: scanfunc. " & $i & " functions in icon " & $ID & " found" & @CRLF)

    $list = StringReplace(_ArrayToString($list), "||", "")
    Return $list
EndFunc   ;==>_scanFunc
;                           end function functions
;==============================================================================================











Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False)
    ; #############################################
    ; You are NOT ALLOWED to remove the following lines
    ; Function Name: _WinAPI_SetLayeredWindowAttributes
    ; Author(s): Prog@ndy
    ; #############################################
    If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03

    If Not $isColorRef Then
        $i_transcolor = Hex(String($i_transcolor), 6)
        $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
    EndIf
    Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages)
    Select
        Case @error
            Return SetError(@error, 0, 0)
        Case $Ret[0] = 0
            Return SetError(4, _WinAPI_GetLastError(), 0)
        Case Else
            Return 1
    EndSelect
EndFunc   ;==>_WinAPI_SetLayeredWindowAttributes
Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

@6)It stopped the program from working.

@2)forgot to add the delete function (oops)

@1 and 4)How would I do that? How would I have to so beta and non beta users can use it?

And now it works! (still need a method for getting icon tho, couldn't find icon select dialouge)

Look at my script for the find icon dialog.

1+4) #include-once should do it.

2) :D

6) ?? I never got thzt error, and you shouldn't.

very nice!

Mat (was MDiesel)

Link to comment
Share on other sites

Where do I put the include once?

I attempted to add support for opening folders but it didn't work, How do I make it open a folder?

It now has icon support!

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

Firstly, #include-once should be put next to the include, I don't think it matters where. It is designed to make sure functions are only included once, I have no idea how.

right... I'll make a list for you of stuff I've found. I might even consider writing some kind of wizard.

For URL's (MUST use this method. doesn't work otherwise)

"%WinDir%\System32\Rundll32.exe Url,FileProtocolHandler http://www.example.com"/
For Opening with the default editor for that filetype: you just replace the url in the code above with the file SHORT name.

For opening a folder, you need to run Explorer.exe with command line arguments. AutoIt has a built in function for selecting folders (just opens the dialog)

/n: Opens a new window in single-paned (My Computer) view for each item

selected, even if the new window duplicates a window that is

already open.

/e: Uses Windows Explorer view. Windows Explorer view is most similar

to File Manager in Windows version 3.x. Note that the default view

is Open view.

/root,<object>: Specifies the root level of the specified view. The

default is to use the normal namespace root (the

desktop). Whatever is specified is the root for the

display.

/select,<sub object>: Specifies the folder to receive the initial

focus. If "/select" is used, the parent folder

is opened and the specified object is selected.

all you need is /n (or /e). "Explorer.exe /n ""folder""" should do it :D. Talking about it now makes me think that a wizard would be easy...

is that all? I will definitely write a wizard I think, as I have it all planned.

Mat

Edit: Slightly offtopic... but I seem to remember you wrote a units converter script corgano. Was it you? and where is it? (I remember that it was good, and I might need it for a project)

Edited by Mat
Link to comment
Share on other sites

Units converter? Convert what units?

Your Website example didn't work (both by directly inserting via regedit and by my program)

VERSION 1.3 RELEASED

-Changing the icon now works!

-Full support for target folders and files

-Icons can delete themselves {BETA} (When made by the compiled script, as long as the compiles script is in the same place as it was when the icon was made)

#include <Array.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

If @Compiled = 1 And $CmdLine[0] > 0 Then
    RegDelete ("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $CmdLine[1] & "-0000-0000-000000000002}")
    RegDelete ("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{00000000-" & $CmdLine[1] & "-0000-0000-000000000002}")
    Exit
EndIf

#Region ### START Koda GUI section ### Form=

$GUImain = GUICreate("Form1", 218, 190, 192, 124, BitOR($WS_SYSMENU, $WS_CLIPSIBLINGS))
;~ GUISetBkColor(0xABCDEF)

    $ButtonNew = GUICtrlCreateButton("New", 136, 12, 75, 25, $WS_GROUP)
    $ButtonEdit = GUICtrlCreateButton("Edit", 136, 44, 75, 25, $WS_GROUP)
    $ButtonDelete = GUICtrlCreateButton("Delete", 136, 76, 75, 25, $WS_GROUP)
$List1 = GUICtrlCreateList("", 0, 8, 129, 149)
$temp = StringSplit(_scan(),"|")
GUICtrlSetData($List1, _scan(),$temp[1])

$ButtonExit = GUICtrlCreateButton("Exit", 136, 128, 75, 25, $WS_GROUP)

;~ WinSetTrans($GUImain, "", 255)
;~ _WinAPI_SetLayeredWindowAttributes($GUImain, 0xABCDEF)
GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###


While 1
    $MMsg = GUIGetMsg()
    Switch $MMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ButtonExit
            Exit

        Case $ButtonNew
            $ID = _getid()
            If @Compiled = 1 Then
                RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\99")
                RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\99", "", "REG_SZ", "&Delete")
                RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\99\Command")
                RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\99\Command", "", "REG_SZ", @ScriptFullPath & ' ' & $ID)
            EndIf
            iconcreate($ID)
;~          remover($ID);now obsolete
            Editicon($ID)
            GUICtrlSetData($List1, "")
            GUICtrlSetData($List1, _scan())

        Case $ButtonEdit
            Editicon(GUICtrlRead($List1),"Editing Icon: "& RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & GUICtrlRead($List1) & "-0000-0000-000000000002}", ""))

        Case $ButtonDelete
            RegDelete ("HKEY_CLASSES_ROOT\CLSID\{00000000-" & GUICtrlRead($List1) & "-0000-0000-000000000002}")
            RegDelete ("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{00000000-" & GUICtrlRead($List1) & "-0000-0000-000000000002}")
            GUICtrlSetData($List1, "")
            GUICtrlSetData($List1, _scan())


    EndSwitch
WEnd


Func Editicon($id,$title = "new icon")

    $GUIicon = GUICreate($title, 380, 164, 192, 124)
;~  GUISetBkColor(0xABCDEF)

    $ILabel4 = GUICtrlCreateLabel("Functions", 148, 4, 50, 17)
        $IButtonNew = GUICtrlCreateButton("New", 136, 24, 75, 25, $WS_GROUP)
        $IButtonEdit = GUICtrlCreateButton("Edit", 136, 56, 75, 25, $WS_GROUP)
        $IButtonDelete = GUICtrlCreateButton("Delete", 136, 88, 75, 25, $WS_GROUP)
    $IFuncList = GUICtrlCreateList("", 0, 8, 129, 149)
    $Itemp = StringSplit(_scanfunc($ID),"|")
    GUICtrlSetData($IFuncList, _scanfunc($ID),$Itemp[1])

    $IButtonApply = GUICtrlCreateButton("Apply", 136, 128, 75, 25, $WS_GROUP)

    $ILabel1 = GUICtrlCreateLabel('Icon Name ("" for none)', 240, 12, 117, 17)
    $IInputName = GUICtrlCreateInput(RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}", ""), 228, 28, 133, 21)

    $ILabel2 = GUICtrlCreateLabel("Icon Tooltip", 240, 60, 60, 17)
    $IInputTooltip = GUICtrlCreateInput(RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}", "InfoTip"), 228, 76, 133, 21)

    $ILabel3 = GUICtrlCreateLabel("Icon Image", 240, 108, 57, 17)
    $IButtonIcon = GUICtrlCreateButton(RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\DefaultIcon", ""), 228, 124, 133, 21, 0)

;~  WinSetTrans($GUIicon, "", 255)
;~  _WinAPI_SetLayeredWindowAttributes($GUIicon, 0xABCDEF)
    GUISetState(@SW_SHOW)

    While 1
        $IMsg = GUIGetMsg()
        Switch $IMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete($GUIicon)
                ExitLoop

            Case $iButtonApply
                iconcreate($ID, GUICtrlRead($IInputName), GUICtrlRead($IInputTooltip), GUICtrlRead($IButtonIcon));this will OVERWRITE the current one, thus, refreshing the infromation
                GUIDelete($GUIicon)
                ExitLoop

            Case $IButtonDelete
                delfunc($ID, GUICtrlRead($IFuncList))
                GUICtrlSetData($IFuncList, "")
                GUICtrlSetData($IFuncList, _scanFunc($ID))

            Case $IButtonEdit
                Editfunc($ID, GUICtrlRead($IFuncList), "Editing function " &    RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & GUICtrlRead($List1) , "") & " in " & RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}", ""))
                GUICtrlSetData($IFuncList, "")
                GUICtrlSetData($IFuncList, _scanFunc($ID))

            Case $IButtonNew
                $F = getfuncid($id)
                Editfunc($ID, $f)
                GUICtrlSetData($IFuncList, "")
                GUICtrlSetData($IFuncList, _scanFunc($ID))

            Case $IButtonIcon
                $Ret = DllCall("shell32.dll", "int", "PickIconDlg", "hwnd", 0, "wstr", "", "int", 1000, "int*", 0)
                If $Ret[2] <> "" Then GUICtrlSetData ($IButtonIcon, FileGetShortName ($Ret[2]) & "," & $Ret[4] + 1)

        EndSwitch
    WEnd

EndFunc

Func Editfunc($ID, $fID, $title = "New func")

    $GUIfunc = GUICreate($title, 159, 164, 300, 204)
;~  GUISetBkColor(0xABCDEF)
    $FInputname = GUICtrlCreateInput(RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $fID, ""), 12, 28, 133, 21)
    $FLabel1 = GUICtrlCreateLabel("Function Name", 24, 12, 76, 17)

    $FLabel2 = GUICtrlCreateLabel("Path (", 24, 60, 32, 17)
        $FRadio2 = GUICtrlCreateRadio("Folder )", 92, 59, 53, 17)
        $FRadio1 = GUICtrlCreateRadio("File", 56, 59, 34, 17)
            GUICtrlSetState(-1, $GUI_CHECKED)
    $FButtonPath = GUICtrlCreateButton(RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $fID & "\Command", ""), 12, 76, 133, 42, $BS_MULTILINE)

    $FButtonApply = GUICtrlCreateButton("Apply", 12, 120, 61, 25, 0)
    $FButtonCancil = GUICtrlCreateButton("Cancil", 84, 120, 61, 25, 0)
    GUISetState(@SW_SHOW)

    While 1
        $FMsg = GUIGetMsg()
        Switch $FMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete($GUIfunc)
                ExitLoop

            Case $FButtonCancil
                GUIDelete($GUIfunc)
                ExitLoop

            Case $FButtonPath
                If GUICtrlRead($FRadio1) = $GUI_CHECKED Then
                    $path = FileOpenDialog("Select target file",@DesktopDir,"All (*.*)")
                Else
                    $path = 'explorer "' & FileSelectFolder("Select target folder","",7,@DesktopDir) & '"'
                EndIf
                GUICtrlSetData($FButtonPath,$path)


            Case $FButtonapply
                addfunc($ID, $fID, GUICtrlRead($FInputname), GUICtrlRead($Fbuttonpath))
                GUIDelete($GUIfunc)
                ExitLoop

        EndSwitch
    WEnd


EndFunc

#Region
;~ ;small reference of test functions

;~ $C = _getid()
;~ iconcreate($c,"this is a test","OMG PIE")
;~ addfunc(1000,1,"poop","notepad.exe")
;~ delfunc(1000, 3)
;~ $list = _scan()

;==============================================================================================
;                                       ;start icon functions
Func iconcreate($CLSID, $title = "title", $tip = "tooltip", $icon = "")
    If $icon = "" Then $Icon = StringRegExpReplace(@AutoItExe, '(?m)(^\[[^\]]*+\]|(?<!\\)(\\)(?![\\\r]))', '\1\2')

    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}")

EndFunc   ;==>iconcreate

Func remover($ID);creates the remove.au3
    $i = 1
    Do
        If FileExists(@ScriptDir & "\Remove" & $i & ".au3") = True Then $i += 1
    Until FileExists(@ScriptDir & "\Remove" & $i & ".au3") = False

    FileWrite(@ScriptDir & "\Remove" & $i & ".au3", "RegDelete (""HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}"")" & @CRLF & _
            "RegDelete (""HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{00000000-" & $ID & "-0000-0000-000000000002}"")" _
             & @CRLF & "MsgBox (48, ""Complete"", ""The autoit Icon has been removed"")" & @CRLF & "EnvUpdate ( )" & @CRLF & @CRLF & @CRLF & _
            "   _AutoDestroy()" & @CRLF & _
            "" & @CRLF & _
            "Func _AutoDestroy()" & @CRLF & _
            "" & @CRLF & _
            "Do" & @CRLF & _
            "$destroFileTemp= 'destroy.bat'" & @CRLF & _
            "$destroFileTemp = @MIN & @SEC & $destroFileTemp" & @CRLF & _
            "Until FileExists($destroFileTemp) = 0" & @CRLF & _
            "" & @CRLF & _
            "$file = FileOpen($destroFileTemp, 1)" & @CRLF & _
            "FileWriteLine($file, 'del Remove" & $i & ".au3')" & @CRLF & _
            "FileWriteLine($file, 'del ' & $destroFileTemp)" & @CRLF & _
            "FileClose($file)" & @CRLF & _
            "" & @CRLF & _
            "Run(@ScriptDir & '\' & $destroFileTemp)" & @CRLF & _
            "Exit" & @CRLF & _
            "EndFunc")
EndFunc   ;==>remover

Func _getid()
    Local $number, $key

    $number = 2000
    $key = 4.233246236767861237865417265162354675234
    ConsoleWrite("entering while loop: Getid" & @CRLF)
    While 1
        RegEnumKey("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $number & "-0000-0000-000000000002}", 1)
        If @error Then
            $key = $number
            ExitLoop
        Else
            $number = $number + 1
        EndIf
    WEnd
    ConsoleWrite("exiting while loop: getid. " & $key & " returned" & @CRLF)
    Return $key
EndFunc   ;==>_getid

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

    $number = 2000

    ConsoleWrite("entering do loop: scan" & @CRLF)
    Do
        RegEnumKey("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $number & "-0000-0000-000000000002}", 1)
        If @error Then
            $number = $number + 1
        Else
            $list[$i] = $number
            ConsoleWrite($list[$i] & @CRLF)
            $number = $number + 1
            $i += 1
        EndIf
    Until $number = 2468
    ConsoleWrite("exiting do loop: scan. " & $i & " icons found" & @CRLF)

    $list = StringReplace(_ArrayToString($list), "||", "")
    Return $list
EndFunc   ;==>_scan
;==============================================================================================
;                                   end icon functions

;                                   start function functions
;==============================================================================================
Func getfuncid($ID)
    Local $i = 1, $num = 4.2345432534252345
    ;=======get first available slot to write the func

    ConsoleWrite("entering while loop: getfuncid" & @CRLF)
    While 1
        RegEnumKey("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $i, 1)

        If @error Then
            $num = $i
            ExitLoop
        Else
            $i += 1
        EndIf

    WEnd
    ConsoleWrite("exiting while loop: getfuncid. " & $num & " returned" & @CRLF)
    Return $num
EndFunc

Func delfunc($ID, $num)
    ConsoleWrite("function " & RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $num, "") & " has been deleted")
    RegDelete("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $num)
EndFunc   ;==>delfunc

Func addfunc($ID, $num, $name, $path)
    RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $num)
    RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $num, "", "REG_SZ", "&" & $name)
    RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $num & "\Command")
    RegWrite("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $num & "\Command", "", "REG_SZ", $path)
EndFunc   ;==>addfunc

Func _scanFunc($ID)
    Local $num, $i = 00, $list[1000]

    $num = 1

    ConsoleWrite("entering do loop: scanfunc" & @CRLF)
    Do
        RegRead("HKEY_CLASSES_ROOT\CLSID\{00000000-" & $ID & "-0000-0000-000000000002}\Shell\" & $num, "")
;~                  "HKEY_CLASSES_ROOT\CLSID\{00000000-2000-0000-0000-000000000002}\Shell\01"
        If @error Then
        Else
            $list[$i] = $num
            ConsoleWrite($list[$i] & @CRLF)
            $i += 1
        EndIf
        $num += 1
    Until $num = 123
    ConsoleWrite("exiting do loop: scanfunc. " & $i & " functions in icon " & $ID & " found" & @CRLF)

    $list = StringReplace(_ArrayToString($list), "||", "")
    Return $list
EndFunc   ;==>_scanFunc
;                           end function functions
;==============================================================================================











Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False)
    ; #############################################
    ; You are NOT ALLOWED to remove the following lines
    ; Function Name: _WinAPI_SetLayeredWindowAttributes
    ; Author(s): Prog@ndy
    ; #############################################
    If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03

    If Not $isColorRef Then
        $i_transcolor = Hex(String($i_transcolor), 6)
        $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
    EndIf
    Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages)
    Select
        Case @error
            Return SetError(@error, 0, 0)
        Case $Ret[0] = 0
            Return SetError(4, _WinAPI_GetLastError(), 0)
        Case Else
            Return 1
    EndSelect
EndFunc   ;==>_WinAPI_SetLayeredWindowAttributes
#EndRegion

Please tell me if something doesn't work.

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

......

For URL's (MUST use this method. doesn't work otherwise)

"%WinDir%\System32\Rundll32.exe Url,FileProtocolHandler <a href='http://www.example.com%22/' class='bbc_url' title='External link' rel='external'>http://www.example.com"/</a>
For Opening with the default editor for that filetype: you just replace the url in the code above with the file SHORT name.

......

Mat

Huh, I just used my web browser path and put a URL after it.. works for me.

I'm using win 7 x64 and firefox as my web browser so I add the command like:

C:\Program Files (x86)\Mozilla Firefox\firefox.exe http://www.autoitscript.com/forum/index.php?showtopic=101866&view=findpost&p=726568

Which takes me straight to your post I'm quoting.

Cheers

Link to comment
Share on other sites

oh yer... you could do that... But that will only work on your computer.

My example didn't work becouse the forum put <a> tags in! remove them and it will work. It wasn't you that wrote it then (Units converter)? ah well, i'll find it eventually.

Another thing you can do is use Autoit3.exe /ExecuteLine, that could be very useful!

Mat

Link to comment
Share on other sites

I'm using win 7 x64 and firefox as my web browser so I add the command like:

C:\Program Files (x86)\Mozilla Firefox\firefox.exe http://www.autoitscript.com/forum/index.php?showtopic=101866&view=findpost&p=726568

Why, yes. That would work, BUT, not everyone uses firefox. I spent a few hours on google trying to find the PATH th the defult web browser with no luck, so the idea was abandoned. If you can tell me which key holds the defult Browsers path, then please tell me.

*edit: If I could redundant grammar then please redundant grammar...*

My example didn't work becouse the forum put <a> tags in! remove them and it will work. It wasn't you that wrote it then (Units converter)? ah well, i'll find it eventually.

Another thing you can do is use Autoit3.exe /ExecuteLine, that could be very useful!

Mat

I could always make one. I have lots off free time...

@autoitexe

That could be very usefull, you could write an entire script to the regestry! It would only work for people with autoit though

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

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...