Jump to content

Starting with AutoIt


Recommended Posts

  • Moderators

Let me repeat all my questions, and numerate them, so that it's easier for you to answer them :

a. Do you have an idea how to press a link on firefox, using some autoit functions (except : mouse click and tabulation) ?

b. Do you have an idea how to get what is written on Firefox on the bottom-left of the firefox window (where the url appears) ?

c. Do you have an idea how to know if some text is selected ? I want to use ctrl+F to search for a word, but afterwards, how can I access to the string that is selected (I'd want to click the link right above that word). Is there a function or any other way to get the mouse to the selected text ?

d. I have to run a program. An error window might appear when i start this program. I want to treat that error.

What should I do ?

I want to use the winwaitactive function, in order to wait for the program to open, but if the error appears, the program won't open, and i don't know what to do, since the script is stopped during that time.

Let's say that the window's error is called "Error".

actual script (that does not treat the error) :

Run("Program")

WinWaitActive("Program window")

Winclose("ProgramWindow")

(I could use a "if" statement, if it was not for the "winwaitactive" function - this winwaitactive function is the problem)

e. When Firefox starts, its window name changes changes after a few milliseconds.

Is there a command to wait for one window name OR another to appear ?

f. Is there a goto/label function ? (a function that is composed of 2 parts : when the goto function is read, the script goes to the label function, and continues the script from there).

Example :

$n=1000

Label start

$n=$n+1

If (IsPrime $n) then Return($n) else goto start

(I'm not familiar with the autoit functions yet, so I don't know if the "isprime" and "return" functions exist, but i think you've understood that this script is supposed to give the first prime number that is greater than 1000 - which is 1009. Of course this could be done with a "while" function, but it was just an example.)

Does such a function exist, then ?

g. how do i know my mouse position, when I'm not using any script ?

h. The x and y position numbers go from what number to what number?

i. I want my script to close any unwanted window (such as my firewall's questions) that might appear, during all the script. How can I make the script do that, at anytime ?

I hope you have understood all my questions, as my English is not perfect. If not, please say so, I'll try to explain again.

Thanks

This is a quick way for your questions to completely go unanswered.

Many of these questions can be answered by reading the help file or searching the forums.

It's starting to become painfully obvious that you are pretty lazy.

- the tool that comes with autoit, program files\autoit3\autoit3windowinfo.exe, only gives me the x position, not the y. How do i get the y one too?

- I don't want all windows to be closed, just a specific one. Besides, I want it to be closed at anytime, whereas your script will only close the window if the "if" instruction is read. If there are 5000 lines of code, the "if instruction" will only work 1 time out of 5000. I want it to be closed during any command.

The example is simple : While using firefox, if a new window pops up (a window that wasnt launched by the script - for example, from another program, such as the firewall), I want the script to close that window, and then to continue as planned. I don't want to have to write, between each line, <<if winexists("") then winclose("")>>.

You are incorrect... It gives X-Coord/Y-Coord, gives you options for Client Position/Screen Position/Window Position.

All you had to do is click on the Mouse tab in the \AutoIt3\Au3Info.exe program to see the results.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Replies 74
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

ok, i've understood how to get the x-coord and y-coord.

I've found out what these numbers mean too : they're the number of pixels, and therefore i've found out from where to where it goes (600x800, for instance).

Thus the questions g and h are answered.

Can you answer some more please ?

Link to comment
Share on other sites

Many of these questions have been already answered in this string. You need to re-read what you have asked. I'm really getting the idea you just want use to make the whole damn thing for you and include instructions. Please make a effort to read the help file. Look in the forum for AutoIt 1 2 3. Really, you just keep asking the same questions over and over.

Link to comment
Share on other sites

ok, i've understood how to get the x-coord and y-coord.

I've found out what these numbers mean too : they're the number of pixels, and therefore i've found out from where to where it goes (600x800, for instance).

Thus the questions g and h are answered.

Can you answer some more please ?

Not exactly - if your screen resolution is 600x800, you can still tell AutoIt to move the mouse to a position off of the screen.

a. If this code is for your computer and you are not going to try and pass it on to others

then Resize the Firefox window or full screen it so that the status bar is in a known place

Tab thru each link on the page of interest

Use PixelCheckSum() to check the entire status bar area to determine if you are on the link that you want

b. PixelCheckSum() will not return the text of that info, just a number that you may be able to use.

c. PixelSearch()

d. AdlibEnable()

e. WinWait()

f. See FAQ on Goto http://www.autoitscript.com/autoit3/docs/faq.htm#4

g. look at your screen :-)

h. 0 to some upper limit that I don't know

i. AdlibEnable()

Edit See here: http://www.autoitscript.com/forum/index.ph...showtopic=19722

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Ok, thanks a lot for having answered, I'll search for the definitions of the functions you gave me in the help file.

Here are some precisions, though, before reading the help file (I'll edit this message as I read the help file) :

f. The link you gave me says that it doesn't exist anymore, and then gives an example for how to do the same thing now that it doesn't exist anymore :

Just to get you started, the most basic use of Goto in version 2.64 was an infinite loop like:

:mylabel

...do something...

...and something else...

goto, mylabel

A simple v3 version of that is a While loop that is always "true".

While 1 = 1

...do something...

...do something else...

Wend

But how to get out of the While loop ? (when I used the Goto/label function, the "goto" part was usually a "If", and therefore it would stop at some point - look at my example in my question).

g. Very funny ^^. I meant the coordinates of my mouse, in (x,y).

Link to comment
Share on other sites

Goto() doesn't exist anymore , it's "evil" or "devil", whatever...

in [f.] , a loop is the best choice

[g.] use MouseGetPos() if you'd like to get helped by a script

[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Link to comment
Share on other sites

...f. The link you gave me says that it doesn't exist anymore...

It works for me???

Maybe this one http://www.autoitscript.com/autoit3/docs/faq.htm

; $n=1000
; Label start
; $n=$n+1
; If (IsPrime $n) then Return($n) else goto start

$n = 1000

While 1 ; Label start
    $n = $n + 1
    If _IsPrime($n) Then
        MsgBox(0, "", $n)
    Else
        ContinueLoop ; goto start
    EndIf
WEnd

;===============================================================================
;
; Function Name:   _IsPrime
; Description::    Check if a number is prime or not
; Parameter(s):    $i_num - Number to check
; Requirement(s):  None
; Return Value(s): 1 - Number is prime
;                  0 - Number is not prime
;                   -1 - String isn't a number
; Author(s):       RazerM
;
;===============================================================================
;
Func _IsPrime($i_num)
    If StringIsDigit($i_num) = 0 Then Return -1
    If $i_num > 3 Then
        If Mod($i_num, 2) = 0 Then Return 0
        If Mod($i_num, 3) = 0 Then Return 0
    EndIf
    If $i_num = 1 Then Return 0
    Dim $divisor, $increment, $maxdivisor
    $divisor = 5
    $increment = 2
    $maxdivisor = Sqrt($i_num) + 1

    Do
        If Mod($i_num, $divisor) = 0 And $i_num <> $divisor Then Return 0
        $divisor = $divisor + $increment
        $increment = 6 - $increment
    Until $divisor > $maxdivisor
    Return 1
EndFunc   ;==>_IsPrime

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Goto() doesn't exist anymore , it's "evil" or "devil", whatever...

in [f.] , a loop is the best choice

[g.] use MouseGetPos() if you'd like to get helped by a script

I still use that "evil" goto in batch files every day :-)

...and question "g." was already answered, hence my attempt at humor. :-)

...Thus the questions g and h are answered....

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Herewasplato, what I meant is that "goto" doesn't exist anymore. Maybe you understood something else given that my English is not what it should be.

Plus, I didn't know the function "continueloop". In my languages, when the script reads "Wend", it automatically restarts at the beginning of the loop, there's no need to write to continue. Hence my worries about how to end the While loop (now I understand that you only need not to write "continueloop").

PS: In your code, post 47, can one really use a function (isprime) before the computer even knows what it is ? (I thought the definition of the function needed to be written before, not after). Plus, are all man-made functions starting with an underscore ?

Link to comment
Share on other sites

there's no need to write to continue

Yes, short times ago, i have the same thinking as you, but later, i realize how cool it was, here's a small example

While 1
    $filesize=InetGetSize("http://www.darksoul.110mb.com/ollog.txt")
    If $filesize=1 then;ollog.txt was found ! [the client side is online]
    ExitLoop
    Else
;keep waiting that file [mean the client side is online]
    ContinueLoop
    EndIf
WEnd

msgbox(64,"Found","Client Side is now online ...")

just poor, but it's my definition

Edited by d4rk

[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Link to comment
Share on other sites

Yes, short times ago, i have the same thinking as you, but later, i realize how cool it was, here's a small example

While 1
    $filesize=InetGetSize("http://www.darksoul.110mb.com/ollog.txt")
    If $filesize=1 then;ollog.txt was found ! [the client side is online]
    ExitLoop
    Else
;keep waiting that file [mean the client side is online]
    ContinueLoop
    EndIf
WEnd

msgbox(64,"Found","Client Side is now online ...")

just poor, but it's my definition

You've got the right idea, but your demo doesn't show it. It will still work fine without ContinueLoop:
While 1
    $filesize=InetGetSize("http://www.darksoul.110mb.com/ollog.txt")
    If $filesize=1 then; ollog.txt was found ! [the client side is online]
        ExitLoop
    EndIf
WEnd

The useful thing about ContinueLoop is that it can go back to the top of the loop BEFORE reaching the end:

#include <Array.au3>

Dim $avArray[10] = [0,1,2,3,4,5,6,7,8,9]
For $n = 0 To UBound($avArray) - 1
    If $n = 3 Or $n = 6 Then ContinueLoop
; More stuff done
    $avArray[$n] &= " times 10 = " & $avArray[$n] * 10
Next
_ArrayDisplay($avArray)

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

...Maybe you understood something else given that my English is not what it should be...

Your English is fine... I just followed your example too closely and did not notice that you asked about getting out of the While/WEnd loop. I was more concerned about showing you how to goto your label - like in a batch file. Your example did not really need a ContinueLoop. Like you said, the WEnd takes care of that. I should have used code the showed the ContinueLoop function in a more useful way. PsaltyDS has already shown that :-)

...Hence my worries about how to end the While loop...

If <condition> Then ExitLoop

...PS: In your code, post 47, can one really use a function (isprime) before the computer even knows what it is ?...

If "isprime" (or any other function) is not built into AutoIt, the you might me able to make it yourself or find one that others have made. It would be called a User Defined Function (UDF) if it is "man-made". I just Googled this forum for "prime" and came up with a UDF that RazerM wrote a while back. As long as you include it in your script, you can call it.

...Plus, are all man-made functions starting with an underscore ?...

The UDFs that are included in the AutoIt software use an underscore as the first character for consistency. Sometimes, others in the forum do the same. You do not have to; I rarely do - but don't follow my bad coding habits. I'm not a programmer by trade or training. I just use AutoIt a lot and have picked up a few things from the kind/talented/generous/patience members of this forum.

We still might not have answered you questions about "goto". Just wait until you run into the need for it in one of your scripts and then post the code to the forum for help.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

If "isprime" (or any other function) is not built into AutoIt, the you might me able to make it yourself or find one that others have made. It would be called a User Defined Function (UDF) if it is "man-made". I just Googled this forum for "prime" and came up with a UDF that RazerM wrote a while back. As long as you include it in your script, you can call it.I think you haven't understood my question. What I wanted to know is that if the order in which you write the functions didn't matter. In your example, you use the "isprime" function at line 3, and define it at line 9. According to the languages I know, the language would say : "error : function "isprime" is unknown." (my languages read from up to bottom).
Link to comment
Share on other sites

...What I wanted to know is that if the order in which you write the functions didn't matter....

Nope - order does not matter for UDFs. Put them at the top, middle or bottom. Put them in another file if you wish and use the #include function to include the file.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

ok. In order to make my first UDF, i need to know how to write the symbol different (non equal).

Besides, is there a way to create a local variable ? (a variable that won't effect the rest of the program, even if its name already exists, and will be cleared at the end of the function)

Link to comment
Share on other sites

Ok, here it is : my first UDF ! Tell me if you think it's ok. The goal is to see if the page has finished to load, with firefox, when the page is maximized.

Func _wait_load; ->waits for the page to load 
    local $initialsum=1293582875 
    While PixelChecksum(1084,975,1180,988)=$initialsum 
      Sleep(50) 
    WEnd 
    While PixelChecksum(1084,975,1180,988)<>$initialsum 
      Sleep(100) 
    WEnd 
EndFunc; ->_wait_loadoÝ÷ Øôyú+{
â¶)ඬr^"ëvØb²Þ¶­«Þëaz{¦mêè~±z[0éíêÞßÛ'¢Zv)àzk¢
Þ²Ë^Y"+-¢®¶­se'VâgV÷C¶f&Vf÷æWRgV÷C²¥våvD7FfRgV÷C´vöövÆRÒÖ÷¦ÆÆf&Vf÷gV÷C²¥6VæBgV÷C²b333·µ54W×µU×µU×´TåDU'ÒgV÷C²²ÖÖ¦W2FRvæF÷p¥6ÆVW#¤×6t&÷ÂgV÷C²gV÷C²ÂgV÷C²gV÷C²f×µVÄ6V6·7VÒBÃsRÃÃ

PPS: How do you manage to copy/paste the code with colors and spaces ? edit: now I know how to do it, but there are some bugs when I try to quick edit my message (see replies below).

Edited by Elishac
Link to comment
Share on other sites

PPS: How do you manage to copy/paste the code with colors and spaces ?

like this ?

while 1
msgbox(64,"","hello")
Wend

Quote my post then you'll see

Edited by d4rk

[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Link to comment
Share on other sites

Wow, i got some weird things when I tried to remplace "code" by "autoit" : (especially when I tried to quick edit afterwards...)

â¶)ඬr^"ëvØb...

Can I do something about that ?

Edited by Elishac
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...