Jump to content

Help Please, Script not working.


Recommended Posts

Guest XxEggOfEvilxX
Posted

Hey, here is my very simple script:

While 1

$coord2 = PixelSearch( 1, 300, 800, 600, 0xA8A888, 0, 3 )

While @error = 0

Send("{LCTRL}")

Sleep (1000)

$coord2 = PixelSearch( 1, 300, 800, 600, 0xA8A888, 0, 3 )

WEnd

WEnd

Basically, I want to press the Left CTRL button once per second when there is that shade of white in the bottom half of an 800x600 screen. For some reason, it just doesn't work. Could someone please check it over and see if I did anything wrong? This is my first script.

Thanks!

Posted

PixelSearch ( left, top, right, bottom, color [, shade-variation] [, step]] )

Hmm... perhapse allowing for a shade variation? what game are you trying to detect what on?

Ooo Ëxçã¿îbúr ooO"Information Is Not Knowledge." ~Albert Einstein
Guest XxEggOfEvilxX
Posted

PixelSearch ( left, top, right, bottom, color [, shade-variation] [, step]] )

Hmm... perhapse allowing for a shade variation? what game are you trying to detect what on?

Ahh, the shade variation. That got it working. Thanks!

Hmm..now I need to figure out a way to stop the loop every 5 minutes, press some keys, and then continue with the loop. Anyone have any idea how to do this?

Posted

Ahh, the shade variation. That got it working. Thanks!

Hmm..now I need to figure out a way to stop the loop every 5 minutes, press some keys, and then continue with the loop. Anyone have any idea how to do this?

Look into these functions:

TimerInit()

TimerDiff(), these two will help you with the 5 minute thing

HotKeySet() , for your key presses.

-CMR

Posted (edited)

How about:

local $timer

while 1

$timer = timerInit()

while timerDiff($timer) < 5 * 60 * 1000

; do pixel things

wEnd

; do key things

wEnd
P.S. Welcome to the forums!

P.S. I've been beaten to it!

Edited by LxP
Guest XxEggOfEvilxX
Posted

Ahh, thanks! Here is my script so far:

While 1

local $timer

$timer = timerInit()

While timerDiff($timer) < 300000

$coord2 = PixelSearch( 575, 390, 680, 410, 0x88A860, 5, 5 )

While @error = 0

Send("{LCTRL}")

Sleep (1000)

$coord2 = PixelSearch( 575, 390, 680, 410, 0x88A860, 5, 5 )

WEnd

WEnd

While timerDiff($timer) > 300000

While timerDiff($timer) < 301000

Send("{LEFT}")

Sleep (750)

Send("{RIGHT}")

Sleep (5000)

WEnd

WEnd

WEnd

It seems that it loops flawlessly for 5 minutes, presses LEFT and RIGHT, and then stops. I assume this is because the timer is not getting reset or something. I couldn't find anything in the help file about resetting the timer...

Is there a command to reset the timer? or could my script be laid out differently?

Posted (edited)

press "F8" to re-run the script

HotKeySet("{F8}", "Play_it_again_sam")

While 2
    sleep(100)
WEnd

Func Play_it_again_sam()
    
While 1
local $timer
$timer = timerInit()
While timerDiff($timer) < 300000
$coord2 = PixelSearch( 575, 390, 680, 410, 0x88A860, 5, 5 )
While @error = 0
Send("{LCTRL}")
Sleep (1000)
$coord2 = PixelSearch( 575, 390, 680, 410, 0x88A860, 5, 5 )
WEnd
WEnd
While timerDiff($timer) > 300000
While timerDiff($timer) < 301000
Send("{LEFT}")
Sleep (750)
Send("{RIGHT}")
Sleep (5000)
WEnd
WEnd
WEnd

EndFunc

Actually with a name like... XxEggOfEvilxX ( might be great for a game name)

i'm amazed people decided to help you

8)

Edited by Valuater

NEWHeader1.png

Guest XxEggOfEvilxX
Posted

Thanks! I threw in a Send({F8}) at the end so it will loop FOREVAR!!! *evil laughter*

Posted (edited)

It seems that it loops flawlessly for 5 minutes, presses LEFT and RIGHT, and then stops. I assume this is because the timer is not getting reset or something. I couldn't find anything in the help file about resetting the timer...

You seem to have a few unnecessary While..WEnd loops -- this may be skewing the logic of your script. Try this:

local $timer

while 1

$timer = timerInit()

while timerDiff($timer) < 300000

$coord2 = pixelSearch(575, 390, 680, 410, 0x88a860, 5, 5)

if not(@error) then

send("{LCTRL}")

sleep(900)

endIf

; 100ms of sleep time here to avoid CPU abuse

sleep(100)

wEnd

; at this point five minutes is up

send("{LEFT}")

sleep(750)

send("{RIGHT}")

sleep(5000)

wEnd
Edit: Gotta have the fixed-width font.

Actually with a name like... XxEggOfEvilxX ( might be great for a game name)

i'm amazed people decided to help you

8)

Nah, this guy seems okay -- he actually 'takes time' (or 'knows how') to punctuate and capitalise! (i dun fink i cn stand teh litl bratz hu cum on2 d bordz excreetin incomprehensible crap liek dis. omg wtf lol.) Edited by LxP

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
×
×
  • Create New...