Jump to content
Sign in to follow this  
rosenman

Need Help With Writing a Script

Recommended Posts

rosenman

Hi, guys.I'm new in the forum.Sorry for the stupid post but i'm actually don't understand the program quiet well.My question is that, is there possibility anybody to write me a script.I think that the script wouldn't be long.I need AutoIT to scan area of the screen for a color and when the color pop up the script to click at left shift button.I use resolution 800x600 and the scan area have to be 370-420 at X and 110-160 at Y coordinates.Thanks in advance people.

Share this post


Link to post
Share on other sites
TehWhale

Some great functions to use:

PixelSearch()

MouseClick()

Send()

Check the helpfile on these, and read up about them!

A Example:

$Color = color goes here...

While 1
$Pixel = PixelSearch(370, 420, 110, 160, $Color, 5)
Send("{Shift Down}")
MouseClick("left", $Pixel[0], $Pixel[1])
Send("{Shift Up}")
WEnd

Warning: The above code may not work. It is an example to show you how to do this.

Share this post


Link to post
Share on other sites
rosenman

Well a minute before read your post i write something like that you post here.

;NFS Underground 2
While 1
$Pixel = PixelSearch( 370, 420, 110, 160, 0x00FE00)
Send("LSHIFT")
Wend

But when i start that script if it gets the color in the scan area it starts to push SHIFT and never stops.

Is there any way to avoid that?

Share this post


Link to post
Share on other sites
TehWhale

Try using:

If Not @Error Then
Send("{LSHIFT}")
MouseClick("Left", $Pixel[0], $Pixe[1])
EndIf

But you can always set it to a hotkey, if it is working too fast for you.

Share this post


Link to post
Share on other sites
rosenman

This time nothing happens.Only slow down computer.

Share this post


Link to post
Share on other sites
TehWhale

That's probably because it didn't find the pixel your looking for.

Share this post


Link to post
Share on other sites
rosenman

Can you see the picture that i attached to this post.See the cords i think that i'm not making mistake.

post-36729-1213493504_thumb.jpg

Share this post


Link to post
Share on other sites
rosenman

Finally i wrote a code that works but not full functionally.

WinWaitActive("NFS Underground 2 - Window Mode By Wiccaan")
While 1
$pixel=PixelSearch(0,0,800,600,0x00FE00)
If IsArray($pixel) = 1 Then
Send("{LSHIFT}")
EndIf
WEnd

Is there a way to speed up the things because when i start the script my pc lags...

I stop everything except the game and the script.I make the game 640x480 and low the graphic details and still when i run the script my pc lags.It cant respond as quickly as i want to :) Is there any way to avoid that lag?

I think i have to make the script to scan not the full screen but only the spot with exact color but i don't know how.

Can anyone help me?

Edited by rosenman

Share this post


Link to post
Share on other sites
TehWhale

Set specific coordinates where the shift up thing is, and set a small sleep in your loop because it's CONSTANTLY checking for that pixel, slow it down to like: Sleep(10).

With Best Hopes, J.B.

Share this post


Link to post
Share on other sites
rosenman

Would you help me with setting the pixel scan?I cannot understand what to put in the $pixel=PixelSearch(0,0,800,600,0x00FE00).

How to set here X to X axis and Y to Y axis?

Thanks in advance.

Share this post


Link to post
Share on other sites
rosenman

I look the code for PixelSearch:

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

Than i Fill it up.

Left pixel = 460

Top pixel = 165

Right Pixel = 465

Bottom pixel = 170

Color = 0x00FE00

PixelSearch (460,165,465,170,0x00FE00)

And this not works for me.When i change it to

PixelSearch (0,0,465,170,0x00FE00)

Than it works but still slow down the pc.

How to make the PixelSearch to search only in this 5 pixel square

from X axis 460-465 and Y axis 165-170.

Please help.

Share this post


Link to post
Share on other sites
TehWhale

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

Set the Step to 5.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.