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 


[DELPHI] Problem with a procedure
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
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Mon Jan 28, 2008 3:15 pm    Post subject: [DELPHI] Problem with a procedure Reply with quote

hey,

I made a procedure for my bot (for autochatter).

Code:
procedure SendText(AText: String);
var lCount, Ky : Integer;
    lScanCode  : Smallint;
    h          : HWND;
    lWithShift : Boolean;
begin
h := FindWindow('MapleStoryClass', nil);
for lCount := 1 To Length(AText) Do
  begin
    lWithShift := lScanCode and (1 shl 8)  <> 0;
    lScanCode := VkKeyScan(AText[lCount]);

    if lWithShift then
    PMH(h, WM_KeyDown, VK_SHIFT, 2752512);

    PMH(h, WM_KeyDown, lScanCode, 0);

    if lWithShift then
    PMH(h, WM_KeyUp, VK_SHIFT, 2752512);
  end;
end;


Well PMH is rehooked PostMessageA.
It works great! But it doesn't click shift if IScanCode has a capital letter.

And what is also weird is if I use

Code:
    PMH(h, WM_KeyDown, lScanCode, 0);
    PMH(h, WM_KeyUp, lScanCode, 0);


It writes every letter of AText twice. I dunno why.
Help please .)
Back to top
View user's profile Send private message
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Mon Jan 28, 2008 7:14 pm    Post subject: Reply with quote

Code:
lWithShift := lScanCode and (1 shl 8)  <> 0;


IScanCode isn't initialized. You gave IScanCode a value after you compared it with 'and.'
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Mon Jan 28, 2008 7:16 pm    Post subject: Reply with quote

Code:
procedure SendText(AText: String);
var lCount, Ky : Integer;
    lScanCode  : Smallint;
    h          : HWND;
    lWithShift : Boolean;
begin
h := FindWindow('MapleStoryClass', nil);
for lCount := 1 To Length(AText) Do
  begin
    lScanCode := VkKeyScan(AText[lCount]);
    lWithShift := lScanCode and (1 shl 8)  <> 0;
   
    if lWithShift then
    PMH(h, WM_KeyDown, VK_SHIFT, 2752512);

    PMH(h, WM_KeyDown, lScanCode, 0);

    if lWithShift then
    PMH(h, WM_KeyUp, VK_SHIFT, 2752512);
  end;
end;[code][/code]

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

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Mon Jan 28, 2008 7:20 pm    Post subject: Reply with quote

Cool One misplaced line...
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Wed Jan 30, 2008 11:00 am    Post subject: Reply with quote

Oh yea...I overlooked that..thanks.
But it's still not working. Sad

I took that from this:

Code:
procedure EnterText(AText: String);
var lCount     : Integer;
    lScanCode  : Smallint;
    lWithAlt,
    lWithCtrl,
    lWithShift : Boolean;
begin
  for lCount := 1 To Length(AText) Do
  begin
    lScanCode := VkKeyScan(AText[lCount]);
    //Ermitteln ob Shift gedrückt wurde   // aka check if Shift is pressed
    lWithShift := lScanCode and (1 shl 8)  <> 0;
    //Ermitteln ob Strg gedrückt wurde   // aka check if CTRL is pressed
    lWithCtrl  := lScanCode and (1 shl 9)  <> 0;
    //Ermitteln ob Alt gedrückt wurde   // aka check if ALT is pressed
    lWithAlt   := lScanCode and (1 shl 10) <> 0;

    if lWithShift then
      keybd_event(VK_SHIFT, 0, 0, 0);
    if lWithCtrl then
      keybd_event(VK_CONTROL, 0, 0, 0);
    if lWithAlt then
      keybd_event(VK_MENU, 0, 0, 0);

    keybd_event(lScanCode, 0, 0, 0);
    keybd_event(lScanCode, 0, KEYEVENTF_KEYUP, 0);

    if lWithAlt then
      keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
    if lWithCtrl then
      keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
    if lWithShift then
      keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
  end;
end;


But I also tried it with keybd_event = Shift and the actual key via PMA. still not working.
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Wed Jan 30, 2008 11:03 am    Post subject: Reply with quote

Here you go, although you insulted me:

Code:
Procedure SendText(WindowCaption:HWND;TextMessage: String);
var lCount     : Integer;
    lScanCode  : Smallint;
    lWithAlt,
    lWithCtrl,
    lWithShift : Boolean;
    A,B,C:DWORD; //Added DWORD declaration
begin
  for lCount := 1 To Length(TextMessage) Do
  begin
    lScanCode := VkKeyScan(TextMessage[lCount]);

    lWithShift := lScanCode and (1 shl 8)  <> 0;

    lWithCtrl  := lScanCode and (1 shl 9)  <> 0;

    lWithAlt   := lScanCode and (1 shl 10) <> 0;

    A:=MapVirtualKey(Cardinal(lWithShift),0);
    A:=A shl 16;

    B:=MapVirtualKey(Cardinal(lWithCtrl),0);
    B:=B shl 16;

    C:=MapVirtualKey(Cardinal(lWithAlt),0);
    C:=C shl 16;

    if lWithShift then
      PMX(WindowCaption,WM_KEYDOWN,A,0);

    if lWithCtrl then
      PMX(WindowCaption,WM_KEYDOWN,B,0);
     
    if lWithAlt then
      PMX(WindowCaption,WM_KEYDOWN,C,0);



    PMX(WindowCaption,WM_CHAR,lScanCode,0);

   

    if lWithAlt then
      PMX(WindowCaption,WM_KEYUP,A,0);

    if lWithCtrl then
      PMX(WindowCaption,WM_KEYUP,B,0);
     
    if lWithShift then
      PMX(WindowCaption,WM_KEYUP,C,0);
     
  end;
end;


replace PMX with your hhPostMEssage() or w.e you're using.

tested and works.

i suggest you using Setforegroundwindow(); to make it minimized

SendText(h,'OMG !!');

h:=Setforegroundwindow(B);

B:=FindWindow('MapleStoryClass',nil);

Edit: To avoid flames i used EnterText(); and made it send a text to a handle, i dedicated it to reakw0n
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Wed Jan 30, 2008 12:43 pm    Post subject: Reply with quote

Nice...it's not working.

I tried out many ways but I gotta find a way that WM_KeyDown on Shift makes the Shift button down until I make WM_KeyUp.

But how?
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Wed Jan 30, 2008 12:49 pm    Post subject: Reply with quote

hey hey, instead of HWND make it PAnsiChar
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Wed Jan 30, 2008 12:50 pm    Post subject: Reply with quote

It doesn't matters if shift key is down, if you send a lower case letter it will send it lower case, pressing shift on the keyboard just changing the char case...
Just send the letters capital?
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Wed Jan 30, 2008 12:57 pm    Post subject: Reply with quote

Symbol wrote:
It doesn't matters if shift key is down, if you send a lower case letter it will send it lower case, pressing shift on the keyboard just changing the char case...
Just send the letters capital?


Yes but how?
I already tried using VkKeyScanEx() but didn't really help.
Any idea?
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Wed Jan 30, 2008 1:04 pm    Post subject: Reply with quote

I don't know what you have to do to post message in MapleStory, in a chat I think it works just fine, so type in the text box with captial letters and just send Edit1.Text[i] or whatever...
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Wed Jan 30, 2008 1:27 pm    Post subject: Reply with quote

No this does not work.
But I have no idea why. It's weird because a 1 and ! has different values but it always sends a 1.

Edit: Hahaha your sig made be loling hard for a while...Very Happy
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Wed Jan 30, 2008 1:30 pm    Post subject: Reply with quote

Try this:

Fixed it

Code:
Procedure SendText(WindowCaption:HWND;TextMessage: String);
var lCount     : Integer;
    lScanCode  : Smallint;
    lWithAlt,
    lWithCtrl,
    lWithShift : Boolean;
    A,B,C:DWORD; //Added DWORD declaration
begin
  for lCount := 1 To Length(TextMessage) Do
  begin
    lScanCode := VkKeyScan(TextMessage[lCount]);

    lWithShift := lScanCode and (1 shl 8)  <> 0;

    lWithCtrl  := lScanCode and (1 shl 9)  <> 0;

    lWithAlt   := lScanCode and (1 shl 10) <> 0;

    A:=MapVirtualKey($10,0);
    A:=A shl 16;

    B:=MapVirtualKey($11,0);
    B:=B shl 16;

    C:=MapVirtualKey($12,0);
    C:=C shl 16;

    if lWithShift then
      PMX(WindowCaption,WM_KEYDOWN,A,0);

    if lWithCtrl then
      PMX(WindowCaption,WM_KEYDOWN,B,0);
     
    if lWithAlt then
      PMX(WindowCaption,WM_KEYDOWN,C,0);

    PMX(WindowCaption,WM_KEYDOWN,lScanCode,0);
    PMX(WindowCaption,WM_KEYUP,lScanCode,0);

    if lWithAlt then
      PMX(WindowCaption,WM_KEYUP,A,0);

    if lWithCtrl then
      PMX(WindowCaption,WM_KEYUP,B,0);
     
    if lWithShift then
      PMX(WindowCaption,WM_KEYUP,C,0);
     
  end;
end;
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Wed Jan 30, 2008 1:46 pm    Post subject: Reply with quote

No. It won't let Shift anc co. pressed down until it gets KeyUp.
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Wed Jan 30, 2008 2:08 pm    Post subject: Reply with quote

Why don't you just send 'A' instead of 'a'? Confused
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