本文介绍了从项目中删除windows.h的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在Xcode上编译我原来的visual c ++项目,所以我可以在macOSX上运行它,因为我不能在Xcode / mac中使用windows.h我正在寻找替代方案。
你能给我一些方法来替换这些子程序:
UINT SendString(string str)
{
UINT count = 0;
for(size_t i = 0; i< str.size(); i ++)
{
INPUT input [2];
:: ZeroMemory(input,sizeof(input));
input [0] .type = input [1] .type = INPUT_KEYBOARD;
input [0] .ki.wVk = input [1] .ki.wVk = VkKeyScan(str [i]);
输入[1] .ki.dwFlags = KEYEVENTF_KEYUP;
count + = SendInput(2,input,sizeof(INPUT));
}
返回计数;
}
void SendKey(char key){
keybd_event(VkKeyScan(key),0,0,0);
keybd_event(VkKeyScan(key),0,2,0);
}
void MouseMove(int x,int y)
{
double fScreenWidth = :: GetSystemMetrics(SM_CXSCREEN)-1;
double fScreenHeight = :: GetSystemMetrics(SM_CYSCREEN)-1;
double fx = x *(65535.0f / fScreenWidth);
double fy = y *(65535.0f / fScreenHeight);
INPUT输入= {0};
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
Input.mi.dx = fx;
Input.mi.dy = fy;
:: SendInput(1,& Input,sizeof(INPUT));
}
void MouseClick(字符串按钮,字符串模式){
INPUT输入= {0};
Input.type = INPUT_MOUSE;
if(mode ==down){
if(button ==left){Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;} else if(button ==right){输入。 mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;}
:: SendInput(1,& Input,sizeof(INPUT));
} else if(mode ==up){
:: ZeroMemory(& Input,sizeof(INPUT));
if(button ==left){Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;} else if(button ==right){Input.mi.dwFlags = MOUSEEVENTF_RIGHTUP;}
:: SendInput (1,&安培;输入,的sizeof(INPUT));
}否则if(mode ==both){
if(button ==left){Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;} else if(button ==right){ Input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;}
:: SendInput(1,& Input,sizeof(INPUT));
:: ZeroMemory(& Input,sizeof(INPUT));
if(button ==left){Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;} else if(button ==right){Input.mi.dwFlags = MOUSEEVENTF_RIGHTUP;}
:: SendInput (1,&安培;输入,的sizeof(INPUT));
}
}
ShellExecute(NULL,L打开,Lhttp://google.com,NULL,NULL,SW_SHOWNORMAL);
解决方案
这篇关于从项目中删除windows.h的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!