Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (flink, AndrewAMD), 656 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
alternative to mickey.z #464661
03/04/17 12:01
03/04/17 12:01
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Hello,

Since mickey.z is broken with touchpad and touchscreen zooming (as in it continues to stay on the value), I would like to use an alternative. I found this https://msdn.microsoft.com/en-us/library/windows/desktop/ms645617(v=vs.85).aspx on msdn, but cannot get it working. Does anyone have a snippet for this or something similar?
If this is not possible, than I have thought of maybe resetting mickey.z to 0 overtime, but it seems to be readonly.

Re: alternative to mickey.z [Re: Reconnoiter] #464662
03/04/17 12:30
03/04/17 12:30
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
SetWindowsHookEx and checking the WM_MOUSEWHEEL works perfectly fine laugh

Re: alternative to mickey.z [Re: Ch40zzC0d3r] #464665
03/04/17 14:32
03/04/17 14:32
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
But how do you get the compiler to recognize e.g. HHOOK (HHOOK _hook;)? I get errors even while I included stuff like #include <Windows.h> . And stuff like Winuser.h cannot be found.
(I am using this currently as example: https://www.unknowncheats.me/forum/c-and-c/83707-setwindowshookex-example.html)

Re: alternative to mickey.z [Re: Reconnoiter] #464667
03/04/17 15:13
03/04/17 15:13
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Code:
typedef void *HHOOK;

typedef struct tagKBDLLHOOKSTRUCT {
    DWORD   vkCode;
    DWORD   scanCode;
    DWORD   flags;
    DWORD   time;
    ULONG_PTR dwExtraInfo;
} KBDLLHOOKSTRUCT, FAR *LPKBDLLHOOKSTRUCT, *PKBDLLHOOKSTRUCT;



All you need is to open WinUser.h in Visual Studio and rip the structs if you cannot include them.
Acknex has its own Windows.h, alot of windows standard includes are missing.

Last edited by Ch40zzC0d3r; 03/04/17 15:14.
Re: alternative to mickey.z [Re: Ch40zzC0d3r] #464669
03/04/17 16:12
03/04/17 16:12
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Ty, how to fix this line?:
kbdStruct = *((KBDLLHOOKSTRUCT*)lParam);

I get a wrong type error with it.

Re: alternative to mickey.z [Re: Reconnoiter] #464673
03/04/17 17:59
03/04/17 17:59
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
I dont understand why he derefs it at all, you can simply use a pointer directly like this:
Code:
KBDLLHOOKSTRUCT *pKbdStruct = (KBDLLHOOKSTRUCT*)lParam;
pKbdStruct->...


Re: alternative to mickey.z [Re: Ch40zzC0d3r] #464678
03/05/17 12:51
03/05/17 12:51
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Okay thanks seems to work I get the message boxes etc.
For others:

Code:
#define WH_KEYBOARD_LL     13
#define WH_MOUSE_LL        14
#define MB_ICONERROR			0x00000010L

typedef void *HHOOK;

typedef struct tagKBDLLHOOKSTRUCT {
    DWORD   vkCode;
    DWORD   scanCode;
    DWORD   flags;
    DWORD   time;
    long dwExtraInfo;
//    ULONG_PTR dwExtraInfo;
} KBDLLHOOKSTRUCT; //, FAR *LPKBDLLHOOKSTRUCT, *PKBDLLHOOKSTRUCT;

KBDLLHOOKSTRUCT *pKbdStruct;

// Callback function (called when a key is pressed) 
LRESULT __stdcall HookCallback(int nCode, WPARAM wParam, LPARAM lParam) {
    if (nCode >= 0) {
        // the action is valid: HC_ACTION.
        if (wParam == WM_KEYDOWN) {
            // lParam is the pointer to the struct containing the data needed, so cast and assign it to kdbStruct
            pKbdStruct = (KBDLLHOOKSTRUCT*)lParam;
//            kbdStruct = *((KBDLLHOOKSTRUCT*)lParam);
            // a key (non-system) is pressed.
            if (pKbdStruct.vkCode == VK_F1) {
                // F1 is pressed!
                MessageBox(NULL, "F1 is pressed!", "key pressed", MB_ICONINFORMATION);
            }
        }
    }

    // call the next hook in the hook chain. This is nessecary or your hook chain will break and the hook stops
    return CallNextHookEx(_hook, nCode, wParam, lParam);
}

void SetHook() {
    // Set the hook and set it to use the callback function above
    // WH_KEYBOARD_LL means it will set a low level keyboard hook. More information about it at MSDN.
    // The last 2 parameters are NULL, 0 because the callback function is in the same thread and window as the
    // function that sets and releases the hook. If you create a hack you will not need the callback function 
    // in another place then your own code file anyway. Read more about it at MSDN.
    if (!(_hook = SetWindowsHookEx(WH_KEYBOARD_LL, HookCallback, NULL, 0))) { 
        MessageBox(NULL, "Failed to install hook!", "Error", MB_ICONERROR);
    }

}

void ReleaseHook() {
    UnhookWindowsHookEx(_hook);
}


void init_startup () {
    // Set the hook
    SetHook();	
    on_close = ReleaseHook; 
    on_exit = ReleaseHook; 
}



Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1