I am working on a program that I want to be able to open files with by double-clicking on the file and choosing “open with…” - name of exported sketch. I know the program can open the files because it opens them just fine when I use the open button that I put into the GUI. I can also open files if I make a shortcut to the exported sketch and drop the file onto it, but it doesn’t do anything when I just double-click the file choosing “open with…” - name of exported sketch. It doesn’t even open the app.
Based on your post, are you using Windows as your OS?
So if I understand correctly, you created some code, you exported it so to get the executable version. Now, you go to your fav file browser, find a file that your program can read and then you try to open by right clicking in the file and selecting the open with… option. However, after selecting your program it does not work. Is this right?
Assume you have your own defined file extension. I did my test using .axx and it is executed with an executable generated by Processing via export. The executable is called openWithDEMO.exe. This is what I did:
Open cmd as administrator. One way is to click start/windows logo, type cmd and then press ctrl+shift+ENTER
Then type assoc .axx=axxFiles
Then type ftype axxFiles=C:\Users\kfrajer\Documents\Processing\CMsketches\untested\openWithDEMO\application.windows64\openWithDEMO.exe %1 %*
Now if I dbl click any .axx app, it opens the axx file with my executable app generated by Processing via export. This was tested in Windows 10. Two more things for you to consider:
In the command prompt, type ftype /? to read some of the documentation related to this process.
I don’t know. I guess it is possible. Probably this is what of the few things that software installers do. They unpacked the files, create proper associations and define uninstallers instructions. You will need to do some reading on your own as I don’t have experience doing this.
You could create a bat file and provide instructions to run it. Remember you need to run this as admin. The instructions provided above were only tested in Win10. You will need to test these instructions in Win 7/8. Lastly, make sure you do proper testing, including managing 32 and 64 bit platforms separately and research in how to undo these changes in case the user needs or wants to remove them.
Yeah, I’ll test it. I think I’ll make a ps1(powershell) script with those commands
and just call it in the setup function of the app. Or since I’m using Inno Script Studio for creating the installers, maybe I can make post-install commands. Thanks for all the help.
That is what I did. My computer is a 64-bit HP computer running Windows 7. I’m not sure what exact version of Windows it is, but I could find out if you needed to know.
I was able to open the file if it was in the same directory as the executable program, but if it was in a different directory; i.e. “documents”, it wouldn’t open them, Not even with the executable’s directory added to the system PATH.
I don’t think it is a bug in Processing as it works in my machine. It might be a bug in the OS. Ok, wait, I shouldn’t be talking bad about Windows. Let me put it in another way. The way I implemented was tested only on Win 10 OS and it is not guaranteed to work in other Windows OSes. I believe you have to do your own research to try to run it properly in Win 7. After all, my attempt above was my own research on my own time.
If I had a Win7 machine, I would give it a try and see if I could figure it out. Unfortunately, I do not own one.
Can you show how you were trying to do this in the command line when running your executable? Also, can you show your code that shows how you handle this file input by the user? For instance, are you using the selectInput() function?