Reputation: 308
I am using following code to show osk
os.system("C:\\PROGRA~1\\COMMON~1\\MICROS~1\\ink\\tabtip.exe")
this code open the osk successfully but when I try to close it using below code
os.system("TASKKILL /F /IM tabtip.exe")
It gives error of
ERROR: The process "TabTip.exe" with PID 10188 could not be terminated.
Reason: Access is denied.
This error is occurring because my script does not have admin rights but I don't understand why would I need it as I started the programs myself and also when normally when I use mouse to close the application it does not demand admin rights. Any idea on how can I solve it ....
Thanks for reading :)
Upvotes: 2
Views: 704
Reputation: 917
I was having this same problem too.
Like you said opening TabTip with os.system("C:\\PROGRA~1\\COMMON~1\\MICROS~1\\ink\\tabtip.exe")
works but it won't open again once minimized.
I found that using os.system('wmic process where name="TabTip.exe" delete'
to stop the keyboard process works.
The keyboard will remain on the screen for some reason until minimized, but it will now pop back up for you when running the process again.
Credit goes to @OmerSS from the comments in this answer: https://stackoverflow.com/a/61326383/4322062
Upvotes: 0
Reputation: 13367
I ended up using comtypes instead of win32com:
import win32gui
from ctypes import HRESULT
from ctypes.wintypes import HWND
from comtypes import IUnknown, GUID, COMMETHOD
import comtypes.client
class ITipInvocation(IUnknown):
_iid_ = GUID("{37c994e7-432b-4834-a2f7-dce1f13b834b}")
_methods_ = [
COMMETHOD([], HRESULT, "Toggle",
( ['in'], HWND, "hwndDesktop" )
)
]
dtwin = win32gui.GetDesktopWindow();
ctsdk = comtypes.client.CreateObject("{4ce576fa-83dc-4F88-951c-9d0782b4e376}", interface=ITipInvocation)
ctsdk.Toggle(dtwin);
comtypes.CoUninitialize()
Upvotes: 2