I am not sure why it isn't working

  • Thread starter Thread starter Weeke
  • Start date Start date
W

Weeke

Guest
Ok, so i have CLR form and i am using checkboxes to enable features. I am trying to control mouse movements, So when a certain checkbox is checked and mouse1 is pressed and rbutton is pressed move mouse on x y cord a certain way. I already have that working on a console application but i am trying to get it to work on checkboxes in a form. When i check the checkbox and try pressing the two buttons my cursor doesnt move at all. I have tried using while loops with no success.

So here is an example

boolean mousePressed() {
if (GetKeyState(VK_LBUTTON) & 0x8000)
return true;
else
return false;
}

boolean ctrlPressed() {
if (GetKeyState(VK_LCONTROL) & 0x8000)
return true;
else
return false;
}

boolean rbPressed() {
if (GetKeyState(VK_RBUTTON) & 0x8000)
return true;
else
return false;
}

This is how i am getting the mouse button pressed info.

This is the Assault rifle checkbox

private: System::Void assaultRifle_checkBox_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
{
if (assaultRifle_checkBox->Checked)
{
DoAssaultRifle();
}
}

This is the code for the assault rifle

void DoAssaultRifle()
{
int ak47crouchedOffsetY[30] = { 58 ,56, 50,46 ,40,26,24,34,16,12,14,16,36,34,42 ,46 ,36 ,40 ,30 ,20 ,16 ,8 ,8 ,12,26,0,0,0,0,0 };
int ak47crouchedOffsetX[30] = { -41,5 ,-60,-52,0 ,20,28,46,58,48,52,30,28,-8,-20,-30,-52,-54,-60,-56,-52,-44,-42,18,0 ,0,0,0,0,0 };
Weapon ak47crouched = Weapon(120, 30, ak47crouchedOffsetY, ak47crouchedOffsetX);

int ak47standingOffsetY[30] =
{ 68 ,56, 50,46 ,40,26,24,34,16,12,14,16,36,34,42 ,46 ,36 ,40 ,30 ,20 ,16 ,8 ,8 ,12,26,8,8,8,8,8 };
int ak47standingOffsetX[30] = { -41,6 ,-60,-52,0 ,20,28,46,58,48,52,30,28,-8,-20,-30,-52,-54,-60,-56,-52,-44,-42,18,5 ,5,5,5,5,5 };
Weapon ak47standing = Weapon(120, 30, ak47standingOffsetY, ak47standingOffsetX);

if (assaultRifle_checkBox->Checked)
{
if (rbPressed() && mousePressed() && ctrlPressed() == true) {
Weapon actualWeapon = ak47crouched;

recoil_ControlSystem(actualWeapon);
}
else if (rbPressed() && mousePressed()) {
Weapon actualWeapon = ak47standing;

recoil_ControlSystem(actualWeapon);
}
else {
bulletNr = 0;
restX = 0;
restY = 0;
}
}
}

This is what i am using to control the mouse

int bulletNr = 0;
int divider = 10;
int restX = 0;
int restY = 0;

void macro(Weapon weapon) {
Sleep(weapon.sleepTime);
INPUT input;
input.type = INPUT_MOUSE;
input.mi.mouseData = 0;
input.mi.time = 0;
input.mi.dx = weapon.offsetX[bulletNr];
input.mi.dy = weapon.offsetY[bulletNr];
input.mi.dwFlags = MOUSEEVENTF_MOVE;
SendInput(1, &input, sizeof(input));
bulletNr++;
}

void recoil_ControlSystem(Weapon weapon) {
INPUT input;
input.type = INPUT_MOUSE;
input.mi.mouseData = 0;
input.mi.time = 0;
input.mi.dwFlags = MOUSEEVENTF_MOVE;

for (int i = 1; i <= divider; i++) {
Sleep(weapon.sleepTime / divider);
input.mi.dx = weapon.offsetX[bulletNr] / divider;
input.mi.dy = weapon.offsetY[bulletNr] / divider;

restX += weapon.offsetX[bulletNr] % divider;
restY += weapon.offsetY[bulletNr] % divider;
if (restX >= 10) {
restX -= 10;
input.mi.dx++;
}
if (restY >= 10) {
restY -= 10;
input.mi.dy++;
}

SendInput(1, &input, sizeof(input));
}
bulletNr++;
if (bulletNr > weapon.capacity)
bulletNr = 0;
}

Any ideas or advice would be greatly appreciated. Thanks.

Continue reading...
 
Back
Top