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 :)
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()