 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Sun Feb 10, 2008 11:16 am Post subject: [C++] PostMessage |
|
|
I've been trying like crazy to get this stupid PostMessage deal to work.
Here's my code:
| Code: |
int _tmain(int argc, _TCHAR* argv[])
{
HWND hHandle = FindWindow(NULL, _T("Untitled - Notepad"));
cout << hHandle << endl;
int x = MapVirtualKey(0x5A, 0) << 16;
cout << x << endl;
cout << GetLastError() << endl;
PostMessage(hHandle, 0x100, 0x5A, x);
cout << GetLastError() << endl;
Sleep(1000);
PostMessage(hHandle, 0x101, 0x5A, x);
return 0;
}
|
When it runs, it gives me a valid handle, and a valid Virtual Key, and both GetLastError()s return 0. However, when I go check notepad, the text is still the same. What am I doing wrong?
_________________
|
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Sun Feb 10, 2008 11:23 am Post subject: |
|
|
Damn.
Is there an easy way to just send something to the selected control?
I'm trying to loop through running programs and send a key-combination to it. Notepad was just an example.
_________________
|
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Sun Feb 10, 2008 11:30 am Post subject: |
|
|
| Code: | | HWND hHandle = FindWindow(L"notepad", NULL); |
^ You might want to use the class instead of the window title aswell.
|
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Sun Feb 10, 2008 11:36 am Post subject: |
|
|
Ok, now I never got this.
When using classes in FindWindow, it's referring to classes as things like when you create your own class while programming, right? If so, how do you know the class--do you just kinda know?
Edit:
GetClassName!
Edit again:
I hate the fact that C++ has no default string. -__-
Ok, so I have this:
| Code: |
char *cname;
int wee = GetClassName(hHandle, cname, 81);
|
This gives me the error that it can't convert char * to LPsomething or other.
I tried the L macro that noz mentioned, and VS said that it didn't exist. -__-
Edit once again:
Damn, that's retarded. Changed it to a TCHAR *, and it built fine. -__-
Edit:
I hate this stuff.
When using this code:
| Code: |
HWND hHandle = FindWindow(NULL, _T("Untitled - Notepad"));
cout << hHandle << endl;
TCHAR *cname = {0};
int wee = GetClassName(hHandle, cname, 81);
cout << GetLastError();
cin.get();
|
I get the error 998, which VS tells me is
| Code: |
Invalid access to memory location.
|
_________________
|
|
| Back to top |
|
 |
Reak I post too much
Reputation: 0
Joined: 15 May 2007 Posts: 3496
|
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Sun Feb 10, 2008 12:31 pm Post subject: |
|
|
Well the thing is, I'm not having trouble with the API itself, I'm having trouble with the C++. x_x
Thanks though, I'm talking to Renko about it on MSN
_________________
|
|
| Back to top |
|
 |
XxOsirisxX Grandmaster Cheater Supreme
Reputation: 0
Joined: 30 Oct 2006 Posts: 1597
|
Posted: Sun Feb 10, 2008 12:34 pm Post subject: |
|
|
I did make one that i saw long time ago at internet.
It's like that one you just posted, just that this one have less features, just the pointer move one it's avalible. Which also tells you the Class.
I will post since i feel like i will not lose nothing.
_________________
|
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Sun Feb 10, 2008 12:36 pm Post subject: |
|
|
Well I've got it, thanks everyone.
_________________
|
|
| 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
|
|