Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Post Message not working
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Fri Aug 15, 2008 6:40 am    Post subject: Reply with quote

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
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Fri Aug 15, 2008 8:34 am    Post subject: Reply with quote

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
View user's profile Send private message
BirdsEye
Advanced Cheater
Reputation: 0

Joined: 05 Apr 2008
Posts: 94

PostPosted: Fri Aug 15, 2008 10:27 pm    Post subject: Reply with quote

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
View user's profile Send private message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Fri Aug 15, 2008 11:23 pm    Post subject: Reply with quote

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;
}



The Extension 'zip' was deactivated by an board admin, therefore this Attachment is not displayed.

Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sat Aug 16, 2008 12:23 am    Post subject: Reply with quote

pkedpker wrote:
that wont work it doesn't have return and this will work
[/code]


it will work fine.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites