autokey-run =
--
You received this message because you are subscribed to the Google Groups "autokey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to autokey-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/autokey-users/1143cca6-f397-48fb-8bf5-cfd604a7156d%40googlegroups.com.
import osos.system("kitty -e 'bash -c \"exec bash; mousepad; exec bash\" '")
--
You received this message because you are subscribed to the Google Groups "autokey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to autokey-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/autokey-users/2c78850d-2e6b-4992-ae16-ed3eaa83046b%40googlegroups.com.
import subprocesssubprocess.call([ "mousepad"])import timetime.sleep(1.0)keyboard.send_keys("abcdefg")time.sleep(0.2)keyboard.send_keys("<enter>")
import subprocesssubprocess.call([ "mousepad"])import timetime.sleep(1.0)keyboard.send_keys("abcdefg")time.sleep(0.2)keyboard.send_keys("<enter>")
subprocess.call([ "mousepad"])
import subprocesssubprocess.call([ "mousepad"])
import subprocesssubprocess.call([ "xfce4-terminal"])
import timetime.sleep(1.0)keyboard.send_keys("abcdefg")time.sleep(0.2)keyboard.send_keys("<enter>")
import subprocesssubprocess.Popen(["xfce4-terminal"])import timetime.sleep(0.6)keyboard.send_keys("abcdefg")time.sleep(0.3)keyboard.send_keys("<enter>")time.sleep(0.3)keyboard.send_keys("exit")time.sleep(0.3)keyboard.send_keys("<enter>")
Glad it works now.
Most of this stuff is putting one foot in front of the other, so, unlessthere's something like a loop involved, it doesn't lend itself to elegance.
The only thing I would do differently is cosmetic/style. I'd put all theimport statements at the top with a blank line after them because
Just in case it isn't clear: subprocess is one of a great many optionalmodules which extend the capabilities of Python. Each such module
Since Python is an interpreted language, it needs to have everythingyou're using in its symbol table at run time and keeping that symbol
You also don't have togo through thousands of existing function names to make sure one you
--
You received this message because you are subscribed to the Google Groups "autokey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to autokey-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/autokey-users/532a8506-517a-47a6-9933-764b83338daa%40googlegroups.com.
great! i'm glad we've got it working.
i'm surprised you have so many sleeps when just sending keystrokes... are you using a very slow computer? even then, i'm certain that you don't need a sleep after 'import time'.
it's not quite clear what you want to achieve. is this merely an excercise to see that it works? or do you really want to open a terminal, run a command, then close the terminal without seeing any output? if that is what you really want to do then yes, we can make it more elegant
import subprocesssubprocess.Popen(["kitty"])import timekeyboard.send_keys("autorandr --load docked")
time.sleep(0.3)keyboard.send_keys("<enter>")time.sleep(0.3)keyboard.send_keys("exit")time.sleep(0.3)keyboard.send_keys("<enter>")
import subprocesssubprocess.Popen(["kitty"])import timekeyboard.send_keys("autorandr --load mobile")
time.sleep(0.3)keyboard.send_keys("<enter>")time.sleep(0.3)keyboard.send_keys("exit")time.sleep(0.3)keyboard.send_keys("<enter>")
--
if you really just want to open a terminal, run a command, then close the terminal, you could do:
import os
os.system("sh -c abcdefg")
import osos.system("xfce4-terminal -c autorandr --load mobile")
--
You received this message because you are subscribed to the Google Groups "autokey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to autokey-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/autokey-users/7c6ad0cd-f10e-4a25-9c71-0854a851025d%40googlegroups.com.
why do you need the terminal?
what happens if you try:
import os
os.system("sh -c autorandr --load mobile")
import osos.system("sh -c mousepad")
import subprocesssubprocess.Popen(["kitty"])import time
time.sleep(0.5)
keyboard.send_keys("autorandr --load docked")
time.sleep(0.3)keyboard.send_keys("<enter>")time.sleep(0.3)keyboard.send_keys("exit")time.sleep(0.3)keyboard.send_keys("<enter>")
--
You received this message because you are subscribed to the Google Groups "autokey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to autokey-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/autokey-users/78712de9-03e6-4b0d-b54a-1b5cf67cd8d7%40googlegroups.com.
I don't do stuff like this, but part of the problem might be related to
the Linux process not being connected to a display when it runs. If
that's the case, either it won't work or you'd need to explicitly tell
xrandr or autorandr more about what displays it's supposed to be working
with.
That's not something I'm familiar with.
autorandr looks really interesting. I had not seen that before. I'll
have to play with it.
Just to clarify a point: To run a program in Linux, you don't need a
terminal if somebody else (such as subprocess in Python) is available to
launch it. The only real difference is that when you run without a
terminal, the three default files, standard input, standard output, and
standard error don't have anywhere to go and are thrown out.
When things work, this is fine, but when things go wrong, many programs
write warning and error messages to standard error which is displayed in
the parent terminal when one exists. When there's no terminal, these
messages are lost. Also, if the program expects to get input directly
from the keyboard (without using something like a GUI interface
instead), what it gets is an end of file on standard input.
None of this should be an issue in this case. It's just good to know how
basic things like this work.
i'm not reading all the lines... there is no need for a sleep after 'import time', but you may need one after opening the subprocess.
it would be neater to put the import statements together at the top:
import subprocess
import time
subprocess.Popen(["kitty"])
...and so on
regarding autorandr, do you mean that it does not load the configuration that you want, or merely that you can't see the command exectute?
you would not see a terminal, it will just try to run the command. did it actually load the correct configuration?
did it actually load the correct configuration?
--
You received this message because you are subscribed to the Google Groups "autokey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to autokey-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/autokey-users/05416943-6208-4ed3-ae3a-555a9ab6420e%40googlegroups.com.
i'm surprised that autorandr is not working, because it doesn't seem as though it requires any user interaction to load its profile.
but i think that becomes an academic exercise... you have a script that works for you.
Running it in a subprocess and capturing any output or errors might help. But life is too short!
--
You received this message because you are subscribed to the Google Groups "autokey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to autokey-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/autokey-users/688537ee-bfb7-40e8-8205-1d4fc51106c6%40googlegroups.com.
it think you need something like this:
import subprocess
import sys
retcode = subprocess.check_output(["autorandr", "--load mobile"], encoding='UTF-8', stderr=subprocess.STDOUT)
print(retcode)
... but i've never used subprocess... if that fails or i've got it wrong, i'm sure someone who knows more than i do can chip in...
--
You received this message because you are subscribed to the Google Groups "autokey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to autokey-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/autokey-users/52b082e2-1bbf-4691-b551-cde898ad587e%40googlegroups.com.