Send keys wont work?-VBForums
Results 1 to 2 of 2

Thread: Send keys wont work?

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2011
    Posts
    4

    Send keys wont work?

    ok so im trying to send a key, Mouse down, in Skyrim for example. but it dose not work. what am i doing wrong?


    Code:
    //==============================//
    //Project: Send Keys            //
    //==============================//
    
    // Define
    #define IsKeyDown(Key) GetAsyncKeyState(Key) & 0x8000 //Used to check if a key is down.
    
    
    // Include headers
    #include <windows.h>
    #include <iostream>
    #include <tchar.h>
    #pragma comment(lib,"User32.lib")
    
    ///////std
    using namespace std;
    
    // Global Vars //
    DWORD dwGameExe = NULL;
    bool bFire = false;
    bool on1 = true;
    //thread - key send and ****.. for checks
    DWORD WINAPI dwMainThread(LPVOID)
    {
    	 //Check for the game
    	for(;dwGameExe == NULL; Sleep(250)); // if exe is still null.. Sleep until game is found
    	{
    		dwGameExe = (DWORD)GetModuleHandle("TESV.exe");// Retrieves the module of "BFBC2Game.exe"
    		//dwGameExe = (DWORD)GetModuleHandle("notepad.exe")
    	}		
    	// Do key checks etc.
    
    //if (IsKeyDown(VK_LBUTTON))
    if (IsKeyDown(VK_F2))
    //if (IsKeyDown(MOUSEEVENTF_LEFTDOWN))
    		on1 = !on1;
    
    	if(on1 == true)
    {
    	
    Sleep(100);
    
    
    mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
    Sleep(100);
    mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
    //Sleep(80);
    
    
    Sleep(100);
    
    
    
    mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
    Sleep(100);
    	mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
    //Sleep(80);
    
    
    
    //	mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
    //	Sleep(10);
    //	mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
    
    return 1;
    
    }
    
    
    
    	if(GetAsyncKeyState(VK_UP)&1) // F1 Hot keey to enable.. then let it see if it fires.
    		bFire = !bFire;
    
    	if(bFire == true)
    	{
    		mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
    		Sleep(2500);
    		mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
    
    MessageBox(NULL,"Project1.dll detached to Process!", "Successful Injection" ,NULL);
    
    	}
    
    	return 1;
    }
    
    BOOL WINAPI DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
    {
        switch (dwReason)
        {
            case DLL_PROCESS_ATTACH:
                // Call thread
    			CreateThread(0,0,dwMainThread,0,0,0);
    			MessageBox(NULL,"Project1.dll detached to Process!", "Successful Injection" ,NULL);
                break;
    
            case DLL_PROCESS_DETACH:
                // Code to run when the DLL is freed
                break;
        }
        return TRUE;
    }

    have been Trying to get it to inject and Work on other apps. but dose not seem to work :/
    Last edited by amatris; Dec 14th, 2011 at 01:56 PM.

  2. #2
    Junior Member
    Join Date
    Oct 2009
    Posts
    21

    Re: Send keys wont work?

    Any luck?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.