Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCG/CGEventTapMBS test
Required plugins for this example: MBS MacCF Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCG/CGEventTapMBS test
This example is the version from Wed, 5th Sep 2017.
Project "CGEventTapMBS test.rbp"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class MainWindow Inherits Window
Control Listbox1 Inherits Listbox
ControlInstance Listbox1 Inherits Listbox
End Control
EventHandler Sub Close() if e<>Nil then e.Enabled = False e = nil end if End EventHandler
EventHandler Sub Open() dim tapLocation as Integer = CGEventTapMBS.kCGAnnotatedSessionEventTap dim Place as Integer = CGEventTapMBS.kCGTailAppendEventTap dim Options as Integer = CGEventTapMBS.kCGEventTapOptionListenOnly dim EventMask as Integer = Bitwise.BitOr(_ CGEventTapMBS.kCGEventMaskFlagsChanged, _ CGEventTapMBS.kCGEventMaskKeyDown, _ CGEventTapMBS.kCGEventMaskKeyUp, _ CGEventTapMBS.kCGEventMaskLeftMouseDown, _ CGEventTapMBS.kCGEventMaskLeftMouseDragged, _ CGEventTapMBS.kCGEventMaskLeftMouseUp, _ CGEventTapMBS.kCGEventMaskOtherMouseDown, _ CGEventTapMBS.kCGEventMaskOtherMouseDragged, _ CGEventTapMBS.kCGEventMaskOtherMouseUp, _ CGEventTapMBS.kCGEventMaskRightMouseDown, _ CGEventTapMBS.kCGEventMaskRightMouseDragged, _ CGEventTapMBS.kCGEventMaskRightMouseUp) e = new MyCGEventTapMBS( tapLocation, Place, Options, EventMask) e.l = Listbox1 e.Enabled = true End EventHandler
Property e As MyCGEventTapMBS
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class MyCGEventTapMBS Inherits CGEventTapMBS
EventHandler Function GotEvent(Proxy as Ptr, type as Integer, e as CGEventMBS) As CGEventMBS dim t as string dim i as string Select case e.Type case CGEventMBS.kCGEventKeyDown t = "KeyDown" i = e.UnicodeString case CGEventMBS.kCGEventKeyUp t = "KeyUp" i = e.UnicodeString case CGEventMBS.kCGEventFlagsChanged t = "FlagsChanged" i = hex(e.Flags) case CGEventMBS.kCGEventNull t = "Null" case CGEventMBS.kCGEventLeftMouseDown t = "LeftMouseDown" case CGEventMBS.kCGEventLeftMouseDragged t = "LeftMouseDragged" case CGEventMBS.kCGEventLeftMouseUp t = "LeftMouseUp" case CGEventMBS.kCGEventMouseMoved return e // don't report as this gives a lot of events! t = "MouseMoved" case 8 t = "MouseEnter" case 9 t = "MouseExit" case CGEventMBS.kCGEventOtherMouseDown t = "OtherMouseDown" case CGEventMBS.kCGEventOtherMouseDragged t = "OtherMouseDragged" case CGEventMBS.kCGEventOtherMouseUp t = "OtherMouseUp" case CGEventMBS.kCGEventRightMouseDown t = "RightMouseDown" case CGEventMBS.kCGEventRightMouseDragged t = "RightMouseDragged" case CGEventMBS.kCGEventRightMouseUp t = "RightMouseUp" case CGEventMBS.kCGEventScrollWheel t = "ScrollWheel" case CGEventMBS.kCGEventTabletPointer t = "TabletPointer" case CGEventMBS.kCGEventTabletProximity t = "TabletProximity" case CGEventMBS.kCGEventTapDisabledByTimeout t = "TapDisabledByTimeout" case CGEventMBS.kCGEventTapDisabledByUserInput t = "TapDisabledByUserInput" // ignore some internal events case 13 return e case 14 return e case 15 return e end Select dim ee as string = "Got "+t+" ("+str(type)+") event" if i = "" then l.AddRow ee else l.AddRow ee+": "+i end if return e End EventHandler
Property l As Listbox
End Class
End Project

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacCG Plugin.

MBS FileMaker Plugins