我对c很新,并且想知道是否有任何可以协助我正在进行的项目 .
在我的代码中,我正在从一个文件中收集信息,该文件包含该程序的信息,然后是当该信息的标准为真时发送的密钥 .
提出一个想法,这是我的文件的样子:
0 0 1 0 235 10 0x21 PG_UP name1
1 0 1 0 260 10 0x22 PG_DN name2
2 0 1 1 235 55 0x23 END name3
3 1 1 1 10 10 0x51 Q name 4
4 1 1 1 35 10 0x57 W name 5
由于列表长度并不总是相同,我的代码使用它来将信息收集到内存中
string pkey, spell;
int entnum, state, movable, gcd, coordx, coordy, key;
while(WorkingFile >> entnum >> state >> movable >> gcd >> coordx >> coordy >> key >> pkey >> spell)
{
BIntVector.push_back(entnum);
BIntVector.push_back(state);
BIntVector.push_back(movable);
BIntVector.push_back(gcd);
BIntVector.push_back(coordx);
BIntVector.push_back(coordy);
BIntVector.push_back(key);
AIntVector.push_back(BIntVector);
BIntVector.clear();
BStringVector.push_back(pkey);
BStringVector.push_back(spell);
AStringVector.push_back(BStringVector);
BStringVector.clear();
}
BIntVector.push_back(key);
用于收集密钥Hex,以便稍后在代码中输入发送密钥语句,具体取决于是否满足其他条件,这就是开始时0 's and 1'的原因 . 字符串值仅用于将内容打印到屏幕上 .
现在我在网上发现这个代码能够做 SendInput()
,当键值存储为int时似乎工作正常但是当我尝试从文本文件中取Hex值时程序崩溃,如果值为's not able to store that as an int. However my code below won' t编译除了int之外还有其他东西 . 我没有't make this code below for the send input, which is why I'我不知道为什么它简单但我不知道sendkey中发生了什么()
int k = 0;
k = AIntVector[0][6];
int sendkey()
{
INPUT ip;
ip.type = INPUT_KEYBOARD;
ip.ki.wScan = 0;
ip.ki.time = 0;
ip.ki.dwExtraInfo = 0;
ip.ki.wVk = k;
ip.ki.dwFlags = 0;
SendInput(1, &ip, sizeof(INPUT));
ip.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &ip, sizeof(INPUT));
}
任何帮助都会很精彩,谢谢 .