I have PyQt test application which opens window. I use event filter to disable all gestures on MS Surface for my application. Some guestures (e.g. "Press and hold") are not recognized now, but not all.
If one finger presses the screen and you press a second finger, transparent square appears around the first finger. It looks like the system recognizes a gesture.
Can I disable ALL gesture recognition in Windows only for my application?
@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()
User contributions licensed under CC BY-SA 3.0