Jump to content
Sign in to follow this  
Gif

DirSetIcon

Recommended Posts

Gif

Func _DirSetIcon($directory, $IconFileOrShell, $IconNumberOrNothing = 0, $foldertip = '')
    IniWriteSection($directory & "\Desktop.ini", ".ShellClassInfo", "ConfirmFileOp=0" & @CRLF & "NoSharing=1" & @CRLF & "IconFile=" & $IconFileOrShell & @CRLF & "IconIndex=" & $IconNumberOrNothing & @CRLF & "InfoTip=" & $foldertip)
    FileSetAttrib($directory, "S")
    FileSetAttrib($directory & "\Desktop.ini", "+HS")
    If @error Then
        Return 0
        SetError(0)
    Else
        Return 1
    EndIf
EndFuncoÝ÷ ÙìZ^Â+'jëh×6#include "_DirSetIcon.au3"
DirCreate(@DesktopDir &"\dir")
_DirSetIcon(@DesktopDir &"\dir", "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ndpsetup.ico", 0, "Icon example")
Exit

Important: set $IconNumberOrNothing to zero if you are using an icon

Share this post


Link to post
Share on other sites
smashly

Hi,

Edit: forum bug , Valuater posted the correction further down the thread.

Cheers

Edited by smashly

Share this post


Link to post
Share on other sites
Valuater

Hi,

Question about the seterror.

Would the error level be set doing the SetError(0) after Return?

eg you have:

[font=monospace]    If @error Then
        Return 0
        SetError(0)
    Else
        Return 1
    EndIf[/font]oÝ÷ Ù(hºWbµ·ºÚ"µÍÙÛ[[ÛÜÜXÙWHYÜ[Ù]Ü
B][ÙB]B[YËÙÛ

The only reason I ask is because I was under the impression (I've probly got it wrong) if you return then the function is exited from the return point.

I've not really played with setting error level so I was just curious.

Cheers

yes smash you are right

also you could use

Return SetError(0, 0, 0)

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Gif

yes that's right , made a mistake, updated

Func _DirSetIcon($directory, $IconFileOrShell, $IconNumberOrNothing = 0, $foldertip = '')
    IniWriteSection($directory & "\Desktop.ini", ".ShellClassInfo", "ConfirmFileOp=0" & @CRLF & "NoSharing=1" & @CRLF & "IconFile=" & $IconFileOrShell & @CRLF & "IconIndex=" & $IconNumberOrNothing & @CRLF & "InfoTip=" & $foldertip)
    FileSetAttrib($directory, "S")
    FileSetAttrib($directory & "\Desktop.ini", "+HS")
    If @error Then
         SetError(0)
        Return 0
    Else
        Return 1
    EndIf
EndFunc

Share this post


Link to post
Share on other sites
Gif

yes that's right , made a mistake, updated

c2--><!--YzItLSYjNjI7JiM2MDsmIzMzOy0tUm5WdVl5QmZSR2x5VTJWMFNXTnZiaWdtSXpBek5qdGthWEpsWTNSdmNua3NJQ1lqTURNMk8w
bGpiMjVHYVd4bFQzSlRhR1ZzYkN3Z0ppTXdNelk3U1dOdmJrNTFiV0psY2s5eQpUbTkwYUdsdVp5QTlJREFzSUNZak1ETTJPMlp2
YkdSbGNuUnBjQ0E5SUNZak16azdKaU16T1RzcENpQWdJQ0JKYm1sWGNtbDBaVk5sWTNScGIyNG9KaU13TXpZN1pHbHlaV04wCmIz
SjVJQ1poYlhBN0lDWnhkVzkwT3lZak1Ea3lPMFJsYzJ0MGIzQXVhVzVwSm5GMWIzUTdMQ0FtY1hWdmREc3VVMmhsYkd4RGJHRnpj
MGx1Wm04bWNYVnZkRHNzSUNaeGRXOTAKTzBOdmJtWnBjbTFHYVd4bFQzQTlNQ1p4ZFc5ME95QW1ZVzF3T3lCQVExSk1SaUFtWVcx
d095QW1jWFZ2ZER0T2IxTm9ZWEpwYm1jOU1TWnhkVzkwT3lBbVlXMXdPeUJBUTFKTQpSaUFtWVcxd095QW1jWFZ2ZER0SlkyOXVS
bWxzWlQwbWNYVnZkRHNnSm1GdGNEc2dKaU13TXpZN1NXTnZia1pwYkdWUGNsTm9aV3hzSUNaaGJYQTdJRUJEVWt4R0lDWmhiWEE3
CklDWnhkVzkwTzBsamIyNUpibVJsZUQwbWNYVnZkRHNnSm1GdGNEc2dKaU13TXpZN1NXTnZiazUxYldKbGNrOXlUbTkwYUdsdVp5
QW1ZVzF3T3lCQVExSk1SaUFtWVcxd095QW0KY1hWdmREdEpibVp2Vkdsd1BTWnhkVzkwT3lBbVlXMXdPeUFtSXpBek5qdG1iMnhr
WlhKMGFYQXBDaUFnSUNCR2FXeGxVMlYwUVhSMGNtbGlLQ1lqTURNMk8yUnBjbVZqZEc5eQplU3dnSm5GMWIzUTdVeVp4ZFc5ME95
a0tJQ0FnSUVacGJHVlRaWFJCZEhSeWFXSW9KaU13TXpZN1pHbHlaV04wYjNKNUlDWmhiWEE3SUNaeGRXOTBPeVlqTURreU8wUmxj
MnQwCmIzQXVhVzVwSm5GMWIzUTdMQ0FtY1hWdmREc3JTRk1tY1hWdmREc3BDaUFnSUNCSlppQkFaWEp5YjNJZ1ZHaGxiZ29nSUNB
Z0lDQWdJQ0JUWlhSRmNuSnZjaWd3S1FvZ0lDQWcKSUNBZ0lGSmxkSFZ5YmlBd0NpQWdJQ0JGYkhObENpQWdJQ0FnSUNBZ1VtVjBk
WEp1SURFS0lDQWdJRVZ1WkVsbUNrVnVaRVoxYm1NPS0tJiM2MjsmIzYwOyYjMzM7LS1lZw==--><!--eg

ok there's a forum bug , just look at the quotes

EDIT: i ve tryedn editing the first post but i cant...

Edited by c4nm7

Share this post


Link to post
Share on other sites
Valuater

Not sure about that error ... but this should handle it

Func _DirSetIcon($directory, $IconFileOrShell, $IconNumberOrNothing = 0, $foldertip = '')
    IniWriteSection($directory & "\Desktop.ini", ".ShellClassInfo", "ConfirmFileOp=0" & @CRLF & "NoSharing=1" & @CRLF & "IconFile=" & $IconFileOrShell & @CRLF & "IconIndex=" & $IconNumberOrNothing & @CRLF & "InfoTip=" & $foldertip)
    If Not FileSetAttrib($directory, "S") And Not FileSetAttrib($directory & "\Desktop.ini", "+HS") Then Return SetError(0, 0, 0)
    Return 1
EndFunc

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Gif

Something is very messed up with the autoit tags!

i noticed that when i try to reply to a text with autoit tags or edit mine, the words become like before, also the

autoit tags button is not working and the autoit favicon is missing

instead i see an IP.B favicon

something is wrong!

Share this post


Link to post
Share on other sites
Valuater

Something is very messed up with the autoit tags!

I have had the same problem all day

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Gif

I have had the same problem all day

8)

forums are updated to version 2.3.0, seems to be a problem with IP.B v2.3.0

Share this post


Link to post
Share on other sites
MrCreatoR

Nice idea, i think it should have some more error checking :rolleyes: ...

$Ret = _DirSetIcon("C:\Some Dir", @AutoItExe, 0, "Tip Text")

ConsoleWrite($Ret)

Func _DirSetIcon($Dir_Path, $IconFile, $IconIndex=0, $TipText="")
    If Not StringInStr(FileGetAttrib($Dir_Path), "D") Then Return SetError(1, 0, -1)
    Local $DirSetFile
    
    If StringMid($Dir_Path, 2, 1) = ":" Then
        $DirSetFile = $Dir_Path & "\Autorun.inf"
        FileSetAttrib($DirSetFile, "-R")
        IniWrite($DirSetFile, "Autorun", "icon", $IconFile & ", " & $IconIndex)
    Else
        $DirSetFile = $Dir_Path & "\Desktop.ini"
        FileSetAttrib($DirSetFile, "-R")
        IniWrite($DirSetFile, ".ShellClassInfo", "IconFile", $IconFile)
        IniWrite($DirSetFile, ".ShellClassInfo", "IconIndex", $IconIndex)
        IniWrite($DirSetFile, ".ShellClassInfo", "InfoTip", $TipText)
    EndIf
    
    FileSetAttrib($DirSetFile, "+R")
    
    If Not FileSetAttrib($Dir_Path, "S") Then Return SetError(2, 0, 0)
    If Not FileSetAttrib($DirSetFile, "+HS") Then Return SetError(3, 0, 0)
    Return 1
EndFunc

This function also allow to set icon for the drive (the results are seen after renaming the label of drive or restart windows).


 

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

Share this post


Link to post
Share on other sites
Gif

Nice,

using this script you create a pseudo-invisible folder

#include "_DirSetIcon.au3"
DirCreate("C:\tempfile")
DirMove("C:\tempfile", @DesktopDir &"\ ", 0)
_DirSetIcon(@DesktopDir &"\ ", "%SystemRoot%\system32\SHELL32.dll", 51)
Exit

the space here (&"\ ") is not real space,

it's ALT + 255

Share this post


Link to post
Share on other sites
SleepyXtreme

c4nm7 that doesn't work for me, although i do get the invis icon, the directory doesn't copy to have a blank text

Edited by SleepyXtreme

Share this post


Link to post
Share on other sites
Gif

c4nm7 that doesn't work for me, although i do get the invis icon, the directory doesn't copy to have a blank text

create a folder and while renaming it press ALT then 255(only num keys) and release ALT, an invisible symbol should be created and

you can name the folder after this...

also instead of 255 try 0160

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  

×