2

I don't know if this has been answered somewhere on here or not but I can't really find anything that has helped me.

Anyway, I am working with PyQt5 on windows and I created a custom URI scheme that opens my app and then the app parses the command arguments and then does the needed processing. Everything is working as expected but I am trying to figure out how to make everything open in the same app instance.

For example, if I have several custom links such as

foo://bar
foo://bar2
foo://bar3

How can I make them all open in the same instance without opening a new app each time they are executed?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Richard
  • 445
  • 1
  • 5
  • 21
  • No, it's just a Qwidget window that opens when a link is clicked and then parses the command argument and sends then sends off the data to a Qthread for processing. I am thinking maybe I need to do something more with the windows registry keys but I wanted advice. This is the command that is set in the registry that executes the app @="\"C:\\testapp\\testapp.exe\" \"%1\"" – Richard May 29 '18 at 02:36
  • To be clear that is how I set the key. This is the actual command set "C:\testapp\testapp.exe" "%1" – Richard May 29 '18 at 02:38
  • I think that this task can not be done by PyQt but by the windows API, so I recommend you not to center your question on the GUI but on the python application and give more emphasis on the windows API. – eyllanesc May 29 '18 at 02:45
  • Alright, I didn't think PyQt would handle this but I wasn't 100% sure so I thought I'd ask before getting further into it. – Richard May 29 '18 at 02:51

1 Answers1

0

In case anyone is interested, I found what seems to be a pretty good solution, at least for what I need. After a lot of looking around I came across this Answer which is using sockets. I altered it a bit to fit my needs and created a client.exe file that I associate with my custom URI scheme now instead of my main app. So instead of using my main app path in the URL Protocol registry key I now use this instead.

"C:\testapp\client.exe" "--data" "%1"

So now when I click a link such as :

foo://bar

The command is ran and opens client.exe and I simply parse the arguments with argparse and then send the data through the socket to my main app. I don't know if there is a better way to do this but it seems to work well for a simple solution.

Richard
  • 445
  • 1
  • 5
  • 21