 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
intheomg Expert Cheater
Reputation: 0
Joined: 16 Apr 2007 Posts: 160
|
Posted: Fri Dec 28, 2007 7:37 pm Post subject: [Question][C++] SendMessage/PostMessage |
|
|
Lets say I would want to make a program which types "abc" into a notepad.
hwnd is the handle.
How would I go about using SendMessage or PostMessage to input abc into notepad?
Thanks,
intheomg
_________________
To get a miss in Power Guard hack, just update the damn addresses from a Damage Control which modifies the damage taken after Power Guard has calculated the damage its supposed to deal to the monster. No clues on which Damage Control!
人生的价值是多少? |
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Fri Dec 28, 2007 7:40 pm Post subject: |
|
|
you don't send the message to the main notepad window, you send it to the edit child control of the window (using FindWindowEx)
also WM_CHAR
not going to write code because this has been answered many times before and you should be able to find it in a search (if search actually worked)
_________________
|
|
| Back to top |
|
 |
intheomg Expert Cheater
Reputation: 0
Joined: 16 Apr 2007 Posts: 160
|
Posted: Fri Dec 28, 2007 7:45 pm Post subject: |
|
|
Well, I still don't really understand SendMessage/PostMessage. Is there any other way to send keys to a MINIMIZED window?
P.S. Google sucks
Thanks,
intheomg
EDIT: Ok, ok, can someone just give me the full code to send keys to a minimized application? I will analyse it thoroughly.
*Hope for someone to pass it to me
_________________
To get a miss in Power Guard hack, just update the damn addresses from a Damage Control which modifies the damage taken after Power Guard has calculated the damage its supposed to deal to the monster. No clues on which Damage Control!
人生的价值是多少?
Last edited by intheomg on Fri Dec 28, 2007 8:09 pm; edited 1 time in total |
|
| Back to top |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
Posted: Fri Dec 28, 2007 8:08 pm Post subject: |
|
|
FindWindowA
FindWindowExA
PostMessage Loop ('A',+1,+2)
_________________
|
|
| Back to top |
|
 |
intheomg Expert Cheater
Reputation: 0
Joined: 16 Apr 2007 Posts: 160
|
Posted: Fri Dec 28, 2007 8:56 pm Post subject: |
|
|
| Code: | #include <windows.h>
#include <iostream>
using namespace std;
int main(){
int locatewindow,exit;
HWND hwnd;
DWORD pid;
HANDLE phandle;
locatewindow:
hwnd = FindWindow(NULL,"Untitled - Notepad");
if(hwnd==0){
cout << "Failed to locate notepad's window, please open window and press enter to continue." << endl << endl;
cin.get();
goto locatewindow;
}else{
GetWindowThreadProcessId(hwnd, &pid); // get the pid
phandle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid); // we need a handle
system("Title = Notepad");
cout << "What would you like to do?" << endl;
cout << "1. Chat." << endl;
cout << "2. Exit notepad trainer." << endl << endl;
}
cout << "Press F2 to type." << endl;
cout << "Press F5 to exit the trainer." << endl << endl;
while(1==1){
if(GetAsyncKeyState(VK_F2)){
cout << "F2 Pressed!" << endl;
PostMessage(hwnd,WM_KEYDOWN,97,0);
Sleep(10);
PostMessage(hwnd,WM_CHAR,97,0);
Sleep(10);
PostMessage(hwnd,WM_KEYUP,97,0);
}
if(GetAsyncKeyState(VK_F5)){
goto exit;
}
}
exit:
return 0;
}
|
Can someone see what's wrong with this? =\
Help me please...
EDIT: Oops, spotted three useless declaration.
Thanks,
intheomg
_________________
To get a miss in Power Guard hack, just update the damn addresses from a Damage Control which modifies the damage taken after Power Guard has calculated the damage its supposed to deal to the monster. No clues on which Damage Control!
人生的价值是多少? |
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Fri Dec 28, 2007 9:16 pm Post subject: |
|
|
| Code: |
typedef void CONTEXT;
typedef void* PCONTEXT;
#include <stdlib.h>
#include <tchar.h>
#include <windef.h>
#include <winbase.h>
#include <winuser.h>
int _tmain(_TINT argc, _TCHAR* argv[])
{
HWND hwnd, hwndchild; int i;
LPCTSTR msg = _T("penispenispenis");
hwnd = FindWindow(_T("Notepad"), NULL); //Take notes, this works with any document open
if (hwnd != NULL) {
hwndchild = FindWindowEx(hwnd, NULL, TEXT("EDIT"), NULL);
if (hwndchild != NULL) {
for(i = 0; i < _tcslen(msg); i++) {
SendMessage(hwndchild, WM_CHAR, msg[i], 0);
}
_tprintf(TEXT("success."));
return EXIT_SUCCESS;
}
}
_tprintf(TEXT("fail."));
return EXIT_FAILURE;
}
|
_________________
|
|
| Back to top |
|
 |
intheomg Expert Cheater
Reputation: 0
Joined: 16 Apr 2007 Posts: 160
|
Posted: Fri Dec 28, 2007 9:22 pm Post subject: |
|
|
| appalsap wrote: | | Code: |
typedef void CONTEXT;
typedef void* PCONTEXT;
#include <stdlib.h>
#include <tchar.h>
#include <windef.h>
#include <winbase.h>
#include <winuser.h>
int _tmain(_TINT argc, _TCHAR* argv[])
{
HWND hwnd, hwndchild; int i;
LPCTSTR msg = _T("penispenispenis");
hwnd = FindWindow(_T("Notepad"), NULL); //Take notes, this works with any document open
if (hwnd != NULL) {
hwndchild = FindWindowEx(hwnd, NULL, TEXT("EDIT"), NULL);
if (hwndchild != NULL) {
for(i = 0; i < _tcslen(msg); i++) {
SendMessage(hwndchild, WM_CHAR, msg[i], 0);
}
_tprintf(TEXT("success."));
return EXIT_SUCCESS;
}
}
_tprintf(TEXT("fail."));
return EXIT_FAILURE;
}
|
|
Err? 44 Errors
BTW, I'm using Dev C++ compiler...
Regards,
intheomg
EDIT!!!!:
Wooo, I got it, after modifying alot from your code.
| Code: |
#include <stdlib.h>
#include <tchar.h>
#include <windef.h>
#include <windows.h>
using namespace std;
int main()
{
HWND hwnd, hwndchild; int i;
LPCTSTR msg = _T("penispenispenis");
hwnd = FindWindow(_T("Notepad"), NULL); //Take notes, this works with any document open
if (hwnd != NULL) {
hwndchild = FindWindowEx(hwnd, NULL, TEXT("EDIT"), NULL);
if (hwndchild != NULL) {
for(i = 0; i < _tcslen(msg); i++) {
SendMessage(hwndchild, WM_CHAR, msg[i], 0);
}
return 0;
}
}
return EXIT_FAILURE;
}
|
Time to analyse! Thanks alot appal ^^
EDITTTTTTTT!!!! ATTENTION!!!
How do I stimulate clicks at a certain co-ordinates with PostMessage/SendMessage, while the targeted window is minimized?
_________________
To get a miss in Power Guard hack, just update the damn addresses from a Damage Control which modifies the damage taken after Power Guard has calculated the damage its supposed to deal to the monster. No clues on which Damage Control!
人生的价值是多少? |
|
| Back to top |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
Posted: Sat Dec 29, 2007 12:53 am Post subject: |
|
|
| Quote: | WM_LBUTTONDOWN
WM_LBUTTONUP
WM_LBUTTONDBLCLK |
| Quote: | WM_RBUTTONDOWN
WM_RBUTTONUP
WM_RBUTTONDBLCLK |
| Quote: | WM_MBUTTONDOWN
WM_MBUTTONUP
WM_MBUTTONDBLCLK |
_________________
|
|
| Back to top |
|
 |
intheomg Expert Cheater
Reputation: 0
Joined: 16 Apr 2007 Posts: 160
|
Posted: Sat Dec 29, 2007 8:48 am Post subject: |
|
|
| sponge wrote: | | Quote: | WM_LBUTTONDOWN
WM_LBUTTONUP
WM_LBUTTONDBLCLK |
| Quote: | WM_RBUTTONDOWN
WM_RBUTTONUP
WM_RBUTTONDBLCLK |
| Quote: | WM_MBUTTONDOWN
WM_MBUTTONUP
WM_MBUTTONDBLCLK |
|
Thanks, but, how do you go about setting the co-ords for it? It is possible?
_________________
To get a miss in Power Guard hack, just update the damn addresses from a Damage Control which modifies the damage taken after Power Guard has calculated the damage its supposed to deal to the monster. No clues on which Damage Control!
人生的价值是多少? |
|
| Back to top |
|
 |
the_undead Expert Cheater
Reputation: 1
Joined: 12 Nov 2006 Posts: 235 Location: Johannesburg, South Africa
|
Posted: Sat Dec 29, 2007 8:51 am Post subject: |
|
|
lParam.
How about you just use msdn?
_________________
|
|
| Back to top |
|
 |
intheomg Expert Cheater
Reputation: 0
Joined: 16 Apr 2007 Posts: 160
|
Posted: Sat Dec 29, 2007 8:54 am Post subject: |
|
|
| the_undead wrote: | lParam.
How about you just use msdn? |
I know it is supposed to be filled in lParam, but, lets say I would like the mouse co-ords - x = 40, y = 50,
how do I go about filling it in? What value do I fill in?
And I have no idea what is MSDN.
Thanks!
intheomg
_________________
To get a miss in Power Guard hack, just update the damn addresses from a Damage Control which modifies the damage taken after Power Guard has calculated the damage its supposed to deal to the monster. No clues on which Damage Control!
人生的价值是多少? |
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|