Sign in to follow this  
Followers 0
Minikori

Record a single key press

3 posts in this topic

Hey, I'm making a function in my script that records a single key that the user presses, but if the user presses escape, it cancels. I know MacroGamer has a function like this, and I've got it's piece of code containing it, but I can't fully understand how it works and what I need to change so it fits my script, here's the code:

CODE
Func GetKeyPressed($gui)

If $gui <> "" Then

while 1

for $i = 8 to 222 ;Accept 102 Standard KeyBoard Input (US)

If _IsPressed(hex($i,2)) Then

If StringRegExp($keyboardLayout[$i],"(CTRL)|(ALT)|(SHIFT)|(WIN)") Then

Select

Case $gui = "editor"

GUICtrlSetData($in_bindkey,$keyboardLayout[$i] & "+")

Local $key = GetKeyPressed("") ;recursive call

GUICtrlSetData($in_bindkey,$keyboardLayout[$i] & "+" & $key)

Return GUICtrlRead($in_bindkey)

Case $gui = "onoff"

GUICtrlSetData($Option_in_ONOFF,$keyboardLayout[$i] & "+")

Local $key = GetKeyPressed("") ;recursive call

GUICtrlSetData($Option_in_ONOFF,$keyboardLayout[$i] & "+" & $key)

Return GUICtrlRead($Option_in_ONOFF)

Case $gui = "recstartstop"

GUICtrlSetData($Option_in_Record,$keyboardLayout[$i] & "+")

Local $key = GetKeyPressed("") ;recursive call

GUICtrlSetData($Option_in_Record,$keyboardLayout[$i] & "+" & $key)

Return GUICtrlRead($Option_in_Record)

Case Else

EndSelect

EndIf

Return $keyboardLayout[$i]

EndIf

Next

wend

Else

while 1

for $i = 8 to 222 ;Accept 102 Standard KeyBoard Input (US)

If _IsPressed(hex($i,2)) And StringRegExp($keyboardLayout[$i],"(CTRL)|(ALT)|(WIN)|(SHIFT)") <> 1 Then

Return $keyboardLayout[$i]

EndIf

Next

wend

EndIf

EndFunc ;GetKeyPressed()==>

If your going to reply with modified code, just use a fake GUIControl.


For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Share this post


Link to post
Share on other sites



Bump.


For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Share this post


Link to post
Share on other sites

Bump.


For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0