Sign in to follow this  
Followers 0
LegacyWeapon

Pressing buttons stop working

7 posts in this topic

I wrote this script to play Dice Escape for me on Neopets (thinking this would be quite easy since it's a bunch of pressing arrow keys).

;Find Arrow Position
$coord = PixelSearch( 0, 0, 600, 800, 0xF1EE72, 10 )
If @error Then
 MsgBox(0, "Dice Escape", "Error at finding pixel!")
 Exit
EndIf

;Check Left/Right Mouse Buttons
Dim $primary
Dim $secondary
$k = RegRead("HKEY_CURRENT_USER\Control Panel\Mouse", "SwapMouseButtons")
If $k = 1 Then
 $primary = "right"
 $secondary = "left"
Else;normal (also case if could not read registry key)
 $primary = "left"
 $secondary = "right"
EndIf
MouseMove($coord[0]+50, $coord[1])
MouseClick($primary)
Sleep(5000)

AutoItSetOption("SendKeyDelay", 500)

Level1()
Sleep(2000)
Level2()
Sleep(2000)
Level3()

Exit

Func Level1()

Send("{UP}{UP}{UP}{UP}{UP}")
Sleep(5000)
Send("N")

EndFunc


Func Level2()

Send("{UP}{UP}{RIGHT}{RIGHT}{DOWN}{LEFT}")
Sleep(5000)
Send("N")

EndFunc

Func Level3()

Send("{UP}{UP}")
Sleep(4000)
Send("{UP}{UP}{RIGHT}{UP}{UP}{RIGHT}{LEFT}{LEFT}")
Sleep(5000)
Send("N")

EndFunc
Strangely at level 3 it doesn't seem to press a lot of the arrow keys...

Share this post


Link to post
Share on other sites



this is done so fast... that maybe the system isn't ready ... so

slow it down a little and that may help

send up + up

sleep(10)

send right + right

sleep (10)

etc... etc...

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Notice this line in the code:

AutoItSetOption("SendKeyDelay", 500)

Share this post


Link to post
Share on other sites

This probably won't help you but I believe that the following code:

;Check Left/Right Mouse Buttons
Dim $primary
Dim $secondary
$k = RegRead("HKEY_CURRENT_USER\Control Panel\Mouse", "SwapMouseButtons")
If $k = 1 Then
$primary = "right"
$secondary = "left"
Else;normal (also case if could not read registry key)
$primary = "left"
$secondary = "right"
EndIf
MouseMove($coord[0]+50, $coord[1])
MouseClick($primary)

can be expressed as simply:

mouseClick("primary", $coord[0] + 50, $coord[1])

Share this post


Link to post
Share on other sites

Try adding this near the beginning:

opt("sendKeyDownDelay", 100)

The default for this is 1ms, which is like tapping your keys hard and super-fast. Generally that won't work for games.

Share this post


Link to post
Share on other sites

Oh thanks it works now :whistle:

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

One more thing which may make your script easier to maintain: it's possible to combine multiple consecutive presses of a key into one code like so:

send("{UP}{UP}{UP}{UP}{UP}")
; is identical to
send("{UP 5}")

All the best!

Edited by LxP

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