Actually I had a helpful suggestion for everyone to make on-screen keyboard enable in python for any operating system. Please review the code I used recently in a project:
Library:
pip install lib-platform
`def open_keyboard_dialog(self):
global onscreen
onscreen+=1
os_name = platform.system().lower()
if os_name == 'darwin':
cmd = [" /System/Library/Input Methods/KeyboardViewer.app/Contents/MacOS/KeyboardViewer" if onscreen%2!=0 else "killall KeyboardViewer"]
subprocess.Popen(
cmd[0],
stdout=subprocess.PIPE,
stderr=None,
shell=True,
)
elif os_name == 'windows':
cmd = ["osk" if onscreen%2!=0 else " "]
subprocess.Popen(
cmd[0],
stdout=subprocess.PIPE,
stderr=None,
shell=True,
)
elif os_name == 'linux':
cmd = ["onboard" if onscreen%2!=0 else "killall onboard"]
subprocess.Popen(
cmd[0],
stdout=subprocess.PIPE,
stderr=None,
shell=True,
)`
I tried this & its helpful for almost any plateform.
New contributor
Uzaif Ahmed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.