0

So I made a program in Python and compiled it to .exe. This works fine. What I want is to be able to double click files I created (say with text in them) and open those files with the .exe I compiled and then do something with the files as input.

I figured one way to do this might be to at least get the exact location of the file that is being opened with the .exe so as a first test something like this:

.exe file:

get_location = dirname(realpath(My_Clicked_File))
print get_location

The file clicked will be some random extension so .test or something I made up.

Knut Holm
  • 3,988
  • 4
  • 32
  • 54
Wealot
  • 201
  • 2
  • 9
  • I haven't tried it, but I expect if you make your .exe the default opening program for a particular file type, and double click a file of that type, then its name and path will be available in `sys.argv`. – Kevin Feb 06 '15 at 13:16
  • possible duplicate of [Create registry entry to associate file extension with application in C++](http://stackoverflow.com/questions/1387769/create-registry-entry-to-associate-file-extension-with-application-in-c) – ivan_pozdeev Feb 06 '15 at 13:20
  • I will look into the other post and return if that helped me. Thanks (I couldn't have found that file with my knowledge on what to search :D) – Wealot Feb 06 '15 at 13:23

1 Answers1

1

If you've associated your file extension with your exe, when you double-click on the file its full file path will be passed as the first argument, which you can get from sys.argv in your script.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895