Jump to content
Sign in to follow this  
Bigred2k

simple script help

Recommended Posts

Bigred2k

I need some help writing a very simple script that searches a area of the screen for a certain color and if found sends a keypress.

The script should work like so:

When numpad 7 is pressed, autoit should send a keypress of "W", search the pixel range of 560,620(top left pixel)/580,645(bottom right pixel), wait till it finds color#1, send 2nd "W" keypress

When numpad 8 is pressed, autoit should send a keypress of "W", search the pixel range of 560,620(top left pixel)/580,645(bottom right pixel), wait till it finds color#2, send 2nd "W" keypress

When numpad 8 is pressed, autoit should send a keypress of "W", search the pixel range of 560,620(top left pixel)/580,645(bottom right pixel), wait till it finds color#3, send 2nd "W" keypress

if someone doesn't mind programming this for me I would REALLY appreciate it.

Thanks!

Share this post


Link to post
Share on other sites
monoscout999

and what are your efforts on this?

Share this post


Link to post
Share on other sites
cdkid

Some useful functions to check out in the help files would be

PixelGetColor

PixelSearch

HotKeySet

Send

Hope this helps. I'm sure if you provided an attempt anyone would be willing to help modify it.

~cdkid


AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites
Bigred2k

Not much. I'm watching basic video tutorials on youtube at the moment =P

Share this post


Link to post
Share on other sites
Bigred2k

OK. Here's what I got:

http://pastebin.com/mC9Kgdbf

Im not sure how to tie the individual pixel searches in with the 7,8,9 keypresses.

Share this post


Link to post
Share on other sites
monoscout999

the first that i see is that you don`t know how to use HotKeySet() see the help file and the examples for this function...

The variables like $blue_pixel = 0x0033FF must be $blue_pixel = "0x0033FF" because that gives you an error...

My advice.. start for one thing at the time, and try to solve that, for example the fist thing you need to do is know how to use the hotkeyset, then do an example of this function and learn how to use it, until that don`t go for another function because you will get messy and is not pleaseant help to messy people with messy scripts.

Edited by monoscout999

Share this post


Link to post
Share on other sites
Bigred2k

This is the first script ive written so thanks for being patient. you can see the latest version here:http://pastebin.com/8iyTHPQ3

How do I make it so that it loops over and over waiting for the next hotkey press?

Share this post


Link to post
Share on other sites
somdcomputerguy

Put a While...WEnd loop, with a small Sleep (parameter of 10 is fine), between the last HotKeySet and the first function (Func). This will keep the script running.

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
monoscout999

You can paste your script directly into the forum using

[/autoit] tags.. just paste your code between.
You dont need to add the brackets in every hotkeyset function or in every send function, this is reserved for special characters, read the help file about the send function and the apendix theres info about this feature. But if you want to use the numpad as hotkey you have to use it but in the correct way {NUMPAD0} - {NUMPAD9} Numpad digits 
you need a loop to containing the script
something like this
[autoit]while true
   sleep(50)
Wend

You will see many loops in the autoit examples

Your PixelSearch function have syntaxis errors... [5] is not a valid value for that parameter, only the integer alone is enough.

there a lot of corrections but are going in the right direction... the experience gives you the knowldege

Another free tip, if you are using SciTe look into the tools menu, something called tidy, this will adjust the format and the spacing of the text inside the script.

EDIT: some syntax examples

HotKeySet("{NUMPAD7}", "ToggleBlue")

$coord = PixelSearch(560, 620, 580, 645, $blue_pixel,5)

Send("w")
Edited by monoscout999

Share this post


Link to post
Share on other sites
StrykeR69

help! I made a program wich have a textbox and there have something typed....when I press the start button....the program goes to startup....how can I do to when the pc is powered on from the start up...the program don't shown the form(textbox and start button)...just don't shown anything and by hisself go to start up????

Share this post


Link to post
Share on other sites
somdcomputerguy

StrykeR69 - you shouldn't hijack a thread to ask an unrelated question.. Start a new topic.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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.