[Python Help] execute python script from keyboard
#1
[Python Help]

im wondering if someone can pls help me perform some task?

i really want to map a dos command to a remote button, but for the sake os experiment, im testing with keyboard input from keymap.xml

ive inserted the following into keymap.xml under keyboard actions;

<one>
"C:\Program Files\XBMC\system\notepad.py"
</one>

my notepad.py has the following text

import sys
import os

os.system(r"C:\Documents and Settings\Damien\Desktop\Notepad++\ansi\notepad++.exe")

now it seems to me that xbmc reacts to my number 1 button on keyboard, as mouse pointer disappears for a second . However, i cant work out how to trigger the python script?

thanks in advance any help,
Dam0
Reply
#2
RunScript(script[,args]*)
Always read the XBMC online-manual, FAQ and search and search the forum before posting.
For troubleshooting and bug reporting please read how to submit a proper bug report.

If you're interested in writing addons for xbmc, read docs and how-to for plugins and scripts ||| http://code.google.com/p/xbmc-addons/
Reply
#3
thanks for the reply

when i change the keyboard assignements in keymap to;

<one>
RunScript("C:\Python31\notepad.py")
</one>

it still wont open up my *.exe for me.

[edit] ive installed Python interpreter, and i now kinda have my script running from command prompt.

however, i still seem to have problems with xbmc triggering the *.py

debug log is here

http://pastebin.com/m415cadfd

[/edit]

regards,
Dam0
Reply
#4
bump..

seems my runscript() command doesnt like "" or ' ' in its script filename

thanks in advance,
Dam0
Reply
#5
Dam0 Wrote:<one>
RunScript("C:\Python31\notepad.py")
</one>

Remove the quotes... you may need to place the script into a directory without spaces, and it may need to be python 2.4 compatible (what you have in the first post is fine)
Always read the XBMC online-manual, FAQ and search and search the forum before posting.
For troubleshooting and bug reporting please read how to submit a proper bug report.

If you're interested in writing addons for xbmc, read docs and how-to for plugins and scripts ||| http://code.google.com/p/xbmc-addons/
Reply
#6
with quotes removed, (thanks)

The script runs fine, but i have one more question for you if that ok?

when the script runs, it opens a command prompt that wont close. is there an option to pipe output to null or something, so i dont get the cmd prompt?

regards,
Dam0
Reply
#7
this is getting into regular python and doesn't have anything to do with xbmc specifically, BUT

PHP Code:
from subprocess import Popen
Popen
('pathtoexecutable'+'args'shell=False
Always read the XBMC online-manual, FAQ and search and search the forum before posting.
For troubleshooting and bug reporting please read how to submit a proper bug report.

If you're interested in writing addons for xbmc, read docs and how-to for plugins and scripts ||| http://code.google.com/p/xbmc-addons/
Reply
#8
thanks mate.

i realise is not specific to xbmc.

i tried to google it for ages, but appeared to have no success.

thanks regardless:-)

Dam0
Reply
#9
just like to add that within xbmc

os.popen(r' start dosfilename.exe) will cause xbmc to lockup

whereas the same script when passed through the python 3.1 interpreter runs fine

if i change the cmd to

os.system(r' start dosfilename.exe) then xbmc runs the python script fine

here is a pastebin incase anyone wants to investigate
http://pastebin.com/m140f8d0b

regards,
Dam0
Reply

Logout Mark Read Team Forum Stats Members Help
[Python Help] execute python script from keyboard0