 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Fri Aug 15, 2008 6:40 am Post subject: |
|
|
| I expect he is testing his code on a non-protected application first to get it working before changing the code to attach to a game instead. I often do that myself too. Loading up notepad is much quicker and easier than opening up a game and you can run a debugger in the background too to see what, if present, problems are and how to fix them.
|
|
| Back to top |
|
 |
Reak I post too much
Reputation: 0
Joined: 15 May 2007 Posts: 3496
|
Posted: Fri Aug 15, 2008 8:34 am Post subject: |
|
|
PostMessage example:
| Code: | #include <windows.h>
#include <iostream>
using namespace std;
int main(){
HWND notepad;
HWND textfield;
notepad = FindWindow(L"notepad", NULL); // Getting notepad-handle
if(notepad != 0){ // Checking if the handle is correct
textfield = FindWindowEx(notepad, 0, L"Edit", NULL); // Getting notepad's memo-handle
if(textfield != 0){ // Checking if memo-handle is correct
char * text = "lol"; // text to send
for(int i=0; i<strlen(text); i++) // Loop
PostMessageA(textfield, WM_CHAR, text[i], 0); // sending every single char of text.
cout << "Done sent :>" << endl;
} else {
cout << "Could not get Edit-Handle" << endl; // if incorrect memo-handle
}
} else {
cout << "Could not get Notepad-Handle" << endl; // if incorrect notepad-handle
}
} |
|
|
| Back to top |
|
 |
BirdsEye Advanced Cheater
Reputation: 0
Joined: 05 Apr 2008 Posts: 94
|
Posted: Fri Aug 15, 2008 10:27 pm Post subject: |
|
|
| Negima wrote: | I fixed my old error but now I get a new error
| Code: | #include <iostream>
#include <windows.h>
int main()
{
HWND hNotepad=FindWindow(NULL, "Notepad");
BOOL PostMessage( hNotepad, WM_KEYUP, 0, 0 );
system("pause"); //dont flame plz
return 0;
} |
| Code: | ------ Build started: Project: NegiBot, Configuration: Debug Win32 ------
Compiling...
NegiBot.cpp
.\NegiBot.cpp(6) : error C2664: 'FindWindowW' : cannot convert parameter 2 from 'const char [8]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
.\NegiBot.cpp(7) : error C2078: too many initializers
Build log was saved at "file://c:\Users\Joseph\Documents\Visual Studio 2008\Projects\NegiBot\NegiBot\Debug\BuildLog.htm"
NegiBot - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== |
|
Try changing FindWindow into FindWindowA, that should work. (Assuming you haven't changed the settings)
|
|
| Back to top |
|
 |
pkedpker Master Cheater
Reputation: 1
Joined: 11 Oct 2006 Posts: 412
|
Posted: Fri Aug 15, 2008 11:23 pm Post subject: |
|
|
that wont work it doesn't have return and this will work
| Code: |
#include <windows.h>
#include <iostream>
using namespace std;
int main(){
HWND notepad;
HWND textfield;
notepad = FindWindow((LPCTSTR)"Notepad", NULL); // Getting notepad-handle
if(notepad != 0){ // Checking if the handle is correct
textfield = FindWindowEx(notepad, 0, (LPCTSTR)"Edit", NULL); // Getting notepad's memo-handle
if(textfield != 0){ // Checking if memo-handle is correct
char * text = "test spammer for lifes..\n"; // text to send
for(int i=0; i<strlen(text); i++) // Loop
PostMessageA(textfield, WM_CHAR, text[i], 0); // sending every single char of text.
printf("Done sent :>\n");
system("pause");
} else {
printf("Could not get Edit-Handle\n"); // if incorrect memo-handle
}
} else {
printf("Could not get Notepad-Handle\n"); // if incorrect notepad-handle
}
return 0;
}
|
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Sat Aug 16, 2008 12:23 am Post subject: |
|
|
| pkedpker wrote: | that wont work it doesn't have return and this will work
[/code] |
it will work fine.
|
|
| 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
|
|