[英]How can I force cmake to use C++ header files in /usr/include in Linux?
[英]What C++ header can I use for these specific functions ? Linux
我是linux用戶,想使用這些'keyboard_event'函數,但這些函數的標題是'windows.h'而linux沒有'windows.h',所以任何人都可以支持這些函數的替代標題,或模擬Linux按鍵的替代方法?
#include <iostream>
using namespace std;
int main() {
keybd_event(VK_CONTROL,0x9d,0 , 0); //pressing CTRL
keybd_event(VkKeyScan(‘R’),0x93,0 , 0); //pressing 'R'
keybd_event(VkKeyScan(‘R’),0x93,KEYEVENTF_KEYUP,0); //releasing 'R'
keybd_event(VK_CONTROL,0x9d,KEYEVENTF_KEYUP,0); /* releasing CTRL */
return;
}
Linux中的windows.h
沒有“等價”。 你需要逐個修復你的錯誤,或者更好,重寫你的Linux代碼。
我找到了一個解決方案,在代碼中我輸入:
system("xte 'keydown Control_L' 'key R' 'keyup Control_L'");
並且它也是如此,但必須包含<cstdlib>
。
我不知道“keyboard_event”函數是什么,但我想這會有所幫助:
#include <iostream>
#include <cstdio> // for getchar()
#include <unistd.h> // for getch()
#include <termios.h> // for getch()
using namespace std;
int getch();
int main()
{
int ch = getch();
cout << ch << endl;
}
int getch()
{
struct termios oldt, newt;
int ch;
tcgetattr(STDIN_FILENO, &oldt);
newt = oldt;
newt.c_lflag &= ~(ICANON | ECHO);
tcsetattr(STDIN_FILENO, TCSANOW, &newt);
ch = getchar();
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
return ch;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.