micmonay / keybd_event

For simulate key press in Linux, Windows and Mac in golang
MIT License
376 stars 56 forks source link

Compilation fails on macos-11 & macos-12 #44

Open PrabhakarRai opened 2 years ago

PrabhakarRai commented 2 years ago

The code works fine when complied on mac-os-10.15 but doing the same on mac-os-11 and mac-os-12 results in following errors.

keyboard_darwin.go:19:38: error: unknown type name 'CGEventRef'
keyboard_darwin.go:19:20: error: unknown type name 'CGEventFlags'; did you mean 'MPEventFlags'?
keyboard_darwin.go:16:14: error: use of undeclared identifier 'kCGAnnotatedSessionEventTap'
keyboard_darwin.go:15:14: error: unknown type name 'CGEventRef'
keyboard_darwin.go:13:9: error: use of undeclared identifier 'event'
keyboard_darwin.go:12:2: error: use of undeclared identifier 'CGEventRef'
keyboard_darwin.go:11:2: error: unknown type name 'CGEventRef'
keyboard_darwin.go:9:9: error: use of undeclared identifier 'event'
keyboard_darwin.go:8:2: error: use of undeclared identifier 'CGEventRef'
keyboard_darwin.go:7:2: error: unknown type name 'CGEventRef'
keyboard_darwin.go:28:21: could not determine kind of name for C.kCGEventFlagMaskShift
keyboard_darwin.go:33:21: could not determine kind of name for C.kCGEventFlagMaskSecondaryFn
keyboard_darwin.go:34:21: could not determine kind of name for C.kCGEventFlagMaskNumericPad
keyboard_darwin.go:35:21: could not determine kind of name for C.kCGEventFlagMaskNonCoalesced
keyboard_darwin.go:32:21: could not determine kind of name for C.kCGEventFlagMaskHelp
keyboard_darwin.go:29:21: could not determine kind of name for C.kCGEventFlagMaskControl
keyboard_darwin.go:31:21: could not determine kind of name for C.kCGEventFlagMaskCommand
keyboard_darwin.go:30:21: could not determine kind of name for C.kCGEventFlagMaskAlternate
keyboard_darwin.go:27:21: could not determine kind of name for C.kCGEventFlagMaskAlphaShift
keyboard_darwin.go:107:2: could not determine kind of name for C.KeyTap
keyboard_darwin.go:110:13: could not determine kind of name for C.CreateUp
keyboard_darwin.go:85:15: could not determine kind of name for C.CreateDown
keyboard_darwin.go:69:18: could not determine kind of name for C.CGEventRef
keyboard_darwin.go:73:2: could not determine kind of name for C.AddActionKey
monolife commented 1 year ago

Changing the import from #import <Foundation/Foundation.h to #import <Cocoa/Cocoa.h> in the cgo portion at the top of keyboard_darwin.go seems to work. I guess Apple reworked the imports in Cocoa

TangMonk commented 1 year ago

Changing the import from #import <Foundation/Foundation.h to #import <Cocoa/Cocoa.h> in the cgo portion at the top of keyboard_darwin.go seems to work. I guess Apple reworked the imports in Cocoa

wow, it works

tmc commented 1 year ago

@micmonay can you get this refreshed?