Jump to content

Pressing buttons stop working


Recommended Posts

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...
Link to comment
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])
Link to comment
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.

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...