-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeypressTest.cpp
More file actions
28 lines (20 loc) · 838 Bytes
/
keypressTest.cpp
File metadata and controls
28 lines (20 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <CoreFoundation/CoreFoundation.h>
#include <ApplicationServices/ApplicationServices.h>
#include <Carbon/Carbon.h>
void performUpKeyAction( unsigned short keyCode )
{
// Create a keyboard event for the up arrow key press
CGEventRef event = CGEventCreateKeyboardEvent(NULL, keyCode, true);
// Post the key press event
CGEventPost(kCGSessionEventTap, event);
// Release the event
CFRelease(event);
}
int main()
{
performUpKeyAction( kVK_ANSI_C ); // Call the function to perform the up key action
return 0;
}
/*
cd "/Users/wanda/Desktop/Eason_C++_學習/c++code/project/tetrisA/" && g++ keyPressTest.cpp -o keyPressTest -framework CoreFoundation -framework CoreGraphics -framework ApplicationServices && "/Users/wanda/Desktop/Eason_C++_學習/c++code/project/tetrisA/"keyPressTest
*/