Jump to content

AutoIT - Associate a file extension to an AutoIT program


 Share

Recommended Posts

Hello everyone! I'm currently working on a small program and I got stuck on a problem. I need to know how to associate a file extension to an AutoIT Program. I've also tried this:

RegWrite("HKEY_CLASSES_ROOT\",".extension","REG_SZ","E:\Program.exe")

, but it does not work. I assume, I need first to register the program into the Registry, before i could associate it to a file extension. Has someone any idea about how can I do this in a right way? 

Thanks in advance!

Link to comment
Share on other sites

8 hours ago, FrancescoDiMuro said:

@Renderer

Take a look at assoc command :)

I have created a small application in AutoIT and i want to assosciate it to a file extension. I have compiled it and put it in E:\Program.exe

Then I tried manually to create a file association in the Registry Editor like bellow:

HKEY_CURRENT_USER\Software\Classes\AppName.file.ext\DefautIcon 
DefaultIcon = E:\Icon.ico
HKEY_CURRENT_USER\Software\Classes\AppName.file.ext\Shell\Open\Command
Command = E:\Program.exe

HKEY_CURRENT_USER\Software\Classes\.ext\(Standard)

(Standard) = AppName.file.ext 

And It does not work. 

 

 

 

Link to comment
Share on other sites

@Renderer Did you even look at the link provided to you about the assoc command in Windows? It works much easier than trying to manipulate the registry, as its intended function is to do it for you.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I have done it. I have managed to create a new extension and to associate it to my AutoIT program. Now I have to make the program recognize when the file is open and eventually get some data from the file and display it into a GUI. To be more specific, let's think about Notepad. It has the "txt" file associated to it. When you open a "txt" file, the data is being displayed in the Notepad app. The same I want to do with my program. At this moment I could create a file extension and associate it to the program I want, but I do not know how to make them fully work together. I hope I brought you a good understanding upon what I mean.

Edited by Renderer
Link to comment
Share on other sites

13 minutes ago, Renderer said:

I hope I brought you a good understanding upon what I want I mean.

Just create a GUI, a menu through which the user can select a file (filtering your custom extension), open it, read it, and pass the content of the file to a Edit/Rich Edit control in your GUI :)

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

 

On 19.1.2019 at 11:42 PM, Nine said:

I find it very intriguing why you always evade on not revealing the extension !

I work on a text editor. I have created a new file extension (.text) in the Registry and associated it to my program.exe. All I want to do is to create a link between the program.exe and the extension (.text) so that the when I open a file.text, it could be fully operated through program.exe. Think about Notepad. You do not need to go to File > Open in order to open a file, you just click the file you want in order to open it and read it. The same I wanted to make for my program. I would be something like: 

click file.text < open through> [program.exe] -> dispaly Content of file.text . In short, the program.exe must be capable to get the content of a file associated to it. 

Link to comment
Share on other sites

Ok, if you want to create a new ext, then you will have to add a new key (like .text),  associate it with a default generic definition then create the new generic definition and associate it the commands you allow it.

Edit : Look at .au3 setup, it is clearly similar

Edited by Nine
Link to comment
Share on other sites

44 minutes ago, Nine said:

Ok, if you want to create a new ext, then you will have to add a new key (like .text),  associate it with a default generic definition then create the new generic definition and associate it the commands you allow it.

Edit : Look at .au3 setup, it is clearly similar

At this moment it looks like that:

Registry:

HKEY_CLASSES_ROOT\TextEditor.text\DefaultIcon\Standard (REG_SZ) : E:\Icon.ico

HKEY_CLASSES_ROOT\TextEditor.text\Shell\ Standard (REG_SZ) : Open

HKEY_CLASSES_ROOT\TextEditor.text\Shell\Open\Command\ Standard (REG_SZ) : "E:\TextEditor.exe" --started-from-file "%1"

TextEditor.exe > code:

global $GUI = GUICreate("Text Editor",550,450)
global $GUI_Edit = GUICtrlCreateEdit("",0,0,550,450)
GUISetState()

while True
    Switch GUIGetMsg()
        Case -3
        ExitLoop
    EndSwitch
WEnd

When I create a file (ex: Sample.text) the TextEditor.exe is opened but it displays "Text Editor" as title and no data into Edit. I guess the main problem is the TextEditor.exe . I need to code it, so that, when I open Sample.text it shows me "Sample.text" as title and the Text inside the Edit. 

 

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