Jump to content

issues with if @error and if not @error?


Recommended Posts

hello, I am actually working with this in paint just to test, I have probably 40+ scripts on my desktop just messing around trying to learn the feature, right now I have specific colors in specific areas of paint window, just to get the mouse to try an click on them, (I know it seems weird) right now before I do anything or make anything feasable, I would like to actually learn the program, my previous post I knew nothing about this program and kind of just tried to use it without reading anything, if anyone can tell me why this isn't working or coast me in the right direction it would be greatly appreciated, the first command works, however it is not picking between either of the if/if not commands..

 

WinActivate("Untitled")
WinWaitActive("Untitled")
Opt("MouseCoordMode", 0)
While 1
;Click 1
   PixelSearch(7, 9, 1016, 589, 0xE29820)
         If Not @error Then
      MouseClick("primary", 409, 445, 1, 1)
   EndIf
;Click 2
   PixelSearch(7, 9, 1016, 589, 0x6E7373)
         If Not @error Then
      MouseClick("primary", 1003, 27, 1, 1)
      sleep(500)
      MouseClick("primary", 507, 457, 1, 1)
;Else Click 2
         If @error Then
            PixelSearch(7, 9, 1016, 589, 0x969494)
      MouseClick("primary", 480, 461, 1, 1)
      Sleep(Random(30000, 300000, 1))
     EndIf
   EndIf
WEnd

 

Edited by MasterofLight
Link to comment
Share on other sites

  • Developers

Your indentation is off and doesn't show what is within which If:

WinActivate("Untitled")
WinWaitActive("Untitled")
Opt("MouseCoordMode", 0)
While 1
    ;Click 1
    PixelSearch(7, 9, 1016, 589, 0xE29820)
    If Not @error Then
        MouseClick("primary", 409, 445, 1, 1)
    EndIf
    ;Click 2
    PixelSearch(7, 9, 1016, 589, 0x6E7373)
    If Not @error Then
        MouseClick("primary", 1003, 27, 1, 1)
        Sleep(500)
        MouseClick("primary", 507, 457, 1, 1)
        ;Else Click 2
        If @error Then
            PixelSearch(7, 9, 1016, 589, 0x969494)
            MouseClick("primary", 480, 461, 1, 1)
            Sleep(Random(30000, 300000, 1))
        EndIf
    EndIf
WEnd

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

thanks, I will look into that, didn't know indention actually made any difference except making a code look clean or messy, It didn't effect anything else I tried OoO now i have to look up the endif indention at least it points me somewhere haha

 

 

Edit: still not working, I got it right, then used Tity (downloaded the Titly.exe plugin to assist me) and it didn't change anything so I made everything flat/not right to make sure it was working, and it set it to exactly how I had it for the new layout, still not working hmmm still looking into it however all the help I could get would be appreciated, in coasting me in the right direction, also I looked at the tidy page to see how the indent is suppose to be/ how it works, set it up accordingly and still nothing after the first click.

 

WinActivate("untitled")
WinWaitActive("untitled")
Opt("MouseCoordMode", 0)
While 1
    ;Click 1
    PixelSearch(7, 9, 1016, 589, 0xE29820)
    If Not @error Then
        MouseClick("primary", 409, 445, 1, 1)
        ;Click 2
        PixelSearch(7, 9, 1016, 589, 0x6E7373)
        If Not @error Then
            MouseClick("primary", 1003, 27, 1, 1)
            Sleep(500)
            MouseClick("primary", 507, 457, 1, 1)
        EndIf
        ;Else Click 2
        If @error Then
            PixelSearch(7, 9, 1016, 589, 0x969494)
            MouseClick("primary", 480, 461, 1, 1)
            Sleep(Random(30000, 300000, 1))
        EndIf
    EndIf
WEnd

 

Edited by MasterofLight
Link to comment
Share on other sites

  • Developers

It indeed doesn't change the program logic, but it does show in this case it works different than you thought it did. ... right or is this what you already thought the logic flow was?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

essentially, I have 3 blobs on paint, I would like it to click 1 then click the second one, wait half a second one exists it will click a certain area I have with jsut a black smudge and then click another one half a second later, however if those 2 don't exist, it will check for another color, and click it, trying to do that statement or would I needto use an Or statement? I am a bit stumped here lol still new to autoit

Link to comment
Share on other sites

  • Developers

I am pretty sure when I ask you to show all details I have to close this thread like your first one, so lets stop the hide and seek here and I wish you success with scripting.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...