Jump to content
Sign in to follow this  
Centrally

AutoIt beginner few simple questions

Recommended Posts

Centrally

As I stumbled upon one system I wanted to automatize AutoIt sounded perfect for doing so but now I stumbled upon several problems and along with that I have several questions so here it is.

This is code I wrote so far before I went into problems and had many questions.

Run ( "Masked for privacy" )

$i = 0
While $i <= 10
  $coord = PixelSearch(906, 579, 1067, 666, 0xA86A21)
  If Not @error Then
    MouseClick("primary", $coord[0], $coord[1], 1, 0)
  EndIf
$i = $i + 1
Sleep(3000)
WEnd

$i1 = 0
While $i1 <= 10
  $coord1 = PixelSearch(86, 658, 160, 706, 0xEE2E24)
  If Not @error Then
   $coord2 = (458, 311)
    MouseClick("primary", $coord2[0], $coord2[1], 2, 1)
  EndIf
$i1 = $i1 + 1
Sleep(3000)
WEnd

Now basically when 2nd screen appear and 2nd while loop is executed it doesn't detect given pixel nor it move&click mouse to selected place after it detect that pixel. After leaving script to run for some time it gives error "NO RIGHT BRACKET".

Next questions:

If first while loop here find pixel in first execution (or any before 10th run) does it stop running or does it still keep looping. If it keep looping how can I stop it if pixel is found.

Will 2nd while loop start executing if 1st one is not done. I mean if question before had answer that it doesn't stop looping it means 2nd script would start after 30 seconds.

Is it possible to read from window bigger part than only pixel? Something like part of picture an so on, if so could you point me to such format

How to read something from outside file (I would like to make configuration file) and save it in variable. Lets say I have .txt file with accountName:password and now I want to take only accountName out of it and save it in variable, same this with password.

Can I use variables declared in other loops, I mean in this my code I used coord1 in 2nd while loop, is coord from first loop accessible by 2nd loop?

__________________________________________________________________________________________________________

Parts of my questions are covered in tutorials and questions already asked, but I questioned them here in way I haven't been able to understand them from Internet found references.

Thanks for your time reading my topic and taking time answering my noobish questions.

Share this post


Link to post
Share on other sites
stormbreaker

Now basically when 2nd screen appear and 2nd while loop is executed it doesn't detect given pixel nor it move&click mouse to selected place after it detect that pixel. After leaving script to run for some time it gives error "NO RIGHT BRACKET".

Because you provide no room to get out of it... something called ExitLoop

Regarding reading something from outside files, checkout help file for FileRead, FileWrite, IniRead examples etc.

You can use variables declared in other loops, use Global declarations...

Edited by MKISH
  • Like 1

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Share this post


Link to post
Share on other sites
Centrally

I added ExitLoop [1] and now I'm getting error in expression, any more ideas?

Share this post


Link to post
Share on other sites
BrewManNH

The brackets shown in the help file are to tell you that that parameter is optional, don't actually use the brackets when using the function. Plus, ExitLoop defaults to 1 so that is also unnecessary. :)


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
kylomas

Centrally,

This stmt is wrong

$coord2 = (458, 311)
. You probably want a pixelsearch here.

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
Centrally

Centrally,

This stmt is wrong

$coord2 = (458, 311)
. You probably want a pixelsearch here.

kylomas

it's not wrong, I used pixelsearch just to verify correct window is open and after that I wanted to select one text field with this coordinated mouse double click.

@BrewManNH

I already tried it without bracket since I saw it's optimal and about it's default value but same thing over again.

So my current code looks like this:

Run ( "masked" )
$i = 0
While $i <= 10
$coord = PixelSearch(906, 579, 1067, 666, 0xA86A21)
If Not @error Then
MouseClick("primary", $coord[0], $coord[1], 1, 0)
ExitLoop
EndIf
$i = $i + 1
Sleep(3000)
WEnd

$i1 = 0
While $i1 <= 10
PixelSearch(86, 658, 160, 706, 0xEE2E24)
If Not @error Then
$coord2 = (458, 311)
MouseClick("primary", $coord2[0], $coord2[1], 2, 1)
ExitLoop
EndIf
$i1 = $i1 + 1
Sleep(3000)
WEnd

And still receiving error about missing right bracked, any more ideas?

Edited by Centrally

Share this post


Link to post
Share on other sites
kylomas

Centrally,

Are you using the full editor? The stmt I pointed out is syntactically wrong.


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
Melba23

Centrally,

I have lifted your "New Member" 5 post restriction - you are now able to continue the discussion as long as necessary. :)

M23

  • Like 1

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Centrally

Centrally,

Are you using the full editor? The stmt I pointed out is syntactically wrong.

I see what you implying I never went over editor tut, since I saw SciTE as being basic text editor with syntax highlighting. After checking this out I found really much functions on it and after doing function called beta run it pointed me to a syntax error in line you mentioned, however I seem really hard time finding syntax for saving coordinates in variable, and I don't want to use them directly inside mouse syntax (will change entire process probably so I need var for this), thanks for answering.

@Melba23

Thanks for that, I was really getting afraid of running out of posts I could do :D

Edited by Centrally

Share this post


Link to post
Share on other sites
kylomas

Centrally,

One possible solution

Run("Masked for privacy")

$i = 0
While $i <= 10
    $coord = PixelSearch(906, 579, 1067, 666, 0xA86A21)
    If Not @error Then
        MouseClick("primary", $coord[0], $coord[1], 1, 0)
    EndIf
    $i = $i + 1
    Sleep(3000)
WEnd

$i1 = 0

local $x = 458, $y = 311

While $i1 <= 10
    $coord1 = PixelSearch(86, 658, 160, 706, 0xEE2E24)
    If Not @error Then
        ;$coord2 = (458, 311)
        MouseClick("primary", $x, $y, 2, 1)
    EndIf
    $i1 = $i1 + 1
    Sleep(3000)
WEnd

kylomas

  • Like 1

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
Centrally

Centrally,

One possible solution

Run("Masked for privacy")

$i = 0
While $i <= 10
    $coord = PixelSearch(906, 579, 1067, 666, 0xA86A21)
    If Not @error Then
        MouseClick("primary", $coord[0], $coord[1], 1, 0)
    EndIf
    $i = $i + 1
    Sleep(3000)
WEnd

$i1 = 0

local $x = 458, $y = 311

While $i1 <= 10
    $coord1 = PixelSearch(86, 658, 160, 706, 0xEE2E24)
    If Not @error Then
        ;$coord2 = (458, 311)
        MouseClick("primary", $x, $y, 2, 1)
    EndIf
    $i1 = $i1 + 1
    Sleep(3000)
WEnd

kylomas

We seams found solution at same time, mine is bit different and I will prolly repharse it to use array instead of var in future code.

My solution is here if anyone stumble on same problem.

$coordx = "458"
   $coordy = "311"
    MouseClick("primary", $coordx, $coordy, 2, 1)

I want to thank you everyone for your time and assistance in resolving my problem.

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  

×