Jump to content

If sentence


Lazzo
 Share

Recommended Posts

okay so as you can imagine I'm a total noob here, just started learning, so for my first project I tried to make a simple mouse clicker but it doesnt seem to work =/

Func BotStart()
   $pt = PixelSearch (625, 405, 1284, 942, 0xD2D2D2)
   sleep(500)
   if Not @error Then
        mouseclick( "left", $pt[0], $pt[1], 1, 0)
        Sleep (500)
        $coord1 = PixelSearch (638, 349, 1299, 790, 0xFF0000)
        Sleep (1000)
        MouseClick ( "left", $coord1[0], $coord1[1], 1, 0)
        Sleep (650000)
        MouseClick ( "left", 485, 132, 1, 0)
        Sleep (1000)
      
  Else
      Sleep(55000)
      Return
EndIf
EndFunc

While 1

MouseClick ( "left", 853, 230, 1, 0)
Sleep (3000)    
Call("BotStart")
Wend

so, it clicks on 853,230 and start the botstart function where it searches for a color in the box and if it finds the color it does aditional clicks, if it does not find the color it sleeps then starts again

but my problem is that if it does not find the color it does not sleep but gives me an error at mouseclick( "left", $pt[0], $pt[1], 1, 0) saying subscript used with non-Array variable

I understand its because the pixelsearch did not return any coordinates but why did it not jump to the else statement? :S

I even tried with if IsArray($pt) then.... else... but I get the same error lol

I'm really stuck atm :S

Link to comment
Share on other sites

Two things to consider:

it does not sleep

Sleep(500) only sleeps half a second. So you won't notice the delay.

if it does not find the color

In your code you check @error after the Sleep command - so you check the @error code of Sleep. Move the Sleep after the error checking.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Two things to consider:

Sleep(500) only sleeps half a second. So you won't notice the delay.

In your code you check @error after the Sleep command - so you check the @error code of Sleep. Move the Sleep after the error checking.

oh damn, didnt realize it checks @error for sleep then, how silly am I ;)

Thanks a lot!

Edited by Lazzo
Link to comment
Share on other sites

It works fine for me. I get "Not found" written to the SciTE console.

Botstart()
Func BotStart()
    $pt = PixelSearch(625, 405, 1284, 942, 0xD2D2D2)
    If Not @error Then
        ConsoleWrite("Found" & @CRLF)
        Sleep(500)
        MouseClick("left", $pt[0], $pt[1], 1, 0)
        Sleep(1000)
        $coord1 = PixelSearch(638, 349, 1299, 790, 0xFF0000)
        Sleep(1000)
        MouseClick("left", $coord1[0], $coord1[1], 1, 0)
        Sleep(650000)
        MouseClick("left", 485, 132, 1, 0)
        Sleep(1000)

    Else
        ConsoleWrite("Not found" & @CRLF)
        Sleep(55000)
        Return
    EndIf
EndFunc ;==>BotStart

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

What are you trying to achieve with your script? The function name sounds a bit suspicious.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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