Jump to content

what is wrong with this script _associate


camilla
 Share

Recommended Posts

hello everybody, as you see i'm newbie and i'm learning about autoit commands such as " Associate file type"

i did thid script , but it didn't work for me

 

 

;I am learning
_Associate (".jpg", "JPGFile", "%1")

Func  _Associate($EXT , $FileType, $FileName)

RegWrite ("HKCR" & $EXT & "", $FileType)
RegWrite ("HKCR" & $FileType & "", "MY file")
RegWrite ("HKCR" & $FileType & "DefaultIcon", $FileName)
RegWrite ("HKCR" & $FileType & "shellopencommand", $FileName & " %1")
EndFunc

it didn't change anything, while this code

 

RegWrite('HKCR.jpeg', '', 'REG_SZ', 'jpegfiles')
RegWrite('HKCRjpegfilesshellopencommand', '', 'REG_SZ', "%1")

works but the icon of the changed extension does not appear as an jpg icon

i want to keep the same icon ,but run any changed exe to jpj

thank you in advance

Link to comment
Share on other sites

In my signature there is a UDF called _ShellFile().

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

 

AZJIO

it doesn't work

 

In my signature there is a UDF called _ShellFile().

not like this

i will explain more

i did it and associate the "jpg" extension to "exefile" and i can run any exe file after changing it's extention to "jpg" , but the problem is in the icon of the changed

"exe" it doesn't appear as an icon of jpg  file that's it

i just want to fix the problem of the icon association

Link to comment
Share on other sites

camilla

i just want to fix the problem of the icon association

1. I'm not sure that is supported jpg. Try ico, dll.
2.

; engine
; http://www.autoitscript.com/forum/topic/70433-rebuild-shell-icon-cache/page__view__findpost__p__531242
_RebuildShellIconCache() ; only WinXP

3.

DllCall("shell32.dll", "none", "SHChangeNotify", "long", '0x8000000', "uint", '0x1000', "ptr", '0', "ptr", '0')
Link to comment
Share on other sites

i can rewrite my question like this

create new file type extension Example (tmpx) with the icon of a (jpeg)?

by means the system any OS will show (tmpx) exactly as a (jpeg) file. after associating the extension to it

Edited by camilla
Link to comment
Share on other sites

Just out of curiosity, why do you want to make an icon look like it is something that it isn't?  That example of renaming an EXE to JPG, to look like a JPG, but still execute is a little worrisome to me.

Link to comment
Share on other sites

do not worry this is just a test in my machine i mean OS and as  i said i'm just learning

i get this idea and try to make it .. i don't know about how to use dll files i want to see if i can add a new file extension with any icon example jpg icon

if you can help post an answer

Link to comment
Share on other sites

You can try looking at this article.

http://www.winhelponline.com/blog/change-file-type-icon-windows-7-vista/

I can't guarantee that it will work on XP also.  Since they handle a lot of things differently, there is often no one size fits all solution.

Link to comment
Share on other sites

 

thank you for your answer,but i want to do that through an autoit script i posted here

i did this but it doesn't help

 

RegWrite('HKCR.tmpx', '', 'REG_SZ', 'tmpxfile')

RegWrite('HKCRtmpxfileDefaultIcon' "", "REG_SZ",  "c:icon.ico ,1");icon.ico is an jpeg ico

RegWrite('HKCRtmpxfileshellopencommand', '', 'REG_SZ', "%1")

 

any idea?

Link to comment
Share on other sites

The article I referenced gives you the registry entries that need to be made.  You just need to put it into RegRead and RegWrite statements.

If you read the article, and the help file on RegRead and RegWrite, I am sure you will figure it out.  You won't learn anything if I do it for you.

Link to comment
Share on other sites

 

Note: If the DefaultIcon key does not exist by default, you need to create it manually.

7. In the right-pane, double-click (default) and mention the path to your custom icon (.ico file or reference to an icon resource from a EXE/DLL file)

 

i think i did it in the script above

 

RegWrite('HKCRtmpxfileDefaultIcon' ,"", "REG_SZ",  "c:icon.ico ,1");icon.ico is an jpeg ico

 

but nothing changed

Link to comment
Share on other sites

You have a space between .ico and the comma, which may make a difference?

And have you tried another number other than '1' after the comma?

Perhaps it needs to be zero '0'

Where did you get the icon file from?

Is it a legitimate icon file, as recognized by Windows?

Try another file, a Windows one, that you know has icon images in it (i.e. dll or exe).

I presume you've pre-tested things manually, before using code to do it for you?

In some of your code in posts above, I see the odd missing key, value or comma, etc.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

  • Developers

do not worry this is just a test in my machine i mean OS and as  i said i'm just learning

i get this idea and try to make it .. i don't know about how to use dll files i want to see if i can add a new file extension with any icon example jpg icon

if you can help post an answer

We do worry when things could be used in a malicious way!

So please keep that in mind when having these type of questions,

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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