Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 23:15

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



sending key to inactive window

Discussion on sending key to inactive window within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Feb 2009
Posts: 1,234
Received Thanks: 1,095
sending key to inactive window

im a newbie with c++ today and im trying to make a dll to send key to inactive window but i tryed calling it and nothing gets sent dont know if i call it right or not .

DLL:
Code:
#include "main.h"
#include <windows.h>

// a sample exported function
int DLL_EXPORT SendMessage(int x = 0){
    //HWND Client = FindWindow(0, "D3D Window");
    HWND hwnd = FindWindow("D3D Window", NULL);


  //  SendInput(hwnd, '2');
    SendMessage(hwnd, WM_KEYDOWN, VK_F4, 0);
    Sleep(300);
    SendMessage(hwnd, WM_KEYUP, VK_F4, 0);
    return x;

  //  PostMessage(hwnd, WM_KEYDOWN, 0x43, 0);
 //     PostMessage(hwnd, WM_CHAR, (WPARAM)'C', 0);
 //     PostMessage(hwnd, WM_KEYUP, 0x43, 0);

//      cout << "pressed" << endl;
	MessageBox(0, "Join us at Inferno Dev!", "DLL Message", MB_OK | MB_ICONINFORMATION);
    return x;
}

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
    switch (fdwReason)
    {
        case DLL_PROCESS_ATTACH:
            // attach to process
            // return FALSE to fail DLL load
            break;

        case DLL_PROCESS_DETACH:
            // detach from process
            break;

        case DLL_THREAD_ATTACH:
            // attach to thread
            break;

        case DLL_THREAD_DETACH:
            // detach from thread
            break;
    }
    return TRUE; // successful
}

AutoIt DLL CALL:
Code:
DllCall("test.dll", "none", 'SendMessage')

please help me how can i make the dll send a key to inactive window
tryed googling tutorials of c++ but nothing at all o.o
fear-x is offline  
Old 07/19/2012, 12:57   #2
 
XxharCs's Avatar
 
elite*gold: 34
Join Date: Apr 2011
Posts: 1,475
Received Thanks: 1,228
when u make a dll then u dont need the FindWindow function because, when you inject ur dll then dll "is" in the process..

Quote:
Code:
switch (fdwReason)
    {
        case DLL_PROCESS_ATTACH:
            // attach to process
            // return FALSE to fail DLL load
            break;
are u creating the thread, if i may ask ??

doing something like this in the DLL_PROCESS_ATTACH:
Code:
CreateThread(0, 0, &BotThread , 0, 0, 0);

are u injecting the dll at all or what ?
Quote:
AutoIt DLL CALL:
Code:
Code:
DllCall("test.dll", "none", 'SendMessage')
i mean yeah, you call the dll, but do you inject it ?

and try the SendInput function

if i missunderstood something, then correct me..
XxharCs is offline  
Old 07/19/2012, 13:04   #3
 
elite*gold: 0
Join Date: Feb 2009
Posts: 1,234
Received Thanks: 1,095
ow i didnt know i must inject it

well how do i attach it to another process? so it would send keys to the game whilst inactive.

and apreciate your help.
fear-x is offline  
Old 07/19/2012, 13:05   #4
 
Dr. Coxxy's Avatar
 
elite*gold: 0
Join Date: Feb 2011
Posts: 1,206
Received Thanks: 736
you misunderstood everything.
he compiled it as dll and loaded it into his autoit project to use the exported function.

you dont need to inject it.
Dr. Coxxy is offline  
Old 07/19/2012, 13:06   #5
 
XxharCs's Avatar
 
elite*gold: 34
Join Date: Apr 2011
Posts: 1,475
Received Thanks: 1,228
make an injector^^
or use some injectors that already exists, for example WinInject

Edit: Yeah Coxxy but he still need to load it from there in the process he want to or ?..
XxharCs is offline  
Old 07/19/2012, 13:11   #6
 
elite*gold: 0
Join Date: Feb 2009
Posts: 1,234
Received Thanks: 1,095
i just want the dll to send specific key in each function in that dll :P posible?
fear-x is offline  
Old 07/19/2012, 13:44   #7
 
Dr. Coxxy's Avatar
 
elite*gold: 0
Join Date: Feb 2011
Posts: 1,206
Received Thanks: 736
he doesnt want to inject anything he just makes a library and exports the sendmessage function to use it in his autoit3 project.

@fear-x google, i have no clue about autoit, but afaik you can call the winapi directly.
so you won't need the dll.
Dr. Coxxy is offline  
Old 07/19/2012, 14:27   #8
 
elite*gold: 0
Join Date: Feb 2009
Posts: 1,234
Received Thanks: 1,095
well with autoit it wont work thats the thing xtrap is blocking it

so i thought dll would do the trick...
fear-x is offline  
Old 07/19/2012, 14:50   #9
 
Dr. Coxxy's Avatar
 
elite*gold: 0
Join Date: Feb 2011
Posts: 1,206
Received Thanks: 736
very unlikely to work.
Dr. Coxxy is offline  
Old 07/19/2012, 15:04   #10
 
elite*gold: 0
Join Date: Feb 2009
Posts: 1,234
Received Thanks: 1,095
anyway to make it work? even without dll ? :s i can make simple send to work or in c++ its keybd_event() but not to inactive window :/
fear-x is offline  
Old 07/19/2012, 16:00   #11
 
elite*gold: 0
Join Date: Jun 2012
Posts: 187
Received Thanks: 58
Sendkey (=SendMessage) doesnt work. A window has a message queue in which it peeks for messages, but it does not receive messages while inactive, to save CPU time. Plus, if your window is a game, it probably uses directinput which doesnt check the message queue anyway.

On a side-note; your signature is telling everyone that you have no idea of computer science.
tnd0 is offline  
Old 07/19/2012, 16:40   #12
 
elite*gold: 0
Join Date: Feb 2009
Posts: 1,234
Received Thanks: 1,095
lol? my sig tells u wat? ;d
fear-x is offline  
Old 07/19/2012, 17:35   #13
 
Dr. Coxxy's Avatar
 
elite*gold: 0
Join Date: Feb 2011
Posts: 1,206
Received Thanks: 736
autoit is the death keyword for coding

EDIT:

Quote:
Originally Posted by tnd0 View Post
Sendkey (=SendMessage) doesnt work. A window has a message queue in which it peeks for messages, but it does not receive messages while inactive, to save CPU time.
this is just wrong.
windows wont send normal windows messages anymore, but the messagepump is still active even if the window has not the focus.
if you place a message in the messagequeue via send/postmessage windows will reactivate the messagepump and the window will proceed the message.
but most likely the game/the anticheat has a check wether the window is ontop / the input is emulated.
or the game simply uses directinput.
Dr. Coxxy is offline  
Old 07/19/2012, 18:33   #14
 
elite*gold: 0
Join Date: Feb 2009
Posts: 1,234
Received Thanks: 1,095
well the game has D3D Window and i know that D3D Windows are pain in the *** to work with
fear-x is offline  
Old 07/19/2012, 22:56   #15
 
elite*gold: 0
Join Date: Jun 2012
Posts: 187
Received Thanks: 58
Quote:
if you place a message in the messagequeue via send/postmessage windows will reactivate the messagepump and the window will proceed the message.
yes, windows will do that. however, on a custom message loop you dont necessarily check any messages (if you suspend your window thread or check in a peekmessage loop for example).
tnd0 is offline  
Reply


Similar Threads Similar Threads
Keep SRO active while window is inactive?
05/28/2012 - Silkroad Online - 0 Replies
I remember I used to have this happen - that I could open up 2 windows side by side, one SRO, other a browser, for example. And while I surfed in the browser the SRO window would be inactive but picture would still keep moving so I could watch my bot do the work or keep an eye on the chat window. But now when I click on any other window the SRO window will freeze : \ Anyone know how to avoid that?
Any program for sending key to Inactive Window ?
04/16/2010 - Dekaron - 2 Replies
well ?
Autoit Controlsend (inactive window)
12/05/2009 - AutoIt - 3 Replies
Hiho, ich hab soweit einen funktionierenden Bot - ich wollte nun das Script so umschreiben das es auch auf das inaktive Fenster von dem Spiel zugreift. Habe mich im Forum etwas belesen und bin zu folgenden Aussagen gekommen: - #requireAdmin(funktioniert nicht) - "0" oder "" bei dem Absatz ControlID (funktioniert auch nicht) Den Titel des Fensters habe ich nun schon dutzende male überprüft, der ist 100%ig korrekt.
1Cabal Window 1Maple Window at Same TIME??
05/26/2008 - Cabal Hacks, Bots, Cheats, Exploits & Macros - 0 Replies
let talk about 1 cabal 1 maple at same time... possible?? how to do tat...?? teach me please :p
Rename CO2 window title (any window actually)
05/13/2006 - CO2 Exploits, Hacks & Tools - 4 Replies
I have seen a few posts requesting this. It is a simple autohotkey macro nothing fancy here. You will notice also that the UPX packer detection is not triggered. If you use autohotkey and want to know how to remove the packer PM me it is rather simple. To use this little tool thingie it is very simple: Execute the code. Focus your window. Press Hotkey CTRL+WIN+w Change the Title. Apply



All times are GMT +1. The time now is 23:15.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.