nf67 Posted September 17, 2009 Share Posted September 17, 2009 (edited) Hi there, I am trying to write a script which sends random keystrokes instead of the actual pressed (lower- or uppercase) key. However, I have not been able to find out how to get the key sent correctly, as the following didn't seem to work the way I intended it to: Send(Chr(Random(97, 122, 1))) ;Lowercase character Send(Chr(Random(65, 90, 1))) ;Uppercase character Here's my script, if you comment out the hotkeysets for the random functions and enabling the YouPressed function instead it works fine though... expandcollapse popup#Include <Misc.au3> HotKeySet("{ESC}", "Quit") HotKeySet("{NUMPADADD}", "BindKeys") While 1 WEnd Func BindKeys() For $BindUpper = 65 To 90 HotKeySet(Chr($BindUpper), "RandomUpper") ;HotKeySet(Chr($BindUpper), "YouPressed") Next For $BindLower = 97 To 122 HotKeySet(Chr($BindLower), "RandomLower") ;HotKeySet(Chr($BindLower), "YouPressed") Next While 1 If _IsPressed("2D") = 1 Then UnbindKeys() EndIf WEnd EndFunc Func YouPressed() Local $Key = @HotKeyPressed MsgBox(0, "You pressed...", "The " & $Key & " key.") EndFunc Func RandomUpper() Send(Chr(Random(65, 90, 1))) EndFunc Func RandomLower() Send(Chr(Random(97, 122, 1))) EndFunc Func UnbindKeys() For $UnbindUpper = 65 To 90 HotKeySet(Chr($UnbindUpper)) Next For $UnbindLower = 97 To 122 HotKeySet(Chr($UnbindLower)) Next EndFunc Func Quit() Exit EndFunc Thank you, and please remove if it's too KL related. note to self: sending the random triggers the function again sending another random which triggers it again which- etc. Edited October 2, 2009 by nf67 Link to comment Share on other sites More sharing options...
nf67 Posted September 18, 2009 Author Share Posted September 18, 2009 Anyone ? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now