Page 1 of 1
How do I run a small external program from Freepie?
Posted: Sat Oct 28, 2017 6:59 pm
by Blamm-0
Suppose I want to have a keyboard key which when pressed once, runs nomousy.exe with a parameter, to hide the mouse cursor:
nomousy.exe /hide
Then I press the key again to run:
nomousy.exe
...which brings the cursor back again. So it's a toggle on-off mouse cursor.
I can't find how to run external programs from Freepie!
Re: How do I run a small external program from Freepie?
Posted: Sun Oct 29, 2017 7:16 am
by Jabberwock
This seems to work:
Code: Select all
import subprocess
if keyboard.getPressed(Key.A):
subprocess.call(['C:\\Windows\\SysWOW64\\calc.exe'])
Re: How do I run a small external program from Freepie?
Posted: Sun Oct 29, 2017 9:05 am
by zelmon64
I didn't know of the subprocess python module so I had a go at adding open and close functions to the window plugin. It can be used like this:
Code: Select all
program = "notepad"
windowopen = False
if starting:
windowopen = window.open(program, r'/A "settings.xml"')
if stopping:
windowopen = window.closeMainWindow(program)
diagnostics.watch(windowopen)
diagnostics.watch(window.getActive)
@Jabberwock do you if adding these functions to the window plugin would have any benefits over the subprocess module?
Re: How do I run a small external program from Freepie?
Posted: Sun Oct 29, 2017 9:29 am
by Jabberwock
I have no idea, as I have just found the code online...
Re: How do I run a small external program from Freepie?
Posted: Mon Oct 30, 2017 10:51 am
by Blamm-0
Thanks both, your ideas have helped me make progress, I'll keep fiddling for a while
Re: How do I run a small external program from Freepie?
Posted: Mon Oct 30, 2017 5:41 pm
by Blamm-0
I'm having trouble. I want to hide the mouse cursor with a toggle hotkey, using a tiny utility called nomousy.exe
Usage: hide cursor -- execute "nomousy.exe /hide"
show cursor again -- execute "nomousy.exe"
Suppose the cursor has been hidden by a successful call of
nomousy.exe /hide
Then, this works in Freepie to unhide the cursor:
import subprocess
if keyboard.getPressed(Key.ScrollLock):
subprocess.call(['C:\\Windows\\SysWOW64\\nomousy.exe'])
But I cannot get Freepie to do the hiding bit successfully, e.g.
subprocess.call(['C:\\Windows\\SysWOW64\\nomousy.exe /hide'])
I have tried many variations of path and syntax, different combos of quotation marks, etc. with no luck. It seems I don't know the right code to add a parameter to a program call. What do you think?
By the way I didn't understand the code about the 'window plugin' because I don't know what the 'window plugin' is, I'm afraid.
I've attached nomousy for your cursor-hiding pleasure!
Re: How do I run a small external program from Freepie?
Posted: Mon Oct 30, 2017 7:16 pm
by Jabberwock
It seems it has to be a list of arguments, so possibly:
subprocess.call(["C:\\Windows\\SysWOW64\\nomousy.exe", "/hide"])
Re: How do I run a small external program from Freepie?
Posted: Mon Oct 30, 2017 7:18 pm
by Jabberwock
There is also this:
http://nullege.com/codes/search/pygame. ... et_visible
but I do not know how to make pygame work with FreePIE.