LtqxWYEG / ShitStuckToYourMouse

Draws mouse-cursor-following particles, text, cursor coordinates, color of pixel under cursor, pictures or a clock - for when you really need to keep an eye on the time. Uses PyGame for low resource usage. Works by creating a transparent full-screen window that is click-through, on top of the z-order.
18 stars 1 forks source link

Subprocesses... #2

Closed PySimpleGUI closed 4 weeks ago

PySimpleGUI commented 2 years ago

I see you're using POpen... I need to check out those parameters you're using as some of them I don't have in the PySimpleGUI Exec API calls and think perhaps I should.

Thanks for showing me some additional use cases that I've not yet seen. Nicely done!

image

LtqxWYEG commented 2 years ago

Oh, thank you. :) And I thought there was an issue with my program haha

Yea I added one recently, cwd:getcwd(). (GetCurrentWorkingDirectory) I needed that for my cython-compiled tests. But apparently that isn't necessary with pyinstalller compiled exes. I don't understand. :)

PySimpleGUI commented 2 years ago

I was looking at the differences in our code for the subprocessing, and I believe you'll be able to simply swap out your Popen for the PySimpleGUI Exec call.

I ran some tests and the result appears to be the same. Maybe I'm missing something as I'm no expert in the subprocessing module nor how you're using it. I just did some quick tests.

PySimpleGUI commented 2 years ago

I should have noted that I ran into this error when trying to use Popen with the same kinds of parms you're using:

  File "X:\Python\python3.9\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "X:\Python\python3.9\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
OSError: [WinError 193] %1 is not a valid Win32 application

I found a discussion on SO about this error. The easy "Fix" is to set shell=True, which is what I do in the Exec calls as well.

https://stackoverflow.com/questions/25651990/oserror-winerror-193-1-is-not-a-valid-win32-application

The way I deal with this in the Exec APIs is that I have a call specifically for executing Python files. As one answer points out, the error says that the parm being passed in is not a valid Win32 application, which is true.

image

LtqxWYEG commented 2 years ago

I never encountered that error. And I remember there WAS a reason why it is False in my program. (Needs more comments) Maybe something about the compiled executable. I'll do some tests now... Nope, no idea why. :)