Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 18:31

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

Advertisement



C++ Send Keys Background

Discussion on C++ Send Keys Background within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Apr 2014
Posts: 28
Received Thanks: 0
C++ Send Keys Background

Hello guys I've a problem, how i can send key to inactive window? For example how i can send "x" in background to inactive window? Thanks and sorry for my bad english xD
reload! is offline  
Old 05/08/2014, 18:05   #2
 
_Entropia_'s Avatar
 
elite*gold: 0
Join Date: Apr 2012
Posts: 44
Received Thanks: 119
u can use SendMessage or PostMessage to send keyboard events.
_Entropia_ is offline  
Old 05/10/2014, 19:39   #3
 
elite*gold: 0
Join Date: Apr 2014
Posts: 14
Received Thanks: 3
As Entropia said, Use SendMessage. You can do it followed by WM_LBUTTON.
Code:
LRESULT WINAPI SendMessage(
  _In_  HWND hWnd,
  _In_  UINT Msg,
  _In_  WPARAM wParam,
  _In_  LPARAM lParam
);
You'll have something like this then:
Code:
#include <Windows.h>
HWND window = FindWindow(0, L"Your Window Title");
SendMessage(window, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y));
SendMessage(window, WM_LBUTTONUP, MK_LBUTTON, MAKELPARAM(x, y));
EDIT; I'm sorry I thought you wanted to send a mouseclick.
Well, here this is how you send the "x" key:
Code:
HWND window = FindWindow(0, L"Your Window Title");
SendMessage(window, WM_CHAR, 'x', 0);
Also, if you want to send a keystroke with SendMessage you can do something like this:
Code:
void sendText(LPCWSTR windowName, char* szText)
{
	if (strlen(szText) < 1) return;

	for (int i = 0; i < strlen(szText); ++i)
	{
		HWND hwnd = FindWindow(0, windowName);
		SendMessage(hwnd, WM_CHAR, szText[i], 0);
	}
}
Code:
sendText(L"Your Window Name", "some text here");
Accelerate. is offline  
Old 05/11/2014, 20:57   #4
 
elite*gold: 0
Join Date: Apr 2014
Posts: 28
Received Thanks: 0
Ok Thanks guys
reload! is offline  
Reply


Similar Threads Similar Threads
Planetside 2: Send left mouse click to game in background
12/14/2012 - AutoIt - 8 Replies
Hey, I've just started playing around with this program and i can manage to get the script to work if I have the game in focus: Send("{SPACE}") Which will for example make the character jump. The idea for me is to have these things working in the background while I have other things to do on my computer, so basically have AutoIt run on an inactive window. I tried this: ControlClick("Planetside2 v0.473.22.176761 **SHIPPING**", "", "", "", 1, 959, 545)
How to send key on background window
09/26/2011 - General Coding - 3 Replies
Do you know how send key in a background window with autoit ? I try WinActivate("4Story") but I can't do enything else...
How can I send the keys sro_client?
05/15/2011 - General Coding - 8 Replies
Hello,how can I send keys just sro_client's window with vb6? I need these codes.I said just because of I want to sendkeys to sro_client's window while what I'm doing something on computer
How can i send keystrokes to an application in background
04/09/2008 - Archlord - 3 Replies
i need something like a macro that can send keystrokes to an application in background and loop the sending in delay of 2 minutes or something... Any1 have an idea how can i do this or where can i download such program?



All times are GMT +1. The time now is 18:32.


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.