-
Aug 17th, 2015, 05:30 AM
#1
Thread Starter
Fanatic Member
Key Press
Hi, i was trying to create an autoclick method for ingame
When i Press F7 the mause to start clicking automatic Left Button , If Press Again F7 - Stop
When i Press F8 the mouse to start clicking automatic Right Button, If press again F8 - stop
It builds correct but doesnt effect when i press Key F7 or F8
where is the problem?
Code:
void EC_AutoClick(void * lpParam)
{
while(true)
{
again:
HWND hWnd = FindWindow(NULL,"MU"); //Name Window
if(GetAsyncKeyState(VK_F7) == -32767)
{
int ClickL = GetPrivateProfileInt("EC-CLICK","ClickL",1,Custom_File);
if(ClickL == 1)
{
WritePrivateProfileString("EC-CLICK","ClickL","1",Custom_File);
SendMessageA(hWnd, WM_LBUTTONDOWN,VK_F7, MK_LBUTTON);
SendMessageA(hWnd, WM_RBUTTONUP,VK_F7, MK_RBUTTON);
//ClientMsgStringSend("","[EquipeCrazzY] Ativando autoclick Esquerdo", 0x2);
}
if(ClickL == 0)
{
WritePrivateProfileString("EC-CLICK","ClickL","0",Custom_File);
//ClientMsgStringSend("","[EquipeCrazzY] Desativando autoclick Esquerdo", 0x2);
SendMessageA(hWnd, WM_LBUTTONUP,VK_F7, MK_LBUTTON);
}
}
if(GetAsyncKeyState(VK_F8) == -32767)
{
int ClickR = GetPrivateProfileInt("EC-CLICK","ClickR",1,Custom_File);
if(ClickR == 1)
{
WritePrivateProfileString("EC-CLICK","ClickR","1",Custom_File);
SendMessageA(hWnd, WM_RBUTTONDOWN,VK_F8, MK_RBUTTON);
SendMessageA(hWnd, WM_LBUTTONUP,VK_F8, MK_LBUTTON);
//ClientMsgStringSend("","[EquipeCrazzY] Ativando autoclick direito", 0x2);
}
if(ClickR == 0)
{
WritePrivateProfileString("EC-CLICK","ClickR","0",Custom_File);
//ClientMsgStringSend("","[EquipeCrazzY] Desativando autoclick direito", 0x2);
SendMessageA(hWnd, WM_RBUTTONUP,VK_F8, MK_RBUTTON);
}
}
Sleep(20);
goto again;
}
_endthread();
}
Main.dll
Code:
#include <process.h>
_beginthread(EC_AutoClick,0,NULL);
WritePrivateProfileString("EC-CLICK","ClickR","1",Custom_File);
WritePrivateProfileString("EC-CLICK","ClickL","1",Custom_File);
-
Aug 18th, 2015, 03:53 AM
#2
Re: Key Press
Code:
if(GetAsyncKeyState(VK_F7) == -32767)
I would suspect that testing for -32767 is the problem as the return value is bit specific. Have you checked what exactly is the return value? See https://msdn.microsoft.com/en-us/lib...=vs.85%29.aspx
All advice is offered in good faith only. 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/
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
Aug 18th, 2015, 04:54 AM
#3
Thread Starter
Fanatic Member
Re: Key Press
i dont understand what you trying to say, sorry for that
but even if i use possitive number still when press the key mouse nothing doing
-
Aug 18th, 2015, 06:30 AM
#4
Re: Key Press
What is the return value for GetAsyncKeyState(VK_F7) as a hex number when F7 is pressed?
All advice is offered in good faith only. 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/
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
Aug 19th, 2015, 02:27 AM
#5
Thread Starter
Fanatic Member
Re: Key Press
i found on internet about -32767 that returns 0xFFFFFFFFFFFF8001 in hex in some forums i read it
http://stackoverflow.com/questions/7...he-description
-
Aug 21st, 2015, 02:58 AM
#6
Thread Starter
Fanatic Member
Re: Key Press
any help how to make when press the key mouse to start clicking ?
maybe someone can convert me this c# to c++
Code:
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
public class Form1 : Form
{
[DllImport("user32.dll",CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
private const int MOUSEEVENTF_LEFTDOWN = 0x02;
private const int MOUSEEVENTF_LEFTUP = 0x04;
private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
private const int MOUSEEVENTF_RIGHTUP = 0x10;
public Form1()
{
}
public void DoMouseClick()
{
//Call the imported function with the cursor's current position
int X = Cursor.Position.X;
int Y = Cursor.Position.Y;
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0);
}
//...other code needed for the application
}
This may help for autoclick mouse ?
Last edited by diablo21; Aug 21st, 2015 at 03:13 AM.
-
Aug 29th, 2015, 10:55 AM
#7
Re: Key Press
The majority of that code isn't even relevant. There's hardly any translation needed to convert it to C++ because this should be it:
Code:
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0);
<<<------------
.NET Programming (2012 - 2018)
®Crestron - DMC-T Certified Programmer | Software Developer <<<------------
-
Aug 31st, 2015, 06:40 AM
#8
Thread Starter
Fanatic Member
Re: Key Press
this is for key press to start but how to stop it?
-
Aug 31st, 2015, 11:15 AM
#9
Re: Key Press
Originally Posted by diablo21
this is for key press to start but how to stop it?
That is for a mouse event not a keypress. For keyboard and mouse you should be using the SendInput() function which deprecates both mouse_event() and keybd_event()
<<<------------
.NET Programming (2012 - 2018)
®Crestron - DMC-T Certified Programmer | Software Developer <<<------------
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
|