-
October 20th, 2009, 12:30 AM
#1
Mouse control in Windows
Hi all
I would like to handle mouse in Windows. For instance, I want to have some functions
*** gogtoxy(x,y)
//then mouse go to (x,y), like you use physical mouse move
*** left_click(), right_click()
//then mouse click
Just plain function like this.
Thanks so much
-
October 20th, 2009, 01:00 AM
#2
Re: Mouse control in Windows
To move mouse cursor use SetCursorPos function.
To emulate mouse click, use SendInput. SendInput may be used lso for cursor movement.
-
October 20th, 2009, 01:41 PM
#3
Re: Mouse control in Windows
Originally Posted by Alex F
To move mouse cursor use SetCursorPos function.
To emulate mouse click, use SendInput. SendInput may be used lso for cursor movement.
Can you tell more, about library ang the way to implement.
When we resize the solution of screen display, will the code change or....
Thank you
-
October 20th, 2009, 02:01 PM
#4
Re: Mouse control in Windows
You can get the screen resolution using the function GetDeviceCaps with HORZRES and VERTRES
-
October 20th, 2009, 06:40 PM
#5
Re: Mouse control in Windows
Originally Posted by Coaxecva
Can you tell more, about library ang the way to implement.
When we resize the solution of screen display, will the code change or....
Thank you
You don't need any extra libraries, its functionality that comes with the windows' api.
Just include <windows.h> and you are ready to use SetCurPos()
-
October 23rd, 2009, 12:55 PM
#6
Re: Mouse control in Windows
Sorry, I'm a newbie in trying this fun learning. I found this struct of SetCurPos().
I will try but it can not work.
/*****************************************************/
int SetCurPos (
[InAttribute] IntPtr hwnd,
[InAttribute] int x,
[InAttribute] int y,
[OutAttribute] array<VSIME_ERR>^ perr
)
/////////////////////////////////////////////////////////////////////
HRESULT IVsIME::SetCurPos(
[in] HWND hwnd,
[in] int x,
[in] int y,
[out] VSIME_ERR * perr
);
/*****************************************************/
***I have tried :
#include "windows.h"
int main()
{
int* hwnd;
SetCurPos(hwnd,10,10);
return 0;
}
***It raises an error:
Error 1 error C3861: 'SetCurPos': identifier not found
***I dont know what hwnd is .
Any ones have tried before, instruct me to use it, pls.
Thank you.
-
October 25th, 2009, 11:44 AM
#7
Re: Mouse control in Windows
I have done in Mouse_move
just SetCurPos(10,10); )
But about double click and right click?
And I dont understand clearly this "int* hwnd;"
-
October 25th, 2009, 01:55 PM
#8
Re: Mouse control in Windows
Are you trying to control the mouse position within your application (i.e. the one that you are coding for) or another application?
-
October 26th, 2009, 06:13 AM
#9
Re: Mouse control in Windows
my "control mouse" means that using function control mouse event instead of physical mouse.
I think SetCurPos(10,10); can work on all application so far.
I have found function mouse click (right and left also).
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0); mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
But about double click? Need your help!!!
-
October 26th, 2009, 06:26 AM
#10
Re: Mouse control in Windows
Originally Posted by Coaxecva
Sorry, I'm a newbie in trying this fun learning. I found this struct of SetCurPos().
I will try but it can not work.
/*****************************************************/
int SetCurPos (
[InAttribute] IntPtr hwnd,
[InAttribute] int x,
[InAttribute] int y,
[OutAttribute] array<VSIME_ERR>^ perr
)
/////////////////////////////////////////////////////////////////////
HRESULT IVsIME::SetCurPos(
[in] HWND hwnd,
[in] int x,
[in] int y,
[out] VSIME_ERR * perr
);
/*****************************************************/
***I have tried :
#include "windows.h"
int main()
{
int* hwnd;
SetCurPos(hwnd,10,10);
return 0;
}
***It raises an error:
Error 1 error C3861: 'SetCurPos': identifier not found
***I dont know what hwnd is .
Any ones have tried before, instruct me to use it, pls.
Thank you.
You need to build a Windows application to use the Windows API. You need to pass SetCurPos a valid window handle. All you passed it was an uninitialized int pointer.
Time to get a good tutorial and work through the basics.
-
October 26th, 2009, 10:32 AM
#11
Re: Mouse control in Windows
Originally Posted by GCDEF
You need to build a Windows application to use the Windows API. You need to pass SetCurPos a valid window handle. All you passed it was an uninitialized int pointer.
Time to get a good tutorial and work through the basics.
How can we do with double clicks?
-
October 26th, 2009, 11:00 AM
#12
Re: Mouse control in Windows
Originally Posted by Coaxecva
How can we do with double clicks?
Do you know anything about writing Windows apps?
-
October 27th, 2009, 06:20 AM
#13
Re: Mouse control in Windows
Sr, I dont know.
But I can do mouse move and mouse click.
#include "windows.h"
int main()
{
SetCurPos(10,10); /// move to 10,10
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0); //check left_mouse down, right mouse is quite similar.
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0); //check left mouse up, right mouse is also like this
return 0;
}
I would like to know how to do double clicks.
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
|