How do I run a small external program from Freepie?

Official forum for open source FreePIE discussion and development.
Post Reply
Blamm-0
One Eyed Hopeful
Posts: 6
Joined: Sat May 30, 2015 4:28 pm

How do I run a small external program from Freepie?

Post 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!
Jabberwock
Cross Eyed!
Posts: 197
Joined: Mon Mar 02, 2015 3:58 pm

Re: How do I run a small external program from Freepie?

Post by Jabberwock »

This seems to work:

Code: Select all

import subprocess

if keyboard.getPressed(Key.A):
	subprocess.call(['C:\\Windows\\SysWOW64\\calc.exe'])
User avatar
zelmon64
Cross Eyed!
Posts: 134
Joined: Thu Apr 09, 2015 4:27 am

Re: How do I run a small external program from Freepie?

Post 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?
You do not have the required permissions to view the files attached to this post.
Jabberwock
Cross Eyed!
Posts: 197
Joined: Mon Mar 02, 2015 3:58 pm

Re: How do I run a small external program from Freepie?

Post by Jabberwock »

I have no idea, as I have just found the code online...
Blamm-0
One Eyed Hopeful
Posts: 6
Joined: Sat May 30, 2015 4:28 pm

Re: How do I run a small external program from Freepie?

Post by Blamm-0 »

Thanks both, your ideas have helped me make progress, I'll keep fiddling for a while
Blamm-0
One Eyed Hopeful
Posts: 6
Joined: Sat May 30, 2015 4:28 pm

Re: How do I run a small external program from Freepie?

Post 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!
You do not have the required permissions to view the files attached to this post.
Jabberwock
Cross Eyed!
Posts: 197
Joined: Mon Mar 02, 2015 3:58 pm

Re: How do I run a small external program from Freepie?

Post by Jabberwock »

It seems it has to be a list of arguments, so possibly:

subprocess.call(["C:\\Windows\\SysWOW64\\nomousy.exe", "/hide"])
Jabberwock
Cross Eyed!
Posts: 197
Joined: Mon Mar 02, 2015 3:58 pm

Re: How do I run a small external program from Freepie?

Post 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.
Post Reply

Return to “FreePIE”