Can someone help with a mouse thing

Posts 1–8 of 8 · Page 1 of 1
Can someone help with a mouse thing
Hey guys, can someone help to with a code to when I click mouse go down? Im working in one thing and i need help i already set the thing just need how to make cursor move down.
Thanks in advance.
[highlight=c++]#include <iostream>
#include <Windows.h>
void main()
{
while (true)
{
if(GetAsyncKeyState(VK_LBUTTON))
{
int x = 50;
int y = 60;
SetCursorPos(x ,y);
}
}
}[/highlight]

You use the GetAsyncKeyState function to check whether the Left Button is down, if so, you simply set the cursor position specified by x and y parameters. Both these functions reside in Windows.h header file.
@Hassan let i put my source
Code:
#include <windows.h>

int main()
{
    while(true) // Infinite loop
    {

          if(GetAsyncKeyState(VK_LBUTTON)&1) // If left mouse button is clicked
    {
          int x = 0;
          int y = 0;
     SetCursorPos(x,y);//Set position of cursor 
     Sleep(500); //0.5 sec of cpu relief :)
     }
}
}
But i want whtn i click id go ↓ understand?
Quote Originally Posted by KissU View Post
@Hassan let i put my source
Code:
#include <windows.h>

int main()
{
    while(true) // Infinite loop
    {

          if(GetAsyncKeyState(VK_LBUTTON)&1) // If left mouse button is clicked
    {
          int x = 0;
          int y = 0;
     SetCursorPos(x,y);//Set position of cursor 
     Sleep(500); //0.5 sec of cpu relief :)
     }
}
}
But i want whtn i click id go ↓ understand?
[highlight=c++]void main()
{
while (true)
{
if(GetAsyncKeyState(VK_LBUTTON)&1)
{
POINT cursorPos;
GetCursorPos(&cursorPos);
int x = cursorPos.x ;
int y = cursorPos.y +50 ;


SetCursorPos(x ,y);
}
}

}[/highlight]

You first create a POINT. Get Cursor's current position using GetCursorPos function by passing cursorPos as a parameter so it can have the cursor's position. Then you assign the x position of the cursor to integer x, and y position of the cursor to integer y, except that you manually set it to go down 50 pixels by specifying +50. Finally you set the cursor position using SetCursorPos function.
@KissU
@Hassan i did just like you said but when i click it go too much down like to taskbar so i trie d with y + 1 and still going ;x
Quote Originally Posted by KissU View Post
@Hassan i did just like you said but when i click it go too much down like to taskbar so i trie d with y + 1 and still going ;x
That's not possible with my code. Post your complete code here.
@KissU
Requesting closed Thank you @Hassan
I'm going get work, thanks for helping. =)
Quote Originally Posted by KissU View Post
Requesting closed Thank you @Hassan
I'm going get work, thanks for helping. =)
LOL. Alright. NP.
/Closed.
Posts 1–8 of 8 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?