 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Reak I post too much
Reputation: 0
Joined: 15 May 2007 Posts: 3496
|
Posted: Mon Jan 28, 2008 3:15 pm Post subject: [DELPHI] Problem with a procedure |
|
|
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 |
|
 |
rapion124 Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Mar 2007 Posts: 1095
|
Posted: Mon Jan 28, 2008 7:14 pm Post subject: |
|
|
| 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 |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Mon Jan 28, 2008 7:16 pm Post subject: |
|
|
| 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 |
|
 |
rapion124 Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Mar 2007 Posts: 1095
|
Posted: Mon Jan 28, 2008 7:20 pm Post subject: |
|
|
One misplaced line...
|
|
| Back to top |
|
 |
Reak I post too much
Reputation: 0
Joined: 15 May 2007 Posts: 3496
|
Posted: Wed Jan 30, 2008 11:00 am Post subject: |
|
|
Oh yea...I overlooked that..thanks.
But it's still not working.
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 |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Wed Jan 30, 2008 11:03 am Post subject: |
|
|
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 |
|
 |
Reak I post too much
Reputation: 0
Joined: 15 May 2007 Posts: 3496
|
Posted: Wed Jan 30, 2008 12:43 pm Post subject: |
|
|
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 |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Wed Jan 30, 2008 12:49 pm Post subject: |
|
|
| hey hey, instead of HWND make it PAnsiChar
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Wed Jan 30, 2008 12:50 pm Post subject: |
|
|
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 |
|
 |
Reak I post too much
Reputation: 0
Joined: 15 May 2007 Posts: 3496
|
Posted: Wed Jan 30, 2008 12:57 pm Post subject: |
|
|
| 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 |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Wed Jan 30, 2008 1:04 pm Post subject: |
|
|
| 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 |
|
 |
Reak I post too much
Reputation: 0
Joined: 15 May 2007 Posts: 3496
|
Posted: Wed Jan 30, 2008 1:27 pm Post subject: |
|
|
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...
|
|
| Back to top |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Wed Jan 30, 2008 1:30 pm Post subject: |
|
|
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 |
|
 |
Reak I post too much
Reputation: 0
Joined: 15 May 2007 Posts: 3496
|
Posted: Wed Jan 30, 2008 1:46 pm Post subject: |
|
|
| No. It won't let Shift anc co. pressed down until it gets KeyUp.
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Wed Jan 30, 2008 2:08 pm Post subject: |
|
|
Why don't you just send 'A' instead of 'a'?
|
|
| 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
|
|