-
April 16th, 2018, 04:16 PM
#1
How to insert data into class data que using Custom Mouse Driver ?
As a little personal project, I am trying to move the mouse without using the MOUSE_EVENT function.
I have installed a custom mouse driver (moufiltr) and am trying to use the MouseClassServiceCallback routine.
Code:
VOID MouseClassServiceCallback(
_In_ PDEVICE_OBJECT DeviceObject,
_In_ PMOUSE_INPUT_DATA InputDataStart,
_In_ PMOUSE_INPUT_DATA InputDataEnd,
_Inout_ PULONG InputDataConsumed
);
Would it be possible to use MOUSE_INPUT_DATA to move the mouse ?
I am looking for some examples to learn from, but I have been unsuccessful.
This currently works perfectly :
Code:
void Mouse::click(int ms)
{
mouse_event(MOUSEEVENTF_RIGHTDOWN, int(X), y, 0, 0);
Sleep(ms);
mouse_event(MOUSEEVENTF_RIGHTUP, int(X), y, 0, 0);
}
but I would like to avoid using the MOUSE_EVENT function to achieve the same result.
-
April 17th, 2018, 02:30 AM
#2
Re: How to insert data into class data que using Custom Mouse Driver ?
Originally Posted by TheOne1337
This currently works perfectly :
Code:
void Mouse::click(int ms)
{
mouse_event(MOUSEEVENTF_RIGHTDOWN, int(X), y, 0, 0);
Sleep(ms);
mouse_event(MOUSEEVENTF_RIGHTUP, int(X), y, 0, 0);
}
What did you want to achieve with this code and what do you mean by "works perfectly"?
Originally Posted by TheOne1337
but I would like to avoid using the MOUSE_EVENT function to achieve the same result.
Why "to avoid using the MOUSE_EVENT function"? what is wrong with it?
Victor Nijegorodov
-
April 17th, 2018, 05:22 AM
#3
Re: How to insert data into class data que using Custom Mouse Driver ?
The correct way to do mouse and keyboard input is to use the SendInput api. https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx
-
April 17th, 2018, 10:07 AM
#4
Re: How to insert data into class data que using Custom Mouse Driver ?
Originally Posted by VictorN
What did you want to achieve with this code and what do you mean by "works perfectly"?
Maybe some back ground info about my program will help with the big picture.
I have designed a small "macro" program that helps me to find and right click on a series of drop down menus to "shortcut" myself to an end menu with a single hotkey press.
Eg. when I press "F1" it will search and find Option 2 from menu 1, then option 1 from menu 2, then option 12 from menu 3.
To achieve this, I currently find the image, and have my program move the mouse to the desired X & Y co-ordinates with the MOUSE_EVENT code snippet I attached above.
Originally Posted by Arjay
The correct way to do mouse and keyboard input is to use the SendInput api.
Arjay is right about the correct way to move the mouse being SendInput. (also the easiest and simplest)
Originally Posted by VictorN
Why "to avoid using the MOUSE_EVENT function"? what is wrong with it?
Both Mouse_Event and SendInput leave Injected flags which I am trying to avoid.
I have decided to try and learn how to move the mouse using a mouse filter driver.
I am currently stuck on this part.
Code:
typedef struct _MOUSE_INPUT_DATA {
USHORT UnitId;
USHORT Flags;
union {
ULONG Buttons;
struct {
USHORT ButtonFlags;
USHORT ButtonData;
};
};
ULONG RawButtons;
LONG LastX;
LONG LastY;
ULONG ExtraInformation;
} MOUSE_INPUT_DATA, *PMOUSE_INPUT_DATA;
Any help will be apreciated.
I am desperately searching for a sample program that uses such a method to move the mouse.
I know there are easier / simpler ways of doing this.
Regards.
-
April 17th, 2018, 11:02 AM
#5
Re: How to insert data into class data que using Custom Mouse Driver ?
Originally Posted by TheOne1337
I am currently stuck on this part.
Code:
typedef struct _MOUSE_INPUT_DATA {
USHORT UnitId;
USHORT Flags;
union {
ULONG Buttons;
struct {
USHORT ButtonFlags;
USHORT ButtonData;
};
};
ULONG RawButtons;
LONG LastX;
LONG LastY;
ULONG ExtraInformation;
} MOUSE_INPUT_DATA, *PMOUSE_INPUT_DATA;
you should read the docs related to this struct and MouseClassServiceCallback routine.
Victor Nijegorodov
-
April 17th, 2018, 11:10 AM
#6
Re: How to insert data into class data que using Custom Mouse Driver ?
Originally Posted by VictorN
you should read the docs related to this struct and MouseClassServiceCallback routine.
I have tried. I am fairly new to programing and am limited to no GUI macros atm.
I cann't understand both of them. If i had an example of it in use, i think it would help me to wrap my head around the concept.
any tips will be greatly appreciated.
-
April 17th, 2018, 11:52 AM
#7
Re: How to insert data into class data que using Custom Mouse Driver ?
Originally Posted by TheOne1337
... SendInput leave Injected flags which I am trying to avoid.
What flag do you mean and why are you trying to avoid them?
Victor Nijegorodov
-
April 17th, 2018, 12:23 PM
#8
Re: How to insert data into class data que using Custom Mouse Driver ?
Originally Posted by VictorN
What flag do you mean and why are you trying to avoid them?
MSLLHOOKSTRUCT
these flags. I am trying to avoid them to simulate human input as closely as possible.
can you write a small example using MOUSE_INPUT_DATA for me to study ?
-
April 17th, 2018, 01:20 PM
#9
Re: How to insert data into class data que using Custom Mouse Driver ?
MOUSE_INPUT_DATA structure and MouseClassServiceCallback are used by driver routines - not user-level programs.
[Thread moved to Driver Development]
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
April 17th, 2018, 02:31 PM
#10
Re: How to insert data into class data que using Custom Mouse Driver ?
Originally Posted by 2kaud
MOUSE_INPUT_DATA structure and MouseClassServiceCallback are used by driver routines - not user-level programs.
[Thread moved to Driver Development]
correct me if i am wrong, but user level programs can use MOUSE_INPUT_DATA structure and MouseClassServiceCallback to delete, transform, or insert data via the filter service callback.
Attachment 35213
But the filter driver itself, is not user-level
Last edited by TheOne1337; April 17th, 2018 at 02:33 PM.
Reason: Quote added
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|