Results 1 to 9 of 9

Thread: Key Press

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    524

    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);

  2. #2
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    991

    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)

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    524

    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

  4. #4
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    991

    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)

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    524

    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

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    524

    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.

  7. #7
    Fanatic Member AceInfinity's Avatar
    Join Date
    May 2011
    Posts
    696

    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);
    <<<------------
    Improving Managed Code Performance | .NET Application Performance
    < Please if this helped you out. Any kind of thanks is gladly appreciated >


    .NET Programming (2012 - 2018)
    ®Crestron - DMC-T Certified Programmer | Software Developer
    <<<------------

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    524

    Re: Key Press

    this is for key press to start but how to stop it?

  9. #9
    Fanatic Member AceInfinity's Avatar
    Join Date
    May 2011
    Posts
    696

    Re: Key Press

    Quote Originally Posted by diablo21 View Post
    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()
    <<<------------
    Improving Managed Code Performance | .NET Application Performance
    < Please if this helped you out. Any kind of thanks is gladly appreciated >


    .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
  •  



Click Here to Expand Forum to Full Width