Jump to content

opening known file extensions with custom applications


aria
 Share

Recommended Posts

I want to be able to open files with certain extensions by an application other than the default program that is written in the registry. So I thought that if a script can listen for the event of a file open, maybe it can intercept this event & open the file with what I want.

For eg, I like using the Scite text editor, but I am not allowed to change the .txt extension to associate it with Scite. I cant place it on the context menu either. So the above way would be nice.

I searched on the forum, and I got this phrase from a post, but unfortunately I havent found the original post that it referred to.

"....To make a certain extension open with my program i found a script on the forum.

If I set .txt files open with myApp.exe then double click myFile.txt it starts myApp.exe,......"

Can anyone please help? I dont have knowledge of COM objects, but I guess one way is to register a listener for the event of a file being clicked (or being selected & opened by pressing enter on the keyboard) & then getting the file & its extension & then doing the rest.

Thanks!!

:)

Link to comment
Share on other sites

I want to be able to open files with certain extensions by an application other than the default program that is written in the registry. So I thought that if a script can listen for the event of a file open, maybe it can intercept this event & open the file with what I want.

For eg, I like using the Scite text editor, but I am not allowed to change the .txt extension to associate it with Scite. I cant place it on the context menu either. So the above way would be nice.

I searched on the forum, and I got this phrase from a post, but unfortunately I havent found the original post that it referred to.

"....To make a certain extension open with my program i found a script on the forum.

If I set .txt files open with myApp.exe then double click myFile.txt it starts myApp.exe,......"

Can anyone please help? I dont have knowledge of COM objects, but I guess one way is to register a listener for the event of a file being clicked (or being selected & opened by pressing enter on the keyboard) & then getting the file & its extension & then doing the rest.

Thanks!!

:)

Why don't you want to change the registry? It seems like the easiest way.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

>Why don't you want to change the registry? It seems like the easiest way.

I may be working on someone else's computer for a little while, so if I go the registry way, I would have to save the original preferences, then load what I want, and when finished - I would need to to delete mine & rollback to what was present. Instead I would rather go the above way. I just dont know COM, otherwise I am sure its a matter of a few lines of code, correct??

Link to comment
Share on other sites

com is likely barking up the wrong tree. What applications are you trying to utilize?

most apps will support a command line option for specifying what file to load at runtime.

i.e.

try notepad file.txt at the command prompt.... Works equally well with file.bak (assuming both files exist.)

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

alright, let's stick to just one use case - I want to use scite with all text files - be it .ini, .txt, etc. As I wrote - no changes to the registry & no opening of the command prompt.

To be very specific - if I browse different windows folders & try to open any files, the script must intercept this "open" event and pass the flow of control to the script so it does what I want (ie open it with scite, rather than what the default is).

This includes not having to open via the context menu by the right click! So please dont think that I want a menu item on the right click context menu :)

Edited by aria
Link to comment
Share on other sites

I want to use scite with all text files - be it .ini, .txt, etc. As I wrote - no changes to the registry & no opening of the command prompt.

And how do you define what text is?? Is your script going to hard code it, or are you going to use the PersistentHandler --- never mind, you said no registry :)

To be very specific -

Well, if one wants specific answers, and has to control not only accomplishing the task, but also how it gets done, one must be specific, mustn't one?

if I browse different windows folders & try to open any files,

How does this jive with the 'all text files' mentioned earlier??

the script must intercept this "open" event and pass the flow of control to the script so it does what I want (ie open it with scite, rather than what the default is).

google hooking event handlers and see what you find. You find the right function, then you can come back and search the forums for a DllCall() implementation of the function, or provide a code snippet about what problem you're having with AutoIT.

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

>And how do you define what text is?? Is your script going to hard code it,

> or are you going to use the PersistentHandler --- never mind, you said no

> registry

That was just an example. I'll have a config file which defines the mapping of what extensions must open with what applications.

Thus what I meant with the scite example is -

the config file will have a mapping entry of -

"open with scite" mapped to ".txt, .ini, etc"

I can then add or delete extensions in this config file & thus use what application I need to, without touching the registry at all.

Makes sense? If not, please ask!

And thanks for the tip about googling for hooking event handlers - I'll see what I can find : - )

>Just leave Scite open and drag the file to the Scite

> window. That seems the easiest solution to me.

Good thought, except I hate using the mouse...I'm a keyboard fanatic :)

Edited by aria
Link to comment
Share on other sites

That was just an example.

And here I thought we were being specific. Imprecise and conflicting language can introduce confusion.

Good thought, except I hate using the mouse...I'm a keyboard fanatic :)

Hmm. A self described keyboard fanatic, who hates using the mouse finds typing "scite <filename>" so much of a challenge that he must write an event handler so that he can (wait for it) double click A MOUSE to open a file.

ROTFLOL!!!

in fairness, it must be noted that the [enter] key can also execute the default event for a filetype -- though that , of course, is not necessarily an open or edit ;)

Edited by flyingboz

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

hahahaha, I dont doubleclick with the mouse, I have it mapped to the keyboard ;)

But yes, I use the enter key on the keyboard for opening a file. That's a given :)

I got the explorer part to work, but the desktop is a problem because it does not show as the active window in the window list if I use WIN+D to go to the desktop.

The active window is the previous window that was selected before pressing Win+D ;)

I'll clean up the stuff I got running & post it in example scripts in a little while.

Edited by aria
Link to comment
Share on other sites

Hi there, I am trying to write a script that will handle file extensions associations on the fly. Basically it is to open extensions with other applications without writing this to the registry. I started a thread here -

http://www.autoitscript.com/forum/index.php?showtopic=52074

I dont know COM as such, but I wondered if there is a way to get the complete path for a file that is selected either on the desktop or in the windows explorer, when the {ENTER} key is pressed (or the mouse double-clicked on it) to open it.

I came across your search tool (which is so cool), so I thought of asking you.

Thanks!

:)

I'm not very experienced with COM myself... I'm not aware of a way to accomplish what you've just asked... But you could probably get this to work if you created a tiny GUI on to which the user would be able to drag the file's icon on to.. the window will then obtain the path (if crafted to accept files)... Once you have the path you can open it with the program of your choice by execting the program with the file path as the first parameter (most programs support this)... this is off the top of my head.. if i think of anything better, I'll put it up...

Link to comment
Share on other sites

user would be able to drag the file's icon on to.. the window will then obtain the path (if crafted to accept files)

Compiled au3 apps implement the DragDrop Handler -- such that dragging a file onto a compiled script causes the script to be invoked with the filename as a cmdline parameter, no gui necessary.

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

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