我有打开窗口的PyQt测试应用程序。我使用事件过滤器为我的应用程序禁用MS Surface上的所有手势。有些客人(例如"按住")现在无法识别,但不是全部。
如果一根手指按下屏幕并按下第二根手指,则第一根手指周围会出现透明方框。看起来系统识别手势。
我是否可以仅在我的应用程序中禁用Windows中的所有手势识别?
@enum.unique
class TABLET(enum.IntEnum):
"""
@see: https://msdn.microsoft.com/en-us/library/windows/desktop/bb969148(v=vs.85).aspx
"""
DISABLE_PRESSANDHOLD = 0x00000001
DISABLE_PENTAPFEEDBACK = 0x00000008
DISABLE_PENBARRELFEEDBACK = 0x00000010
DISABLE_TOUCHUIFORCEON = 0x00000100
DISABLE_TOUCHUIFORCEOFF = 0x00000200
DISABLE_TOUCHSWITCH = 0x00008000
DISABLE_FLICKS = 0x00010000
ENABLE_FLICKSONCONTEXT = 0x00020000
ENABLE_FLICKLEARNINGMODE = 0x00040000
DISABLE_SMOOTHSCROLLING = 0x00080000
DISABLE_FLICKFALLBACKKEYS = 0x00100000
ENABLE_MULTITOUCHDATA = 0x01000000
class EventFilter(QAbstractNativeEventFilter):
def nativeEventFilter(self, event_type, message):
import time
from andy.platform.win32 import WM, MSG, TABLET
if event_type == 'windows_generic_MSG' or event_type == 'windows_dispatcher_MSG':
msg = ctypes.cast(ctypes.c_void_p(int(message)), ctypes.POINTER(MSG))
if msg.contents.message == WM.TABLET_QUERYSYSTEMGESTURESTATUS:
return True, (TABLET.DISABLE_PRESSANDHOLD |
TABLET.DISABLE_PENTAPFEEDBACK |
TABLET.DISABLE_PENBARRELFEEDBACK |
TABLET.DISABLE_TOUCHUIFORCEON |
TABLET.DISABLE_TOUCHUIFORCEOFF |
TABLET.DISABLE_TOUCHSWITCH |
TABLET.DISABLE_FLICKS |
TABLET.DISABLE_SMOOTHSCROLLING |
TABLET.DISABLE_FLICKFALLBACKKEYS |
TABLET.ENABLE_MULTITOUCHDATA)
return False, 0
def main():
app = QApplication([])
event_filter = EventFilter()
app.installNativeEventFilter(event_filter)
w = QWidget()
w.resize(800, 600)
w.move(300, 300)
w.setWindowTitle('Sample')
w.show()
app.exec_()
if __name__ == '__main__':
main()