 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Snootae Grandmaster Cheater
Reputation: 0
Joined: 16 Dec 2006 Posts: 969 Location: --->
|
Posted: Fri Apr 04, 2008 8:04 am Post subject: [C++] postmessage dll error |
|
|
hey guys, im working on my bot in C++
i've got this so far:
| Code: | HWND mswin;
DWORD lParam;
INT scancode;
INT key;
INT on;
void sendshit(INT key)
{
mswin = FindWindowW(L"MapleStoryClass", NULL);
lParam = MapVirtualKey(key,0);
lParam <<= 16;
PMX(mswin,WM_KEYDOWN,key,lParam);
Sleep(10);
PMX(mswin,WM_KEYUP,key,lParam);
}
bool Keys(void) // Main code
{
if (on == 1){
sendshit(0x45);
Sleep(300);
}
if (on == 0){
Sleep(1000);
}
return true;
}
bool HotKeys(void) // Main code
{
for(;;) // Main loop
{
Sleep(20);
if(GetAsyncKeyState(VK_F6) && (on == 0)) {
on = 1;
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)&Keys, 0, 0, 0);
Sleep(400);
}
if(GetAsyncKeyState(VK_F6) && (on == 1)) {
on = 0;
Sleep(400);
}
}
return true;
}
BOOL WINAPI DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpReserved )
{
switch ( dwReason )
{
case DLL_PROCESS_ATTACH:
on = 0;
CreateThread( 0, 0, (LPTHREAD_START_ROUTINE)HotKeys, 0, 0, 0 );
break;
case DLL_PROCESS_DETACH:
break;
}
return 1;
}
|
i seem to work well, but only twice, then it errors
can you help me out, i dont know whats going wrong
btw, im working on globalhotkeys aswell, i know its not good this way
lol, just remembered i called it sendshit, looks funny
_________________
|
|
| Back to top |
|
 |
Kalookakoo Expert Cheater
Reputation: 0
Joined: 03 Mar 2008 Posts: 117
|
Posted: Fri Apr 04, 2008 8:34 am Post subject: |
|
|
I'm sorry I'm no real help to your problem, but I felt I needed to ask.
Why would globalhotkeys bebetter to use the GetAsyncKeyState?
|
|
| Back to top |
|
 |
Snootae Grandmaster Cheater
Reputation: 0
Joined: 16 Dec 2006 Posts: 969 Location: --->
|
Posted: Fri Apr 04, 2008 9:09 am Post subject: |
|
|
because keystate requires checking every 20 ms or so
i believe hotkeys are just called when keys are pressed, less cpu usage
_________________
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Fri Apr 04, 2008 9:17 am Post subject: |
|
|
are you calling PMX from an external dll?
Edit:
For Global hotkey's
define an ATOM and call GlobalAddAtom("some random string");
then use RegisterHotKey
It'l look like this:
| Code: | ATOM HotKey1;
...
HotKey1 = GlobalAddAtom(_T("Hotkey"));
RegisterHotKey( hWnd, HotKey1, MOD_CONTROL, VK_F11 );
|
hWnd - your window to handle the message (WM_HOTKEY)
HotKey1 - The ATOM you defined and added.
MOD_CONTROL can be NULL if u dont want a mod key (shit,ctrl,or alt)
VK_F11 is edited for w/e hotkey you want.
then check for WM_HOTKEY in your WndProc
| Code: | case WM_HOTKEY:
switch ( HIWORD(lParam) )
{
case VK_F11:
sendshit();
break;
} |
_________________
Last edited by lurc on Fri Apr 04, 2008 9:26 am; edited 1 time in total |
|
| Back to top |
|
 |
Snootae Grandmaster Cheater
Reputation: 0
Joined: 16 Dec 2006 Posts: 969 Location: --->
|
Posted: Fri Apr 04, 2008 9:22 am Post subject: |
|
|
nope, inside
_________________
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Fri Apr 04, 2008 9:30 am Post subject: |
|
|
hmm..
looks like this right?
| Code: | DWORD dwPM = (DWORD)GetProcAddress( LoadLibrary( _T("user32.dll") ), "PostMessageA" ) + 5;
_declspec(naked) BOOL WINAPI PMX( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
_asm
{
mov edi,edi
push ebp
mov ebp,esp
jmp dword ptr ds:[dwPM]
}
} |
It might be that your not exiting your threads... if they don't already exit if you dont call ExitThread, not really sure about that one....
Btw read my post above about Global Hotkeys
_________________
|
|
| Back to top |
|
 |
Snootae Grandmaster Cheater
Reputation: 0
Joined: 16 Dec 2006 Posts: 969 Location: --->
|
Posted: Fri Apr 04, 2008 9:39 am Post subject: |
|
|
ahh thanks for hotkeys stuff, ill try your pmx stuff too
hmm, doesn't know what _T is, do i need to include something else?
_________________
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Fri Apr 04, 2008 9:46 am Post subject: |
|
|
_T is a macro for UNICODE..
if your not using a UNICODE charecter set you can get rid of it, if you are add tchar.h
_________________
|
|
| Back to top |
|
 |
Snootae Grandmaster Cheater
Reputation: 0
Joined: 16 Dec 2006 Posts: 969 Location: --->
|
Posted: Fri Apr 04, 2008 9:58 am Post subject: |
|
|
oh, think ill just get rid of it
_________________
|
|
| 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
|
|