Jump to content
Sign in to follow this  
randomboy

Random Keys

Recommended Posts

Func _IsPressed($s_hexKey, $v_dll = 'user32.dll')
    Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey)
    If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
    Return 0
EndFunc
$dll = DllOpen("user32.dll")
$r = Send("{BS}p")
While 1
    sleep (50)
        If _IsPressed("41") Then
            Send("{BS}h")
        EndIf

I have been working with the above code and I'm trying to create a script where a user hits a key and the program sends out a random key. I have managed to set the program to send out set letters but not random letters. Can anyone help me?

Thanks


I got inside my house, leant back on my bed and began to think...where the hell was my roof?!?!24 hours in a day....24 beers in a case....Coincidence??

Share this post


Link to post
Share on other sites

Random + Loop + Chr()


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Thank you very much


I got inside my house, leant back on my bed and began to think...where the hell was my roof?!?!24 hours in a day....24 beers in a case....Coincidence??

Share this post


Link to post
Share on other sites

Actually I don't understand what SmOke_N has told me to do. Can someone help?

Edited by randomboy

I got inside my house, leant back on my bed and began to think...where the hell was my roof?!?!24 hours in a day....24 beers in a case....Coincidence??

Share this post


Link to post
Share on other sites

Func _IsPressed($s_hexKey, $v_dll = 'user32.dll')
    Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey)
    If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
    Return 0
EndFunc
$dll = DllOpen("user32.dll")
;$r = Send("{BS}p")
While 1
    sleep (50)
        If _IsPressed("41") Then
            $key=Random(65,90)
            $key1=chr($key)
            msgbox(0,"Key sent",$key1)
            ;Send("{BS}h")
        EndIf 
Wend

Remember it will still send the original key



Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

When I tried it it didn't really work.

Edited by randomboy

I got inside my house, leant back on my bed and began to think...where the hell was my roof?!?!24 hours in a day....24 beers in a case....Coincidence??

Share this post


Link to post
Share on other sites

Func _IsPressed($s_hexKey, $v_dll = 'user32.dll')
    Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey)
    If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
    Return 0
EndFunc
$dll = DllOpen("user32.dll")
While 1
    sleep (50)
        If _IsPressed("41") Then
            $key=Random(65,90)
            Send($key)
        EndIf
Wend

I tried the above code and it gave me the following output.

a75.3041700553149a71.0769480129238a66.9570499367546a80.7049670582637

I think it just gave me random numbers between 65 and 90.

Does anyone know what has happened and what I need to do to solve it?

Edited by randomboy

I got inside my house, leant back on my bed and began to think...where the hell was my roof?!?!24 hours in a day....24 beers in a case....Coincidence??

Share this post


Link to post
Share on other sites

Not to worry I solved it.


I got inside my house, leant back on my bed and began to think...where the hell was my roof?!?!24 hours in a day....24 beers in a case....Coincidence??

Share this post


Link to post
Share on other sites

You forgot

key1=chr($key)
send($key1)


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

Yeah I realised I forgot that but thanks anyway.


I got inside my house, leant back on my bed and began to think...where the hell was my roof?!?!24 hours in a day....24 beers in a case....Coincidence??

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...