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 


how to find value of key pressed in delphi
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
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Fri Jun 06, 2008 10:40 pm    Post subject: how to find value of key pressed in delphi Reply with quote

im trying to find the virtual key value of a key pressed in delphi so i can set it to a variable, i can use GetASyncKeyState, but that requires a load of ifs, anyway to just set it straight to a variable
_________________
Back to top
View user's profile Send private message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Sat Jun 07, 2008 12:21 am    Post subject: Reply with quote

CreateWindowsHookEx() using the LL_HOOK message, I believe it is. You should set up a low level keyboard hook with that API.

I'm sure there are plenty examples on the web.

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Sat Jun 07, 2008 12:30 am    Post subject: Reply with quote

thanks, i will have a look around
_________________
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Sat Jun 07, 2008 9:16 am    Post subject: Reply with quote

He's not trying to create a hotkey, or at least I don't think. Because he said he wants to store it in a variable.
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Sat Jun 07, 2008 9:33 am    Post subject: Reply with quote

I'm guessing he wants custom input keys for his MS bot.
Have the user press a button to set the key. When the button is pressed, call a new function:
Code:

do{GetMessage( &msg, NULL, 0, 0 )}
while(msg.message != WM_KEYDOWN)
return msg.wParam;

_________________
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Sat Jun 07, 2008 9:50 am    Post subject: Reply with quote

Code:

DWORD vk;
while(GetMessage(&msg, NULL, 0, 0) > 0) {
   if(msg.message != WM_KEYDOWN) {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
   }
   else {
      //get vk here not sure how though
   }
return msg.wParam;


I'm not quite sure how to get the vk. Could you do like...

Code:

else {
   vk = (DWORD)msg.wParam;
}


Because the vk would be in the wParam right? Like if they hit the 'z' key, then the wParam would be 0x5A.

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Sat Jun 07, 2008 9:56 am    Post subject: Reply with quote

wParam is a DWORD, 4 bytes
The WM_KEYDOWN is broken up liek: http://msdn.microsoft.com/en-us/library/ms646280(VS.85).aspx
If you just want to get the 1 byte scancode which is 1 byte into the wParam, you could try something like:
Code:
BYTE vk = (BYTE)*(((void*)(msg.wParam))+1)


EDIT: disregard the above was thinking about lparam
wParam is a DWORD, 4 bytes, but all it contains is the scancode.
Code:
BYTE vk = msg.wParam;

should work.

_________________


Last edited by HalfPrime on Sat Jun 07, 2008 10:04 am; edited 2 times in total
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Sat Jun 07, 2008 10:02 am    Post subject: Reply with quote

Code:

BYTE vk;
while(GetMessage(&msg, NULL, 0, 0) > 0) {
   if(msg.message != WM_KEYDOWN) {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
   }
   else {
      vk = msg.wParam;
   }
}
return msg.wParam;

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing


Last edited by oib111 on Sat Jun 07, 2008 10:29 am; edited 1 time in total
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Sat Jun 07, 2008 10:10 am    Post subject: Reply with quote

That'll give you the scankey code instead of the virtual key code.
_________________
Back to top
View user's profile Send private message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Sat Jun 07, 2008 10:34 am    Post subject: Reply with quote

how would you get the vk then?
_________________
Back to top
View user's profile Send private message
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Sat Jun 07, 2008 10:35 am    Post subject: Reply with quote

HalfPrime wrote:
Code:
BYTE vk = msg.wParam;

should work.

_________________
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Sat Jun 07, 2008 10:36 am    Post subject: Reply with quote

oib111 wrote:
Code:

BYTE vk;
while(GetMessage(&msg, NULL, 0, 0) > 0) {
   if(msg.message != WM_KEYDOWN) {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
   }
   else {
      vk = msg.wParam;
   }
}
return msg.wParam;

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8588
Location: 127.0.0.1

PostPosted: Sat Jun 07, 2008 12:18 pm    Post subject: Reply with quote

Some more insight on this:
http://msdn.microsoft.com/en-us/library/ms646268(VS.85).aspx

You can make your own version of GetKeyboardState as well handling WM_KEYDOWN and WM_KEYUP with your own array. Which you would commonly see done in game programming to handle key events.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Dark Byte
Site Admin
Reputation: 475

Joined: 09 May 2003
Posts: 25974
Location: The netherlands

PostPosted: Sat Jun 07, 2008 12:22 pm    Post subject: Re: how to find value of key pressed in delphi Reply with quote

Snootae wrote:
im trying to find the virtual key value of a key pressed in delphi so i can set it to a variable, i can use GetASyncKeyState, but that requires a load of ifs, anyway to just set it straight to a variable


Try the onkeydown event on the focused object. key will contain the virtual key value

_________________
Tools give you results. Knowledge gives you control.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Sat Jun 07, 2008 1:35 pm    Post subject: Reply with quote

HalfPrime wrote:
wParam is a DWORD, 4 bytes
The WM_KEYDOWN is broken up liek: http://msdn.microsoft.com/en-us/library/ms646280(VS.85).aspx
If you just want to get the 1 byte scancode which is 1 byte into the wParam, you could try something like:
Code:
BYTE vk = (BYTE)*(((void*)(msg.wParam))+1)


EDIT: disregard the above was thinking about lparam
wParam is a DWORD, 4 bytes, but all it contains is the scancode.
Code:
BYTE vk = msg.wParam;

should work.


wParam = WORD (2 Bytes) Parameter, lParam = LONG (LongInt) Parameter

Check this out - http://rot1blg.wordpress.com/2008/05/16/table-of-contents/
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