
Elishac
Active Members-
Posts
114 -
Joined
-
Last visited
Everything posted by Elishac
-
Please help me, as it's not working, and I don't know why !
-
Thanks for your answer, Generator. I've looked up WinSetState(), and I've made the appropriate modifications. Except from that suggestion, all you are saying is that I'd better use Internet Explorer. I know that, some people already told me. But I'd rather use Firefox, for some other reasons. Now, given my choice, can you please help me to make my script work ? I know it won't be perfect, and not reliable, but please help me to make it as good as possible. At this very moment, my script is not working at all, which is not normal, I guess, so please help me.
-
Ok, thanks for the hint, I made the modifications. Anything else ?
-
Yeah this is my very first one. But there must be a lot of mistakes. That's why I need your help. (besides, this is my second topic, and I asked some questions in the first one :-), they helped me a lot). Please help me :-). (I made the _wait_load function separately though - so this is my second one - but my second script includes my first script :-)).
-
Now I can test it. There aren't any mistakes anymore (at least there isn't any error message window). It runs firefox, but then it stops, and doesn't do anything else. Can you see what is wrong ?
-
The script is not finished yet, so I can't test it. Meanwhile, I'm correcting and editing some mistakes.
-
I know, but I'd rather use Mozilla. It's done, now, anyways, so please tell me if there are any mistakes.
-
Hello, I'd like to write a autoit script that basically goes to a site, opens some web pages of that site, and does some stuff in these pages. I'd like to use Firefox (a personal version, actually) to do these tasks. Please help me, as I've tried really hard. This might be a bit complicated for a first script. I'll take the autoitscript forum as an example for the site I'd like to go to, even though it's not the case. Here is my algorithm (it can be improved - if you have some ideas, they're welcome, I have some ideas too - but for now, let's try to make a script with that algorithm) : 1- Run firefox 2- If a window opens and says that firefox is already running, press enter (it will close the firefox that is running), and go to the step 1-. 3- Wait for 15 seconds for Firefox to open. 4a- First possibility: it didn't open. if a window opens and says that Add-on updates are available, then close that window, and continue to the next step (5-). Else, stop the whole script, and create a message window untitled Error saying that Firefox didn't open. 4b- Second possibility : it opened. Then continue to the next step (5-). 5- Maximize the Firefox window (alt+space+up+up+enter). 6- Press F6, and write the url. For example : http://www.autoitscript.com/forum/index.ph...orum=2&st=0. 7- Wait for the page to load completely (I wrote a function called _wait_load() in order to do that). 8- If there's a problem loading page (connection issue), then close firefox and go to the step 1-. 9- Search for a word, with ctrl+F. For example, "last post by". 10- Make the mouse go to the selected word. With my version of firefox, it's easy, as the word is overlined in green. 11- Click the word (in my case, it's actually a link right above the word) that was searched. 12- Same as 7-. 13- Same as 8-. 14- Do some things in that page (for example, copy paste the topic into a .txt) 15- Come back to the previous page, that shows all the topics (alt+left). 16- Find the next "last post by" (ctrl+G) (Firefox saves the position of the last one that was overlined). 17- Redo the steps 10 to 16 included, 20 times (as there are 20 topics displayed). 18- Redo the steps 6 to 17 included, 2274 times (there are 2274 pages in the subforum "General Help"), but change the last part of the url of the step 6. In my case, the number just needs to be increased by 1, but in the case of the autoitscript forum, the number needs to be increased by 20 : st=0, st=20, st=40, ... 19- Make a message box saying that the script is finished. This script only needs to be used by me. As a result, I sometimes used specific numbers, that "Autoit window info" gave me. Don't bother about the numbers, just tell me if it looks correct. Here is the script that I made : Func _wait_load() ;->waits for the page to load $initialsum=1293582875 While PixelChecksum(1084,975,1180,988)=$initialsum Sleep(50) WEnd While PixelChecksum(1084,975,1180,988)=$initialsum Sleep(100) WEnd EndFunc ; ->_wait_load Global $p=0 ; this is the number of the pages that have already been done (see the url below). Global $c=0 ; this is the number of the topics that have been dealt with successfully (it's just a variable that is meant to count the number of success operations). While 1 Run("C:\Program Files\Mozilla Firefox\firefox.exe") If WinWaitActive("Mozilla Firefox is already running") Then Send("{Enter}") continueLoop EndIf ; If firefox is already running, shut it down and go to step 1. If Not(WinWait("Google - Mozilla Firefox",15)) Then If WinExists("Firefox Add-on Updates") Then WinClose("Firefox Add-on Updates") ; close available updates. else MsgBox(0,"Error","Firefox didn't open") EndIf EndIf WinSetState("Google - Mozilla Firefox","",@SW_MAXIMIZE) WinActivate("Google - Mozilla Firefox") While $p<=2274 ; number of pages Sleep(3000) Send("{F6}http://www.autoitscript.com/forum/index.php?showforum=2&st="&(20*$p)) ; _wait_load() If WinActive("Problem loading page - Mozilla Firefox") Then Winclose("Problem loading page - Mozilla Firefox") ContinueLoop 2 EndIf Send("^f") Send("last post by") For t = 1 to 19 ; there are 20 topics, so this action must be redone 19 times. local $coord=PixelSearch(400,300,700,950,0x38D878) If Not(@error) Then MouseMove($coord[0]+30,$coord[1]-12) EndIf ;don't mind about the specific numbers. MouseClick() _wait_load() If WinActive("Problem loading page - Mozilla Firefox") Then WinClose("Problem loading page - Mozilla Firefox") ContinueLoop 3 EndIf ; ; here will be all the operations that need to be done for each topic, such as copy/paste it into a .txt. ; $c=$c+1 ; c is the number of successfull operations made during the whole script. Send("!{LEFT}") ; go to previous page. Send("^g") ;next research. Next $p=$p+1 WEnd ExitLoop ; If we reached this point, we did all we needed to do. Exit the main loop. WEnd MsgBox(0,"Congratulations","The script has ended successfully") Please help me and tell me if there are any mistakes. Thanks. PS: I'm sorry my English is not perfect, I hope you understood me. Otherwise, tell me what you didn't understand, and I'll try to say it again.
-
Is it possible to make a recursive function ? (a function that calls itself).
-
Damn, i think I've fixed the error, but the error message didn't help me at all. I just remembered what could be wrong. The message said 'error: missing separator character after keyword'. Given the message, I first thought a space was missing at some place. Actually, I think what was missing are the parenthesis after the definition.
-
A script can run even though it's not well programed, can't it ? It's my first script, so I'd like you to tell me if it's ok and if it can be improved.
-
Anyway, can someone tell me if my functions are ok, at post 58 ?
-
Well, that's in case you copied/pasted the missing part... can't this bug be fixed, given that we are in a forum for programers ? ^^. I'll try to use "code" instead of "autoit".
-
I can't just delete them, it was part of what I had written. Part of my text disappeared when I tried to quick edit !! Fortunately, I had copy paste it. Is this a known bug ??
-
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 ?
-
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).
-
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)
-
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).
-
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 ?
-
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 : 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).
-
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 ?
-
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
-
- 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("")>>.
-
"autoit window info tool with autoit" gives the position of the mouse ?? (can you make full sentences please? it's hard to see what question you're answering to) what loop ? Can you be more precise ?
-
1- when i'm not using the autoit script, i want to know the position of my mouse (in order to program it later on) - how do i do that ? 1- x and y go from what number to what number?. 2- ok for winactive. 3- i know that winclose will close the window at a certain time. but i want it to be closed at anytime, as soon as it appears. How to do that ?