Jump to content

Need help to make my first script work.


Recommended Posts

Hello,

I'd like to write a autoit script that basically goes to this forum, opens every topic of this forum, and copies/pastes all in a .txt.

I'd like to use Torpark (you can download it from here .

Press the link that is in a red box, which is called 'lancer le telechargement' (it's French, but don't worry, the software is in English).

Don't forget to allow pop-ups).

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 Torpark

2- If a window opens and says that Torpark is already running, press enter (it will close the Torpark that is running), and go to the step 1-.

3- Wait for 15 seconds for Torpark 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 Torpark didn't open.

4b- Second possibility : it opened. Then continue to the next step (5-).

5- Maximize the Torpark window.

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) (if you want to test my script, you might have to adapt this function for yourself)

8- If there's a problem loading page (connection issue), then close Torpark 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 Torpark, 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- copy paste the topic into a .txt (let's assume this part is already done).

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.

Thus, If you want to test my script, you will have to change these specific numbers

Here is the script that I made :

Func  _wait_load() ;->waits for the page to load
    $initialsum=1293582875 ;change that for yourself
    While PixelChecksum(1084,975,1180,988)=$initialsum ;change the 4 numbers for yourself
        Sleep(50)
    WEnd
    While PixelChecksum(1084,975,1180,988)=$initialsum
        Sleep(100)
    WEnd
EndFunc  ; ->_wait_load

Opt("WinTextMatchMode", 2) 

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:\Documents and Settings\John\Desktop\Torpark 2.0.0.3a\Torpark.exe") ;(or whereever your .exe is)
If WinWaitActive("Torpark  - Turn any terminal into an anonymous connection.") Then
    Send("{Enter}")
    continueLoop 
EndIf ; If Torpark is already running, shut it down and go to step 1.


If Not(WinWait("Mozilla",15)) Then 
    If WinExists("Firefox Add-on Updates") Then
        WinClose("Firefox Add-on Updates") ; close available updates.
    else
    MsgBox(0,"Error","Torpark didn't open") 
    EndIf
EndIf
WinSetState("Mozilla","",@SW_MAXIMIZE) 

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") Then
    Winclose("Problem loading page") 
    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) ;you might want to change these 4 numbers if you want to test the script
If Not(@error) Then
    MouseMove($coord[0],$coord[1])
    EndIf
MouseClick("left")
_wait_load()
If WinActive("Problem loading page") Then
    WinClose("Problem loading page")
    ContinueLoop 3
EndIf
; 
; here will be the copy-paste into a .txt.
;
$c=$c+1 ; c is the number of successfull copies/pastes 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 for your help.

PS: I know you would prefer me to use ie to visit all pages of a forum, but i've already had a discussion about that, and I want to use firefox (it's actually Torpark, but it works like firefox). Please help me to make my script as good as possible (even if it's not perfect, and even if some errors might occur).

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

Edited by Elishac
Link to comment
Share on other sites

If you don't understand the purpose of this script, here is an example (but i actually want to do something even more complicated, we'll see about that later on - let's firstly make this script work) :

Let's say that a chinese person, called John, (let it be me) wants to learn how to use autoit.

Therefore he wants to read all the topics in the autoit forum.

But, as you may know, China has a huge firewall that forbids to go to some pages (see here).

Let the autoit forum be one of these pages.

Then, how can John access the forum ?

He would have to shortcut the chinese firewall.

How can he do that ?

I'm not very good at computer science, so maybe there's an easiest way than the one I'm about to tell you, but anyway, I found a way to do that : using Torpark software (see here, it's the same Wikipedia page as the link before).

The problem of using Torpark is that it slows down the Network a lot. And John can't afford to lose 1 minute every time he clicks a link.

Therefore, I'd like to create a script that uses the Torpark software and copies/pastes every topic of the autoit forum into some .txt, that John can run while doing something else. Afterwards, John will be free to read the autoit topics, as they will be saved on his computer.

Torpark uses a bit of Mozilla Firefox, and that's why I needed to use Mozilla, instead of Internet Explorer.

Edited by Elishac
Link to comment
Share on other sites

Don't need to waste time with it, just use some 'mask' , like boredatschool.com

[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

Thanks for your answer.

Nonetheless, this is actually the second topic about this script, and I've already discussed about the possible softwares that can do it. It was just an example (what I want to do is more complicated, and can't be done with any other software - but now, let's just make this algorithm work), and I really need this done.

Link to comment
Share on other sites

  • 2 weeks later...

You not getting help because you want help for all problems you have at once.

Try to solve problem by problem, take one issue and search/ask solution for it.

When someone see such big post with many questions/tasks, he loses the desire to help. To be honest, i am for example didn't read all the first post :)

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

You not getting help because you want help for all problems you have at once.

Try to solve problem by problem, take one issue and search/ask solution for it.

When someone see such big post with many questions/tasks, he loses the desire to help. To be honest, i am for example didn't read all the first post :)

sorry but I'm the second living example

[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

Work on doing one small fuction at a time. As you build each one of those effectivly the next step will become easier.

Also FF is unfourtunatly not that heavily suported. You may want to sytart wil eaiser stuff in IE first. (maybe just grabbing basic page stuff first) then move on from there. Also it looks like you are not actually using FF wich is a bigger problem. You are moving further away from supported software.

Start small and little. then move on from there. Build like using Lego's as you get one wall the next will be easier till eventually you have a whole house.

Dont just try to build the house striaght out or you will fail.

Link to comment
Share on other sites

I know it's a complicated script, but it's the only one I want to do right now, and I really need it to work.

I would love to help you and to take my problems one by one, but I don't know how to do that : I don't know what is wrong with the script.

If you think it's too long to read the first post and to correct it, then maybe you would be faster to do the script for me, instead of correcting it. I just need a working script, I don't care if I didn't make it by myself.

<<<< If you want to make the script yourself, here is what you have to do : download Torpark (for free), version 2.0.0.3a. Then make a script that opens a torpark page (it's like a firefox one), and copy/paste all posts of a forum into a .txt. >>>>

For further details, read the first post, but I think it's enough. That wasn't too long, was it ?

As far as I can see in the autoitscript forum, the scripts you are used to make are far more complicated than this one. It should be easy, it's not that long. The only problem is that you can't use the usual functions you're used to, since it's firefox and not ie.

Link to comment
Share on other sites

i think some people (includes me ) arent too happy about the idea of the whole forum being scanned and collected by an anonymous robot program :)

apart from that : if you automatize programs where there is no API for (firefox in this case) you will face limitations. therefore it may be better to use a generic program like commandline wget or curl , which also works with TOR proxy

Link to comment
Share on other sites

Actually I don't mean to scan a whole forum. It was just an example (see message 1 for more explanations). My idea is a little bit more complicated, but since we aren't able to do this simple algorithm, let's not make it even more complicated.

I don't know commandline wget or curl, but I know torpark. Anyway, if you can make my algorithm work with commandline wget or curl, it's fine too.

Please help me to make this script work.

PS: A lot of people (like nobbe, in the previous message) have tried to help me and give me some advices about how to do what I want without using torpark. Thanks for trying to help, but I want to do my algorithm the way it is described in message 1 (that's to say, with torpark, and not with another software or ie or anything else). Just help me to make the script work, as it is not working yet !!!

In that topic, nobody has tried to make my script work so far. Please correct my script, or make another one if you think it would be faster to make it than to correct it, but use torpark anyway.

Thanks a lot for your help.

Edited by Elishac
Link to comment
Share on other sites

  • 4 weeks later...

Please help me... I've been trying to do that script for months now, and I'm sure you can do it in 2 hours... there's no need to read all the topic, just read my first post.

If you can't help me to find out where the mistake is, then please make this script for me, but please help me... I really need it...

Link to comment
Share on other sites

Please help me... I've been trying to do that script for months now, and I'm sure you can do it in 2 hours... there's no need to read all the topic, just read my first post.

If you can't help me to find out where the mistake is, then please make this script for me, but please help me... I really need it...

Wow dude, can you read?
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...