Results 1 to 3 of 3
  1. #1
    asqapro's Avatar
    Join Date
    May 2012
    Gender
    male
    Posts
    228
    Reputation
    18
    Thanks
    1,686
    My Mood
    Tired

    A quick scope + switch macro

    I had this idea earlier today, and tried making it, but ran into difficulties with the quickscoping part. The macro would wait until you left click, stop the left click, then right click. It would wait a period of time for the scope to zoom in (I found a table of zooming times on the AVA forums), then left click, and quickswitch (using any method, like q-q, or 1-2, 1-3, etc).

    I got the quickswitch code down ez, but the quickscope is difficult, because by the time the program registers the left click, so has the game, and it already shoots.

    Here's what I made so far:

    Code:
    #define WINVER 0x0500
    #include <iostream>
    #include <windows.h>
    #include <winable.h>
    
    using namespace std;
    
    void quick_switch(){
        INPUT input;
    
        input.type = INPUT_KEYBOARD;
        input.ki.wScan = 0;
        input.ki.time = 0;
        input.ki.dwExtraInfo = 0;
        input.ki.wVk = 0x51; //Virtual keycode for Q, I'm too lazy to add other methods of quickswitching right now
        SendInput(1, &input, sizeof(INPUT));
    
        Sleep(10);
    
        input.ki.dwFlags = KEYEVENTF_KEYUP;
        SendInput(1, &input, sizeof(INPUT));
    }
    
    void unclick(bool left_or_right){
        INPUT input = {0};
        //input.mi.dwExtraInfo = 0x200;
        input.type = INPUT_MOUSE;
        if(left_or_right){ //if true, it's a left click
            input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
            SendInput(1, &input, sizeof(INPUT));
        }
        else if(!left_or_right){ //false, right click
            input.mi.dwFlags = MOUSEEVENTF_RIGHTUP;
            SendInput(1, &input, sizeof(INPUT));
        }
    }
    
    void click(bool left_or_right){
        INPUT input = {0};
        input.mi.dwExtraInfo = 0x200;
        input.type = INPUT_MOUSE;
        if(left_or_right){
            input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
            SendInput(1, &input, sizeof(INPUT));
        }
        else if(!left_or_right){
            input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
            SendInput(1, &input, sizeof(INPUT));
        }
    }
    
    int scope_speed_milliseconds;
    
    LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam) { //hook for mouse wheel
        PKBDLLHOOKSTRUCT k = (PKBDLLHOOKSTRUCT)(lParam);
    
    
        if(wParam == WM_LBUTTONDOWN){
            unclick(true); //un_click left
            click(false); //click right
            unclick(false); //un_click right
            Sleep(scope_speed_milliseconds - 20); //wait for the scope to zoom
            click(true); //click left
            unclick(true); //un_click left
            quick_switch(); //quick switch using Q
            Sleep(15);
            quick_switch(); //switch back to main weapon
        }
        return CallNextHookEx(0, nCode, wParam, lParam);
    }
    
    MSG msg;
    
    int main(){
        bool active = true;
        float scope_speed_seconds;
        //int scope_speed_milliseconds; //commented out to make global for mouse hook
        cout << "Scope speeds:" << endl;
        cout << "0.12s: Mosin Nagant Basic Scope, AWM Precision Scope" << endl;
        cout << "0.14s: FR-F2 Sharpshooter Scope, ASW.338 Quick Scope II, AWM Basic Scope, DSR-1 Quick Scope 2, Blaser R93 Sharpshooter Scope" << endl;
        cout << "0.16s: ASW.338 Sharpshooter Scope II" << endl;
        cout << "0.18s: ASW.338 Basic Scope" << endl;
        cout << "0.20s: M24 Basic Scope, SV98 Precision Scope, FR-F2 Basic Scope, DSR-1 Basic Scope, PGM.338 Precision Scope, Blaser R93 Precison Scope" << endl;
        cout << "0.21s: SV98 Basic Scope" << endl;
        cout << "0.22s: Blaser R93 Basic Scope, FR-F2 Quick Scope, DSR-1 High Powered Scope 2" << endl;
        cout << "0.30s: TPG1 High Powered Scope, PGM.338 High Powered Scope" << endl;
        cout << "0.34s: TPG1 Basic Scope, PGM.338 Basic Scope" << endl << endl;
    
        cout << "Enter your scope speed in seconds: ";
        cin >> scope_speed_seconds;
    
        scope_speed_milliseconds = scope_speed_seconds * 1000; //Sleep() takes milliseconds
    
        //HHOOK mousehook = SetWindowsHookEx(WH_MOUSE_LL, MouseHookProc, NULL, 0);
        //SetTimer(NULL, 1, 5, (TIMERPROC) &MouseHookProc); //commented out while not in use
    
        while(true){
            while(active){
                if((GetKeyState(VK_LBUTTON) & 0x80) != 0){ //if the left mouse button is pressed
                    unclick(true); //un_click left
                    click(false); //click right
                    unclick(false); //un_click right
                    Sleep(scope_speed_milliseconds - 20); //wait for the scope to zoom
                    click(true); //click left
                    unclick(true); //un_click left
                    quick_switch(); //quick switch using Q
                    Sleep(15);
                    quick_switch(); //switch back to main weapon
    
                }
            }
            //if(GetMessage(&msg, NULL, 0, 0)){
            //    TranslateMessage(&msg);
            //    DispatchMessage(&msg);
            //}
        }
        return 0;
    }
    Simple stuff, catching clicks and sending them. I was trying to make a mouse hook, but it did worse than just using GetKeyState(). I don't do injection hacks, but if someone could inject code into the game to allow this program to grab the left click before the game registers it, this could work. Quickscoping like this may not be very effective, but it's worth a shot.

  2. The Following User Says Thank You to asqapro For This Useful Post:

    MarvLie (03-12-2014)

  3. #2
    MarvLie's Avatar
    Join Date
    Jun 2012
    Gender
    female
    Posts
    494
    Reputation
    16
    Thanks
    1,303
    My Mood
    Tired
    Dude thanks you gave me an awesome idea to fix a bug in my quickswitch

    and now i'm gonna help you let the user of this macro use mousewheelbutton to shoot so if they klick the left mousebutton your programm klicks the right button go sleep and press the middlemouse button to shoot i may will give you credits for the quickscope idea if i add it to my macro :P
    Last edited by MarvLie; 03-12-2014 at 01:53 AM.

  4. The Following User Says Thank You to MarvLie For This Useful Post:

    asqapro (03-12-2014)

  5. #3
    asqapro's Avatar
    Join Date
    May 2012
    Gender
    male
    Posts
    228
    Reputation
    18
    Thanks
    1,686
    My Mood
    Tired
    Oh man, I don't know how I didn't think of that XD Thank you so much, I'm gonna finish this quick

Similar Threads

  1. {REQUEST} Auto Quick Scope
    By maspareven in forum Combat Arms Mod Discussion
    Replies: 6
    Last Post: 01-29-2010, 06:11 AM
  2. Quick Scope Hack/Cheating Tool ~ for SNIPERS
    By cruel12 in forum Call of Duty Modern Warfare 2 Help
    Replies: 2
    Last Post: 01-01-2010, 05:46 AM
  3. [Tutorial] Call of duty quick scope
    By ***crossfire*** in forum Call of Duty 4 - Modern Warfare (MW) Hacks
    Replies: 4
    Last Post: 11-11-2009, 05:01 PM
  4. [Discussion] crossfire quick scope!!!!!!
    By ***crossfire*** in forum CrossFire Hacks & Cheats
    Replies: 15
    Last Post: 10-25-2009, 03:47 AM
  5. QUick scope tutorial
    By ***crossfire*** in forum Combat Arms Discussions
    Replies: 7
    Last Post: 10-24-2009, 12:53 AM