emulation of scroolwheel

Hi guys,

first of all pleas excuse my rather bad English spelling. Well I am searching for a way to emulate a scrollwheel rotation. I need to scroll much more sensitive than the scrollwheel on the mouse does. Unfortunately I can not simply use keyboard emulation of up/down arrows. I've been programming vb.net for some years (hobby) and got to know some nice code in .NET which realises "all my dreams". It makes use of user32.

1
2
3
4
5
6
7
8
9
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Integer) As Short
    Private Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cbuttons As Integer, ByVal dwExtraInfo As Integer)
    Private Const MOUSEEVENT_WHEEL = &H800 'die entscheidende constante [dwFlag]
 
    Dim SCROLLUP As Integer = 120       'Scrollgeschwindigkeit hoch
    Dim SCROLLDOWN As Integer = -120    'Scrollgeschwindigkeit runter
   
    'call:
    'mouse_event(MOUSEEVENT_WHEEL, 0, 0, SCROLLDOWN, 0) 


Unfortunately I am quiet new to Cpp but I have been doing a few basic things with C. But I never came to include more than math.h, stdio.h an so on. So can somebody help me to realise this in C++? The first thing I'm rather sure about is, that I need to include windows.h but that's where my knowlede gets to an end.

So thanks for helping me

greetings from Germany

Michael
The port of that code to C++ is:
1
2
3
4
5
#include <windows.h>

#define SCROLLUP 120
#define SCROLLUP -120
mouse_event(MOUSEEVENT_WHEEL, 0, 0, SCROLLDOWN, 0);


For more information see MSDN documentation:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646260(v=vs.85).aspx
Hi thanks a lot, well unfortunately nothing works. My code:

1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <windows.h>

#define SCROLLUP 120
#define SCROLLDOWN -120

int main(void)
{
using namespace std;
mouse_event(MOUSEEVENT_WHEEL, 0, 0, SCROLLDOWN, 0);
}



Following Errors occure at the line containing:
mouse_event(MOUSEEVENT_WHEEL, 0, 0, SCROLLDOWN, 0);
- Invalid Arguments ' Candidates are: void mouse_event(unsigned long int,unsigned long int,unsigned long int,unsigned long int,unsigned long int) '
- Symbol 'MOUSEEVENT_WHEEL' could not be resolved

In fact I do miss the
Private Const MOUSEEVENT_WHEEL = &H800
but I don't know how to realise that =)

Thanks


Michael

From the MSDN link I posted there is MOUSEEVENTF_WHEEL which is defined as 0x0800

Why don't you read the documentation ? If you do, all of this looks much easier. And also please read what exactly this function do.
Okay I think I need to do this more in detail. But I think I know what this function does - from MSDN: "The mouse_event function synthesizes mouse motion and button clicks". That is exactly what I want to do. I just don't know how to include correctly and how to "call" the function correctly. In my eyes the mous_event() is not resolved. So that's why I get the MOUSEEVENTF_WHEEL not resolved correctly. Is that right? Or did I do a huge mistake using the mous_event() in the main function? I just don't get what I missed ... thx
Last edited on
OH my god - I am a absolute dumb idiot.

1
2
mouse_event(MOUSEEVENT_WHEEL, 0, 0, SCROLLDOWN, 0);   // no good
mouse_event(MOUSEEVENTF_WHEEL, 0, 0, SCROLLDOWN, 0); // works perfectely 


nice one. spent 2 days on a missing "F". That's what I call bad luck. Well thanks a lot for helping me out.
Topic archived. No new replies allowed.