Sign in to follow this  
Followers 0
Bretai2k

Require assistance with particular code

7 posts in this topic

#1 ·  Posted (edited)

I am very new to autoit, and found a bit of code I have been working with to perform a certain function. I've had to change much of the code to get it to work already, but have come across a final piece of the code that I cannot figure out how to get working.

Any help in figuring this out would be greatly appreciated.

Do

MouseMove(0, 0)

Sleep(1500)

variable1 = PixelGetColor(variable2, variable3)

Sleep(Random(400, 800))

If variable1 <> variable4 Then

Sleep(Random(3000, 5000))

variable5 = Random(1, 4)

If variable5 = 1 Then

Send("{D down}")

Sleep(100)

Send("{D up}")

ElseIf variable5 = 2 Then

Send("{S down}")

Sleep(100)

Send("{S up}")

ElseIf variable5 = 3 Then

Send("{A down}")

Sleep(100)

Send("{A up}")

ElseIf variable5 = 4 Then

Send("{W down}")

Sleep(100)

Send("{W up}")

EndIf

TrayTip("Guud Stuff", "This should be working.", 5)

EndIf

Until variable1 = variable4

MouseClick("left", variable2, variable3, 2)

variable6 = variable6 + 1

IniWrite("Config.ini", "Stuff", "Done", variable6)

Sleep(10000)

EndIf

Variables 2 and 3 are predefined variables that are called from an Ini file.

If this should be working as is then maybe there is something in another part of the code that is causeing this not to function. Wierd thing is I do see the Mousemove command work, and repeat if I move the mouse, but nothing else seems to be working.

Edited by Bretai2k

Share this post


Link to post
Share on other sites



code run through Scite Tool "Tidy"...

Do
    MouseMove(0, 0)
    Sleep(1500)
    variable1 = PixelGetColor(variable2, variable3)
    Sleep(Random(400, 800))
    If variable1 <> variable4 Then
        Sleep(Random(3000, 5000))
        variable5 = Random(1, 4)
        If variable5 = 1 Then
            Send("{D down}")
            Sleep(100)
            Send("{D up}")
        ElseIf variable5 = 2 Then
            Send("{S down}")
            Sleep(100)
            Send("{S up}")
        ElseIf variable5 = 3 Then
            Send("{A down}")
            Sleep(100)
            Send("{A up}")
        ElseIf variable5 = 4 Then
            Send("{W down}")
            Sleep(100)
            Send("{W up}")
        EndIf
        TrayTip("Guud Stuff", "This should be working.", 5)
    EndIf
Until variable1 = variable4
MouseClick("left", variable2, variable3, 2)
variable6 = variable6 + 1
IniWrite("Config.ini", "Stuff", "Done", variable6)
Sleep(10000)
;### Tidy Error: next line creates a negative tablevel.
;### Tidy Error: next line creates a negative tablevel for the line after it.
EndIf

Yes, that last Endif is for a bigger piece of the code. I ran it through Tidy and did not see any errors. When I test through the editor, it does not report any problems. When I complie it, no errors. When I run it, the rest of the program runs, but when it gets to this part it seems to run the Mousemove bit of the code, but I do not see any of the rest of it working, and still I see no errors (other than I can see that it is not doing what I asked it to).

Share this post


Link to post
Share on other sites

Sorry... I spent about 500 milliseconds looking at your code... I see that your variable are not even variables... where are the $? (BTW this is Question 1 of 20)

Lar.

Yeah, its not the actual code. I changed the $variable statements with variable1,2,3, etc. Was hoping it would still get the point across. I've "borrowed" some code from someone who is trying to make money off what they made and even though I am changing/have changed it to suit my needs I don't want to post his actual code out there for others who might want it to steal from that person without paying for it. Being new to this most of it is way over my head (though I am trying to learn), but since the first part of the code was working I was really hoping it was just something within that section that was preventing it from going through the whole thing like it was supposed to.

Thank you so much for helping me as much and as quickly as you have. It's refreshing to see an active and helpful community work with each other!

I would be willing to PM you the actual code if you would be willing to help, but I'd really hate to impose on you so much. Like I said I'm not comfortable posting it in its entirety to a public forums when someone is trying to make an honest buck off their work.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Try to do some debugging with MsgBoxes or something... to show the variables values at different points in the script... There are too many variables that I DO NOT know the value of, to be able to help you.

Lar.

Okay so I added some msgboxes to test it out and here's what I get now:

Remember that variable2 and variable3 are declared in a file called config.ini

$variable2 = IniRead("Config.ini", "General", "variable2", "ERROR")
$variable3 = IniRead("Config.ini", "General", "variable3", "ERROR")

Do
     MouseMove(0, 0)
     $variable1 = PixelGetColor($variable2, $variable3)
     Sleep(Random(400, 800))
     If $variable1 <> $variable4 Then
          Sleep(Random(3000, 5000))
          TrayTip("Guud Stuff", "Getting info and moving around.", 5)
          $variable5 = Random(1, 4)
          If $variable5 = 1 Then
               Send("{D down}")
               Sleep(100)
               Send("{D up}")
          ElseIf $variable5 = 2 Then
               Send("{S down}")
               Sleep(100)
               Send("{S up}")
          ElseIf $variable5 = 3 Then
               Send("{A down}")
               Sleep(100)
               Send("{A up}")
          ElseIf $variable5 = 4 Then
               Send("{W down}")
               Sleep(100)
               Send("{W up}")
          EndIf
          TrayTip("Guud Stuff", "This should be working.", 5)
     EndIf
Until $variable1 = $variable4

So what I am seeing is the mouse moving to the upper lefthand corner of the screen, then I get a tray tip that says "This should be working." This repeats over and over but I never see the tray tip display "Getting info and moving around.", nor do I see the keys getting depressed and released. It seems like for some reason it is not pulling the info correctly for $variable1. My code seems to be correct (at least from a noob standpoint), but for some reason all the meat in the center of the program is not working. Any other ideas?

Edited by Bretai2k

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I don't see this in your code... it is going to be difficult to help you.

Lar.

Sorry had accidentally posted the original code and forgot to change some things. Check it out now. Also, sorry if I'm making this more difficult than it needs to be, I just really want to protect this person's code.

Edited by Bretai2k

Share this post


Link to post
Share on other sites
TrayTip("Guud Stuff", "This should be working.", 5)oÝ÷ ÚØb²+!j^)àºw(Ø­Ú©ºØ­{hjqHJ+²¶§+pYZ²²Þ®Ö¤{*.­«­¢+ÙQÉåQ¥À ÅÕ½ÐíÕÕMÑÕÅÕ½Ðì°ÅÕ½ÐíÑÑ¥¹¥¹¼¹µ½Ù¥¹É½Õ¹¸ÅÕ½Ðì°Ô¤oÝ÷ Ûú®¢×y¨[ºÛajÝý²z-¶¦j)â²Ëv¶æ¥Ü­ê'*ÞjÊ'¶­jëh×6TrayTip("Guud Stuff", "This should be working.", 5)
is in there was just to test and see if that part of the code was running, which right now I suspect it isn't. I have basically the exact same code (using different variables of course) elsewhere in my program and that runs fine, it just seems for some reason this does not work correctly.

Share this post


Link to post
Share on other sites

It seems to be an endless loop as $variabale4 never is set therefore can't equal $variable1....

what I would do first is to do a msgbox right before the sleep function, consisting of the values for $variable1,$variable2 and $variable4 (or 3 msgboxes) just to see what the values are.

looks a bit like a game bot, with the wasd keysset to move around. I know at least one game that uses those keys. :lmao:


> there are 10 types of people in the world, those who understand binary and those who don't.

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  
Followers 0