1

I am using Python (2.4) and trying to simulate a key press (CTRL, SHIFT). But my python is built into a Media application/framework (From Peavey) that allows me to do very basic coding in Python but does not have the capability to install/import any modules, libraries.

So I can't use any of the libraries/modules for key press such as : Keyboard, pyinput, ctype, Win32, wintype etc.

Is there any way to simulate a Keypress without using "import" at the top of the script?

Thank you in advance...

I have tried the following:

import keyboard  # using module keyboard
while True:  # making a loop
    try:  # used try so that if user pressed other than the given key error will not be shown
        if keyboard.is_pressed('q'):  # if key 'q' is pressed 
            print('You Pressed A Key!')
            break  # finishing the loop
        else:
            pass
    except:
        break  # if user pressed a key other than the given key the loop will break

But when executed, it gives me Error stating:

Traceback (most recent call last):
  File "key.py", line 1, in ?
    import keyboard  # using module keyboard
ImportError: No module named keyboard

And I can't import the library when I use the code in production.

sfkhan
  • 53
  • 9
  • Maybe this can help you (but you need to import some library here): https://stackoverflow.com/questions/21905946/python-selenium-how-to-use-browser-shortcuts – Peter Apr 04 '19 at 13:51
  • Maybe you can try copying and modifying some of the functionalities of said lib. It might work, but I do not know whether `dumpkeys` http://man7.org/linux/man-pages/man1/dumpkeys.1.html exist in Peavey. – pnv Apr 04 '19 at 13:59
  • @Peter, I am unable to use any sort of imports unfortunately. Otherwise it would have been a simple to do task.. Thank you for your reply. – sfkhan Apr 04 '19 at 14:01

0 Answers0