keyboard icon indicating copy to clipboard operation
keyboard copied to clipboard

is it possible to get the output in the active window?

Open jorigel opened this issue 3 years ago • 2 comments

Hi, my script is working so far . . . But I expected the output happens in the active window. In my case it happens in the terminal-window where I started the script. What am I doing wrong? Or is that not possible in such a way calling it? Is it the "print"-order doing this and what can I do about it make it showing up in the active window?

thanx for Ur attention jori

jorigel avatar Jan 22 '22 03:01 jorigel

Hi folks, I'm trying to explain my problem with a little piece of code:

begin import keyboard

keyboard.wait('ctrl+alt+p') keyboard.write('Test') #print('Test') end

I'm expecting a written 'Test' in the active window as soon as the sequence ctrl+alt+p is pressed. The script starts working but ends without writing the text in the active window (it shows up in the window where the script was started if using the print-command instead of keyboard.write but not in the active window).

Anybody able to explain, what I'm doing wrong to solve the problem? jori

jorigel avatar Jan 28 '22 20:01 jorigel

You would probably do that something like this:

import keyboard

def test_func():
    print("Test")
    keyboard.write("Test")

keyboard.add_hotkey("Ctrl+Alt+p", test_func)
keyboard.wait()

But I would expect your program to work assuming you uncomment #print as it should stop waiting and continue after the keyboard.wait call. Tested and it works on my machine (displayed "Test" in both the active text editor and in the console).

freerror avatar Jun 21 '22 07:06 freerror