Jump to content

Recommended Posts

Posted (edited)
; los comentarios empiezan por signo ";" no son fin de sentencia como en Java
; autor Aníbal Álvarez Álvarez
; fecha creación: 21-09-18

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <wd_core.au3>
#include <wd_helper.au3>
#include <MsgBoxConstants.au3>
#include <GuiStatusBar.au3>
#include <GuiEdit.au3>
#include <WindowsConstants.au3>
#include <FileConstants.au3>
#include <WinAPIFiles.au3>

    Local $sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":false}}'
    Local Const $sMessage = "Selecciona un fichero TXT."

;    MsgBox($MB_SYSTEMMODAL,"",@ScriptDir & @CRLF &_WinAPI_GetCurrentDirectory())

    Global $sFile

    ; Create GUI
    Global $hGUI = GUICreate("(Pega aquí tu) Listado de páginas web", 1000, 800)
    Global $idEdit = _GUICtrlEdit_Create($hGUI,"https://www.biomedcentral.com", 2, 2, 1000, 700)

    _GUICtrlEdit_AppendText($idEdit,@CRLF & 'https://www.reference.com')
    _GUICtrlEdit_AppendText($idEdit,@CRLF & 'http://www.oup.com')
    _GUICtrlEdit_AppendText($idEdit,@CRLF & 'https://www.ssa.gov')
    _GUICtrlEdit_AppendText($idEdit,@CRLF & 'https://www.libsyn.com')
    _GUICtrlEdit_AppendText($idEdit,@CRLF & 'https://www.windowsphone.com')
    _GUICtrlEdit_AppendText($idEdit,@CRLF & 'https://www.ny.gov')
    _GUICtrlEdit_AppendText($idEdit,@CRLF & 'https://www.bigcommerce.com')
    _GUICtrlEdit_AppendText($idEdit,@CRLF & 'https://www.oreilly.com')
    _GUICtrlEdit_AppendText($idEdit,@CRLF & 'http://www.domeneshop.no')
    _GUICtrlEdit_AppendText($idEdit,@CRLF & 'http://www.artisteer.com')
    _GUICtrlEdit_AppendText($idEdit,@CRLF & 'https://www.arxiv.org')

    $hStatusBar = _GUICtrlStatusBar_Create($hGUI, -1)
    _GUICtrlStatusBar_SetIcon($hStatusBar, 0, 97, "shell32.dll")
    _GUICtrlStatusBar_SetText($hStatusBar, @TAB & "Lines: " & _GUICtrlEdit_GetLineCount($idEdit))

    Global $idButton = GUICtrlCreateButton("Abrir links", 10, 720, 250)
    GUICtrlSetState(-1, $GUI_FOCUS) ; the focus is on this button

    Global $idButton2 = GUICtrlCreateButton("Cargar links desde archivo", 300, 720, 250)

    GUISetState(@SW_SHOW)


Do
        $idMsg = GUIGetMsg()
        If $idMsg = $idButton Then

            SetupGecko()
            Firefox()
        EndIf
        If $idMsg = $idButton2 Then

            FileLoad()
        EndIf
Until $idMsg = $GUI_EVENT_CLOSE

Func FileLoad()
    ; Create a constant variable in Local scope of the message to display in FileOpenDialog.
    Local Const $sMessage = "Selecciona un fichero TXT que contenga links web."


    Local $sFileOpenDialog = FileOpenDialog($sMessage, _WinAPI_GetCurrentDirectory() & "\", "Archivo de texto (*.txt)", $FD_FILEMUSTEXIST)
    If @error Then

        MsgBox($MB_SYSTEMMODAL, "", "No se ha selecionado ningún fichero.")
        FileChangeDir(@ScriptDir)
    Else
        FileChangeDir(@ScriptDir)
        $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF)
        _GUICtrlEdit_SetText($idEdit, FileRead($sFileOpenDialog))
        _GUICtrlStatusBar_SetText($hStatusBar, @TAB & "Lines: " & _GUICtrlEdit_GetLineCount($idEdit))
    EndIf
EndFunc   ;==>FileLoad

Func Firefox()
    $sFFPid = _WD_Startup()
    $sSession = _WD_CreateSession($sDesiredCapabilities)

    _WD_Navigate($sSession, _GUICtrlEdit_GetLine($idEdit, 0))

    Local $total = _GUICtrlEdit_GetLineCount($idEdit)

    For $x = 1 To $total-1 Step +1

        _WD_NewTab($sSession,'true')

        _WD_Navigate($sSession, _GUICtrlEdit_GetLine($idEdit, $x))
    Next
EndFunc    ;==>Firefox

Func SetupGecko()
    _WD_Option('Driver', _WinAPI_GetCurrentDirectory() & '\geckodriver.exe')
    _WD_Option('DriverParams', '--log trace')
    _WD_Option('Port', 4444)
EndFunc   ;==>SetupGecko

Hi. As a description of this code, the code do a simple GUI with an edit text box and two buttons. You can paste your web links into the text box and press left button to open the number of your links pasted on Firefox each one of them in a sigle tab, so I called the script "webloader". The second button opens a txt file with web links and load them at the text box.

webloader.au3Fetching info...

webloader.PNG

Edited by ademon
complete description and images
Posted

Please read this:

How to post code on the forum *

And edit your post accordingly to the provided URL.

Btw.
When you post code in Examples... please provide also some description.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

The forums search function is your friend ;)

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted (edited)
  On 9/24/2018 at 7:02 AM, ademon said:

Done.

Expand  

not completely ...

  On 9/21/2018 at 11:04 AM, mLipok said:

Btw.
When you post code in Examples... please provide also some description.

Expand  

Could you describe a bit your example ?

edti: In English please.

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...