I'm rather new to c++ and wondering if any could assist with a project I'm working on.
In my code at the moment I'm gathering information from a file that has information for the program and then a key to send when the criteria of that information is true.
To give an idea, here's what my file looks like:
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
Because the list length isn't always the same, my code uses this to gather the information into memory
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();
}
The BIntVector.push_back(key);
is used to gather the key Hex to input into the send key statement later in the code depending on if other criteria is met, which is the reason for the 0's and 1's at the start. The string values are just used to print things out onto the screen.
Now I found this code online to be able to do SendInput()
, it seems to work fine when the key value is stored as an int but when I try take the Hex value from the text file the program crashes as it's not able to store that as an int. However my code below won't compile if the value is anything other then a int.
I didn't make this code below for the send input, which is why I'm not sure why it's not working or how to get around it.
Maybe it's something simple but I have no idea what's going on within the 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));
}
Any assistance would be wonderful, thank you.