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 


Need help for a PostMessage loop
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
TraxMate
Master Cheater
Reputation: 0

Joined: 01 Mar 2008
Posts: 363

PostPosted: Sun Sep 14, 2008 9:48 am    Post subject: Need help for a PostMessage loop Reply with quote

Hi,
I'm working on a trainer for MapleStory and I have some trouble sending a key in a loop untill I untick the checkbox. I know how PostMessage works and how to make it bypass GG. I only have problem with sending it more than once when the checkbox is ticked. I've tried a for(;Wink loop but the only thing that does is to freeze the trainer(not that i expected it to work) and I have searched both here and google but havn't found a solution to my problem : /. I was hoping you huys could help me so I attached the source.



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

Back to top
View user's profile Send private message
Fuzz
Grandmaster Cheater
Reputation: 0

Joined: 12 Nov 2006
Posts: 531

PostPosted: Sun Sep 14, 2008 10:09 am    Post subject: Reply with quote

You need to use threads.
_________________
Back to top
View user's profile Send private message AIM Address
TraxMate
Master Cheater
Reputation: 0

Joined: 01 Mar 2008
Posts: 363

PostPosted: Sun Sep 14, 2008 10:25 am    Post subject: Reply with quote

Fuzz wrote:
You need to use threads.
And how do I use threads? I've tried CreateThread but don't really know how it works.
Back to top
View user's profile Send private message
kitterz
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Dec 2007
Posts: 1268

PostPosted: Sun Sep 14, 2008 11:14 am    Post subject: Reply with quote

TraxMate wrote:
Fuzz wrote:
You need to use threads.
And how do I use threads? I've tried CreateThread but don't really know how it works.


google is your friend. So is MSDN

http://msdn.microsoft.com/en-us/library/ms682453.aspx

Code:
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)&ProcedureNameGoesHere, hWnd, 0, 0);


Basically this.....

_________________
Back to top
View user's profile Send private message Send e-mail
TraxMate
Master Cheater
Reputation: 0

Joined: 01 Mar 2008
Posts: 363

PostPosted: Sun Sep 14, 2008 11:50 am    Post subject: Reply with quote

kitterz wrote:
TraxMate wrote:
Fuzz wrote:
You need to use threads.
And how do I use threads? I've tried CreateThread but don't really know how it works.


google is your friend. So is MSDN

http://msdn.microsoft.com/en-us/library/ms682453.aspx

Code:
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)&ProcedureNameGoesHere, hWnd, 0, 0);


Basically this.....

Thank you very much Smile. It's working now Very Happy.

Edit: How do I make it stop when I untick the checkbox? CreateThread is new to me so I don't know much about it.
Back to top
View user's profile Send private message
Fuzz
Grandmaster Cheater
Reputation: 0

Joined: 12 Nov 2006
Posts: 531

PostPosted: Sun Sep 14, 2008 12:56 pm    Post subject: Reply with quote

TerminateThread()
_________________
Back to top
View user's profile Send private message AIM Address
sponge
I'm a spammer
Reputation: 1

Joined: 07 Nov 2006
Posts: 6009

PostPosted: Sun Sep 14, 2008 2:46 pm    Post subject: Reply with quote

ExitThread() is preferred. When you tick the checkbox set a boolean, and have your thread compare that boolean. IF true -> ExitThread()
_________________
Back to top
View user's profile Send private message
Fuzz
Grandmaster Cheater
Reputation: 0

Joined: 12 Nov 2006
Posts: 531

PostPosted: Sun Sep 14, 2008 2:50 pm    Post subject: Reply with quote

Yeah, i guess ExitThread() would be better.
_________________
Back to top
View user's profile Send private message AIM Address
TraxMate
Master Cheater
Reputation: 0

Joined: 01 Mar 2008
Posts: 363

PostPosted: Mon Sep 15, 2008 1:38 pm    Post subject: Reply with quote

Thank you sponge and Fuzz. You helped alot. But how do I set the delay between every keypress? i.e I write 100 in the text box and the delay should be 100 msec. I tried this
Code:
DWORD _stdcall AutoLoot()
{
   LRESULT Delay = SendMessage(AutoLootDelay, WM_GETTEXT, 0, 0); // AutoLootDelay is the text box and it's preset on 100

   if(MapleWnd = FindWindow(_T("MapleStoryClass"), 0))
   {
      for(;;)
      {
         _PostMessageA(MapleWnd, WM_KEYDOWN, 0x5A, (MapVirtualKey(0x5A, 0) << 16));
         Sleep(Delay);
      }
   }
   return 0;
}
And on the text box I want to get the delay time from is set on 100. It compiles perfect but it just spam the z button without a delay. I've been trying this for a couple of hours but havn't gotten it to work. I've googled for a solution but didn't find one. I know I could just write Sleep(100); instead but I want to be able to change the delay whenever I want.
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Mon Sep 15, 2008 1:43 pm    Post subject: Reply with quote

You're getting char's from it, not an int.

try GetDlgItemInt
Back to top
View user's profile Send private message
TraxMate
Master Cheater
Reputation: 0

Joined: 01 Mar 2008
Posts: 363

PostPosted: Tue Sep 16, 2008 1:51 pm    Post subject: Reply with quote

LOL wtf??? I didn't even had anything related to x e n t a r's trainer in the last post :S. Just saw that now... -.-. I tried GetDlgItemInt but didn't work :/. Could you maybe give me a code snippet on how to retrieve a text from atext box?
Back to top
View user's profile Send private message
Fuzz
Grandmaster Cheater
Reputation: 0

Joined: 12 Nov 2006
Posts: 531

PostPosted: Tue Sep 16, 2008 4:48 pm    Post subject: Reply with quote

slovach wrote:
You're getting char's from it, not an int.

try GetDlgItemInt



If you'r going to do GetdlgItemInt, can you post how to use SetDlgItemInt Very Happy.


And to TraxMate: Sleep(100)?

_________________
Back to top
View user's profile Send private message AIM Address
sponge
I'm a spammer
Reputation: 1

Joined: 07 Nov 2006
Posts: 6009

PostPosted: Tue Sep 16, 2008 5:01 pm    Post subject: Reply with quote

Quote:
GetWindowText()

_________________
Back to top
View user's profile Send private message
TraxMate
Master Cheater
Reputation: 0

Joined: 01 Mar 2008
Posts: 363

PostPosted: Wed Sep 17, 2008 2:32 am    Post subject: Reply with quote

Fuzz wrote:
slovach wrote:
You're getting char's from it, not an int.

try GetDlgItemInt



If you'r going to do GetdlgItemInt, can you post how to use SetDlgItemInt Very Happy.


And to TraxMate: Sleep(100)?

I'm using Sleep(100); but want to be able to change the delay while using the trainer :p.

sponge wrote:
Quote:
GetWindowText()
Will try that now.
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Wed Sep 17, 2008 11:45 am    Post subject: Reply with quote

GetDlgItemInt:
Code:

int Delay = GetDlgItemInt(hWnd,IDC_DELAY_EDIT,0,0);

hWnd - handle to your trainer
IDC_DELAY_EDIT - the Edit contol's Id
then you get the value that was entered to the edit control as int and not as string

_________________
Stylo
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 1, 2  Next
Page 1 of 2

 
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