Skip to content Skip to sidebar Skip to footer

Closing Osk (tabtip) In Python

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 cod

Solution 1:

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

Post a Comment for "Closing Osk (tabtip) In Python"