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.
Re: Mouse control in Windows
Quote:
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
Re: Mouse control in Windows
You can get the screen resolution using the function GetDeviceCaps with HORZRES and VERTRES
Re: Mouse control in Windows
Quote:
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()
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.
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;"
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?
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!!!
Re: Mouse control in Windows
Quote:
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.
Re: Mouse control in Windows
Quote:
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?
Re: Mouse control in Windows
Quote:
Originally Posted by
Coaxecva
How can we do with double clicks?
Do you know anything about writing Windows apps?
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.