Jump to content

Need Help please


msarob
 Share

Recommended Posts

I am trying to make a script for a game. In the game, there is occasionally a popup that requires you to match pictures on the bottom with ones that appear on the top. I am having problems trying to get it to go one at a time and match and click the matching picture. I want it to recognize when the popup comes up and the check each picture on the top and then find the right one on the bottom and click it. I want it to continuously check in case the popup comes again. What I have so far is:

CODE
While 1

Sleep(10)

WEnd

func Terminate()

exit 0

endfunc

func Start()

Local $x,$protection1, $prot1, $prot2, $prot3, $prot4, $prot5, $click1, $click2, $click3, $click4, $click5, $click6

MsgBox(0,"Prog Running","here we go")

$x=0

while $x<1000

$protection1=pixelgetcolor(612,297)

if $protection1=0XFF0000 then mousemove(437,314)

$twoorthree=pixelgetcolor(502,384)

if $twoorthree=0XBD945A then $prot1=pixelgetcolor(477,368)

$click1=pixelgetcolor(426,463)

$click2=pixelgetcolor(461,463)

$click3=pixelgetcolor(496,463)

$click4=pixelgetcolor(531,463)

$click5=pixelgetcolor(566,463)

$click6=pixelgetcolor(601,463)

if $prot1=$click1 then MouseClick("left",426,463)

if $prot1=$click2 then MouseClick("left",461,463)

if $prot1=$click3 then MouseClick("left",496,463)

if $prot1=$click4 then MouseClick("left",531,463)

if $prot1=$click5 then MouseClick("left",566,463)

if $prot1=$click6 then MouseClick("left",601,463)

$prot2=pixelgetcolor(512,368)

$click1=pixelgetcolor(426,463)

$click2=pixelgetcolor(461,463)

$click3=pixelgetcolor(496,463)

$click4=pixelgetcolor(531,463)

$click5=pixelgetcolor(566,463)

$click6=pixelgetcolor(601,463)

if $prot2=$click1 then MouseClick("left",426,463)

if $prot2=$click2 then MouseClick("left",461,463)

if $prot2=$click3 then MouseClick("left",496,463)

if $prot2=$click4 then MouseClick("left",531,463)

if $prot2=$click5 then MouseClick("left",566,463)

if $prot2=$click6 then MouseClick("left",601,463)

$prot3=pixelgetcolor(547,368)

$click1=pixelgetcolor(426,463)

$click2=pixelgetcolor(461,463)

$click3=pixelgetcolor(496,463)

$click4=pixelgetcolor(531,463)

$click5=pixelgetcolor(566,463)

$click6=pixelgetcolor(601,463)

if $prot3=$click1 then MouseClick("left",426,463)

if $prot3=$click2 then MouseClick("left",461,463)

if $prot3=$click3 then MouseClick("left",496,463)

if $prot3=$click4 then MouseClick("left",531,463)

if $prot3=$click5 then MouseClick("left",566,463)

if $prot3=$click6 then MouseClick("left",601,463)

if $twoorthree=0XC59C5A then $prot4=pixelgetcolor(494,368)

$click1=pixelgetcolor(426,463)

$click2=pixelgetcolor(461,463)

$click3=pixelgetcolor(496,463)

$click4=pixelgetcolor(531,463)

$click5=pixelgetcolor(566,463)

$click6=pixelgetcolor(601,463)

if $prot4=$click1 then MouseClick("left",426,463)

if $prot4=$click2 then MouseClick("left",461,463)

if $prot4=$click3 then MouseClick("left",496,463)

if $prot4=$click4 then MouseClick("left",531,463)

if $prot4=$click5 then MouseClick("left",566,463)

if $prot4=$click6 then MouseClick("left",601,463)

$prot5=pixelgetcolor(529,368)

$click1=pixelgetcolor(426,463)

$click2=pixelgetcolor(461,463)

$click3=pixelgetcolor(496,463)

$click4=pixelgetcolor(531,463)

$click5=pixelgetcolor(566,463)

$click6=pixelgetcolor(601,463)

if $prot5=$click1 then MouseClick("left",426,463)

if $prot5=$click2 then MouseClick("left",461,463)

if $prot5=$click3 then MouseClick("left",496,463)

if $prot5=$click4 then MouseClick("left",531,463)

if $prot5=$click5 then MouseClick("left",566,463)

if $prot5=$click6 then MouseClick("left",601,463)

$x=$x+1

wend

endfunc

What I think this should do is check to see if the popup is up, mouse over it, then check to see if there are 2 pictures showing or 3, then it will check a pizel in the first picture and match it to the bottom pictures and click the appropriate one. Then it will move on to the second, then third if necessary. once the popup is done it will go back to looking for the popup again.

For some reason its not woking. Any advice would be very helpful. Also, if there is a better way to code this all, that would be helpful too. I am a beginner at this.

Thank you

Link to comment
Share on other sites

Well first you should learn how scripts are exectuted. They are executed line by line starting from the begining, obviously. So if you look at your code you'll see that your first 3 lines are an infinite loop. When you run this, it will stay there for ever. Nothing will make it exit the loop and the rest of the script will never be executed.

Even if that infinite loop wasn't there, the script wouldn't work anyways since you are not calling your functions. Start() and Terminate() are your two User Defined Functions. You created them, but never called them. Look at these examples:

here I declare the UDF but never call it:

Func Example()
    MsgBox(0,"","This example one. This messagebox should not show up")
EndFunc

And here I call it:

Example();Here I call the UDF

Func Example()
    MsgBox(0,"","This example two. This messagebox should show up")
EndFunc

Please read While..Wend, Func..EndFunc in the help file.

Link to comment
Share on other sites

For some reason I didn't add the first few lines in.

hotkeyset("{PAUSE}","Start")

hotkeyset("{ESC}","Terminate")

These are the first two lines. When I start up the script, it doesn't do anything, which it shouldn't. When I press the "PAUSE" key, it should put a msg box, then start checking for the popup. As it stands right now, once I press the PAUSE key, the msg box will come up and it seems to start checking but it doesn;t seem to work right. I have read the FAQs and the help file included but I can't seem to get it to work.

Link to comment
Share on other sites

One of the best things you can do is try to learn good debugging habits. You can absolutely go insane looking at a lump of code not knowing at all where things are going wrong.

A couple of suggestions;

Add #AutoIt3Wrapper_run_debug_mode=Y to the top of your script to see in the console line by line what is being processed.

or

Opt("TrayIconDebug", 1) to the top. When you leave your mouse over the tray icon this will show you what line the script is on.

The first method is prefereable but can give you a lot of code to look at, especially with a loop. Still very good though. Also, you can put some msgboxes in your code to check your values every now and then. Games can be very problematic to code for, there can be safeguards against scripting, for starters. It can also be hard for people to help because we can't test the code your having problems with.

Try to do some debugging and see if you can break down the code into a smaller piece your having problems with, and/or provide us with a link (assuming the game is web based) for us to test the code against. I'll keep looking over your code to see if I can see anything obviously wrong...ha but right now your code is second to nusring my bad headache....

Good luck!

While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd
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...