Jump to content

Recommended Posts

Hi all, 

 

I´m trying to use the command "WD_LoadWait" because I want to pause the script until the web page fully loads in Firefox but I don´t know how to use it.

Here´s the full help

; #FUNCTION# ====================================================================================================================
; Name ..........: _WD_LoadWait
; Description ...: Wait for a browser page load to complete before returning
; Syntax ........: _WD_LoadWait($sSession[, $iDelay = 0[, $iTimeout = -1[, $sElement = '']]])
; Parameters ....: $sSession - Session ID from _WDCreateSession
; $iDelay - [optional] Milliseconds to wait before checking status
; $iTimeout - [optional] Period of time to wait before exiting function
; $sElement - [optional] Element ID to confirm DOM invalidation
; Return values .: Success - 1
; Failure - 0 and sets the @error flag to non-zero
; Author ........: Dan Pollak
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _WD_LoadWait($sSession, $iDelay = Default, $iTimeout = Default, $sElement = Default)
Local Const $sFuncName = "_WD_LoadWait"
Local $iErr, $sResponse, $oJSON, $sReadyState
 
If $iDelay = Default Then $iDelay = 0
If $iTimeout = Default Then $iTimeout = $_WD_DefaultTimeout
If $sElement = Default Then $sElement = ""
 
If $iDelay Then Sleep($iDelay)
 
Local $hLoadWaitTimer = TimerInit()
 
While True
If $sElement <> '' Then
_WD_ElementAction($sSession, $sElement, 'name')
 
If $_WD_HTTPRESULT = $HTTP_STATUS_NOT_FOUND Then $sElement = ''
Else
$sResponse = _WD_ExecuteScript($sSession, 'return document.readyState', '')
$iErr = @error
 
If $iErr Then
ExitLoop
EndIf
 
$oJSON = Json_Decode($sResponse)
$sReadyState = Json_Get($oJSON, "[value]")
 
If $sReadyState = 'complete' Then ExitLoop
EndIf
 
If (TimerDiff($hLoadWaitTimer) > $iTimeout) Then
$iErr = $_WD_ERROR_Timeout
ExitLoop
EndIf
 
Sleep(100)
WEnd
 
If $iErr Then
Return SetError(__WD_Error($sFuncName, $iErr, ""), 0, 0)
EndIf
 
Return SetError($_WD_ERROR_Success, 0, 1)

EndFunc

 

Any sugestions or examples?

Share this post


Link to post
Share on other sites

Hi Picorico2 and welcome!

First, when we post code we use the button that looks like this: <>  on the forum post editor.

Second, what do you mean you don't know how to use it? Have you installed a driver for your browser? Does _WD_CreateSession work? Do you not understand the _WD_LoadWait parameters? (Being a little more specific goes a long way)


All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts

Share this post


Link to post
Share on other sites

Did you happen to look in wd_demo.au3? There's an example in there showing how to call _WD_LoadWait.

P.S. Instead of posting the UDF function, it would have been better if you had posted your code so that we can see what you are trying to do and where you may have gone awry.

Share this post


Link to post
Share on other sites

Thanks for the early reply,

 

Its an honor that the creator of the Web Driver has answered me.

 

I just want to open a web page, and pause the script until it fully loads.

 

and do I have to use the line below (I'm a newbie)

 

$sSession = _WD_CreateSession($sDesiredCapabilities)

Please post an example.

 

Share this post


Link to post
Share on other sites

After creating the session, you can then navigate to the desired site using _WD_Navigate. Next you would call _WD_LoadWait. Something like this --

_WD_Navigate($sSession, "http://google.com")
_WD_LoadWait($sSession)

_WD_LoadWait offers several optional parameters. Look at the function header for a description of what action each one performs. Try writing some code to "practice" using these optional features. Then come back and let us know how you fared. :thumbsup:

Share this post


Link to post
Share on other sites

Good Morning Danp2,

 

I got an error that says that I haven´t declared the variable so I copied the line below from your demo but still doesn´t do anything

 

Local $sDesiredCapabilities, $iIndex, $sSession

 

Here's the code:

#include "wd_core.au3"
#include "wd_helper.au3"
#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>

Local $sDesiredCapabilities, $iIndex, $sSession

_WD_Navigate($sSession, "https://guerrero.gob.mx/Pry_PagoReferenciado/Administracion/indexMs.php")

_WD_LoadWait($sSession)

 

Like I said I´m a newbie but I want to learn, pls be patient. 😄

 

 

 

Share this post


Link to post
Share on other sites

I would really suggest taking a look at wd_demo.au3 that comes with the UDF. You're looking for something a bit more like this: (untested)

#include <MsgBoxConstants.au3>
#include <wd_core.au3>
#include <wd_helper.au3>

; Here you can specify some browser specific settings... you'll need to research them depending on your browser
; ... or just copy paste someone else's code :D

#Region Settings Setup
  _WD_Option('Driver', 'geckodriver.exe')
  _WD_Option('DriverParams', '--log trace')
  _WD_Option('Port', 4444)

  Global $sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}'
#EndRegion Settings Setup

; You need to initialize some stuff with this UDF
_WD_Startup()
; If there is an error setting stuff up, then exit
If @error <> $_WD_ERROR_Success Then
    Exit -1
EndIf

; Create a new instance of a browser with some settings you request
Global $sSession = _WD_CreateSession($sDesiredCapabilities)
; If there was an error, exit
If Not (@error = $_WD_ERROR_Success) Then Exit MsgBox($MB_ICONERROR, "Error: _WD_CreateSession", "Failed to create a Session. Check your desired capabilities.")

; Move to the requested website
_WD_Navigate($sSession, "http://yourwebsite.com")

; Anything you want to do after navigating to the website goes here
MsgBox($MB_ICONINFORMATION, "Navigation completed!", "Click ok to shutdown the browser and console")

; This removes the browser instance
_WD_DeleteSession($sSession)

; And this cleans up some resources
_WD_Shutdown()

Edit 1: Updated with Gecko driver settings... didn't realize that was used for FireFox
Edit 2: _WD_Options goes before _WD_Startup

Edited by seadoggie01

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts

Share this post


Link to post
Share on other sites

Did you download the geckodriver? If yes: Is it located in your script's directory, or did you properly specify the location of it?


All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts

Share this post


Link to post
Share on other sites

My apologies, a little dyslexia going on there... _WD_Options goes first, then _WD_Startup... I'll edit my post


All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts

Share this post


Link to post
Share on other sites

Hi there again,

Now for some unknown reason it has stopped working

It doesn´t open the web page anymore and continues the script.

Here's my code:

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.5
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <MsgBoxConstants.au3>
#include <wd_core.au3>
#include <wd_helper.au3>
#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>

HotKeySet("{Esc}", "ExitScript")

$_WD_DEBUG = $_WD_DEBUG_None ; You could also use $_WD_DEBUG_Error

; Here you can specify some browser specific settings... you'll need to research them depending on your browser
; ... or just copy paste someone else's code :D

#Region Settings Setup
_WD_Option('Driver', 'C:\Program Files (x86)\AutoIt3\Include\geckodriver.exe')
_WD_Option('DriverParams', '--log trace')
_WD_Option('Port', 4444)

Global $sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}'
#EndRegion Settings Setup

; You need to initialize some stuff with this UDF
_WD_Startup()
; If there is an error setting stuff up, then exit
If @error <> $_WD_ERROR_Success Then
    Exit -1
EndIf

; Create a new instance of a browser with some settings you request
;Global $sSession = _WD_CreateSession($sDesiredCapabilities)
; If there was an error, exit
;If Not (@error = $_WD_ERROR_Success) Then Exit MsgBox($MB_ICONERROR, "Error: _WD_CreateSession", "Failed to create a Session. Check your desired capabilities.")


Local $sDestination = "E:\Documentos\AUTOIT\palomitav.jpg"

Local $sDesiredCapabilities, $iIndex, $sSession

;Verificar si la serie es correcta

MsgBox($MB_SYSTEMMODAL, "Serie", "Favor de copiar la serie y dar clic en Aceptar")

SplashTextOn("", "Verificando la serie en Pago Referenciado...", 200, 60, 1400, 5, 600, 60, opt = 1)
; Ancho_Ven, Alto_Ven        Y,

Send("^{TAB}")

_WD_LoadWait($sSession, "https://guerrero.gob.mx/Pry_PagoReferenciado/Administracion/indexMs.php")

Send("{TAB 3}")
Sleep(1000)
Send("{ENTER}")

_WD_LoadWait($sSession, "https://guerrero.gob.mx/Pry_PagoReferenciado/Administracion/menuOper.php")

MouseMove(1047, 115, 5)
MouseMove(1047, 145, 5)
MouseMove(1223, 145, 5)
MouseMove(1223, 170, 5)
MouseClick("left")

_WD_LoadWait($sSession, "https://guerrero.gob.mx/Pry_PagoReferenciado/Administracion/PagoTenencia/tenencia2015/admin.php")

Send("{TAB}")
Send("^v")
MouseMove(404, 224, 5)
MouseClick("left")

SplashOff()

$a = MsgBox(4, "", "¿Es correcta la serie?")

If $a = 6 Then ;SI

    ;MouseMove(309, 476, 5)
    ;MouseClick("left")
    Send("{TAB 6}")
    ;Sleep(500)
    Send("{DOWN 3}")
    Send("{TAB}")
    Send("{ENTER}")

    Send("{TAB}")
    Send("{ENTER}")

    _WD_LoadWait($sSession, "https://guerrero.gob.mx/Pry_PagoReferenciado/Administracion/PagoTenencia/tenencia2015/index.php?i=3&usu=570&serie=8AFDR5ADXA6284122&sid=0.29255510000995255")

    Send("{END}")

ElseIf $a = 7 Then ;NO

    Send("^+{TAB}")

    MsgBox($MB_SYSTEMMODAL, "Placa", "Favor de copiar la PLACA y dar clic en Aceptar")

    Send("^{TAB}")

    MouseMove(425, 226, 5)
    MouseClick("left")

    Sleep(1000)
    Send("{TAB}")
    Send("^v")
    Sleep(10000)

    $a = MsgBox(4, "", "¿Es correcta la placa?")

    If $a = 6 Then ;SI

        MouseMove(95, 295, 5)
        MouseClick("left")
        MouseMove(404, 224, 5)
        MouseClick("left")
        MouseMove(309, 517, 5)
        MouseClick("left")
        Sleep(1000)
        Send("{DOWN 3}")
        Send("{ENTER}")
        Sleep(1000)
        Send("{TAB}")
        Send("{ENTER}")
        Sleep(1000)
        Send("{TAB 2}")
        Send("{ENTER}")
        Sleep(4000)
        Send("{END}")

    ElseIf $a = 7 Then ;NO

        ;WinActivate ("Cobro de Tenencia ::: Sistema Pago Referenciado - Mozilla Firefox")

        Sleep(1000)

        Send("^+{TAB}")

        Send("r")

        Sleep(3000)

        Send("El número de serie y placa son incorrectos")

    EndIf

EndIf

Func ExitScript()
    Exit
EndFunc   ;==>ExitScript

 

 

 

Share this post


Link to post
Share on other sites

@picorico2

Please read:

and this:

https://www.autoitscript.com/wiki/Forum_FAQ#How_can_I_post_.22code.22_on_the_forum_.3F

also:
https://www.autoitscript.com/wiki/Forum_FAQ#How_can_I_edit_my_post_on_the_forum_.3F

so I propose you to edit your post because the code you posted is not posted well (is not formated).


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2019-10-01

Share this post


Link to post
Share on other sites
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.5
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <MsgBoxConstants.au3>
#include <wd_core.au3>
#include <wd_helper.au3>
#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>

HotKeySet("{Esc}", "ExitScript")

$_WD_DEBUG = $_WD_DEBUG_None ; You could also use $_WD_DEBUG_Error

; Here you can specify some browser specific settings... you'll need to research them depending on your browser
; ... or just copy paste someone else's code :D

#Region Settings Setup
_WD_Option('Driver', 'C:\Program Files (x86)\AutoIt3\Include\geckodriver.exe')
_WD_Option('DriverParams', '--log trace')
_WD_Option('Port', 4444)

Global $sDesiredCapabilities = '{"desiredCapabilities":{"javascriptEnabled":true,"nativeEvents":true,"acceptInsecureCerts":true}}'
#EndRegion Settings Setup

; You need to initialize some stuff with this UDF
_WD_Startup()
; If there is an error setting stuff up, then exit
If @error <> $_WD_ERROR_Success Then
    Exit -1
EndIf

; Create a new instance of a browser with some settings you request
;Global $sSession = _WD_CreateSession($sDesiredCapabilities)
; If there was an error, exit
;If Not (@error = $_WD_ERROR_Success) Then Exit MsgBox($MB_ICONERROR, "Error: _WD_CreateSession", "Failed to create a Session. Check your desired capabilities.")


Local $sDestination = "E:\Documentos\AUTOIT\palomitav.jpg"

Local $sDesiredCapabilities, $iIndex, $sSession

;Verificar si la serie es correcta

MsgBox($MB_SYSTEMMODAL, "Serie", "Favor de copiar la serie y dar clic en Aceptar")

SplashTextOn("", "Verificando la serie en Pago Referenciado...", 200, 60, 1400, 5, 600, 60, opt = 1)
; Ancho_Ven, Alto_Ven        Y,

Send("^{TAB}")

_WD_LoadWait($sSession, "https://guerrero.gob.mx/Pry_PagoReferenciado/Administracion/indexMs.php")

Send("{TAB 3}")
Sleep(1000)
Send("{ENTER}")

_WD_LoadWait($sSession, "https://guerrero.gob.mx/Pry_PagoReferenciado/Administracion/menuOper.php")

MouseMove(1047, 115, 5)
MouseMove(1047, 145, 5)
MouseMove(1223, 145, 5)
MouseMove(1223, 170, 5)
MouseClick("left")

_WD_LoadWait($sSession, "https://guerrero.gob.mx/Pry_PagoReferenciado/Administracion/PagoTenencia/tenencia2015/admin.php")

Send("{TAB}")
Send("^v")
MouseMove(404, 224, 5)
MouseClick("left")

SplashOff()

$a = MsgBox(4, "", "¿Es correcta la serie?")

If $a = 6 Then ;SI

    ;MouseMove(309, 476, 5)
    ;MouseClick("left")
    Send("{TAB 6}")
    ;Sleep(500)
    Send("{DOWN 3}")
    Send("{TAB}")
    Send("{ENTER}")

    Send("{TAB}")
    Send("{ENTER}")

    _WD_LoadWait($sSession, "https://guerrero.gob.mx/Pry_PagoReferenciado/Administracion/PagoTenencia/tenencia2015/index.php?i=3&usu=570&serie=8AFDR5ADXA6284122&sid=0.29255510000995255")

    Send("{END}")

ElseIf $a = 7 Then ;NO

    Send("^+{TAB}")

    MsgBox($MB_SYSTEMMODAL, "Placa", "Favor de copiar la PLACA y dar clic en Aceptar")

    Send("^{TAB}")

    MouseMove(425, 226, 5)
    MouseClick("left")

    Sleep(1000)
    Send("{TAB}")
    Send("^v")
    Sleep(10000)

    $a = MsgBox(4, "", "¿Es correcta la placa?")

    If $a = 6 Then ;SI

        MouseMove(95, 295, 5)
        MouseClick("left")
        MouseMove(404, 224, 5)
        MouseClick("left")
        MouseMove(309, 517, 5)
        MouseClick("left")
        Sleep(1000)
        Send("{DOWN 3}")
        Send("{ENTER}")
        Sleep(1000)
        Send("{TAB}")
        Send("{ENTER}")
        Sleep(1000)
        Send("{TAB 2}")
        Send("{ENTER}")
        Sleep(4000)
        Send("{END}")

    ElseIf $a = 7 Then ;NO

        ;WinActivate ("Cobro de Tenencia ::: Sistema Pago Referenciado - Mozilla Firefox")

        Sleep(1000)

        Send("^+{TAB}")

        Send("r")

        Sleep(3000)

        Send("El número de serie y placa son incorrectos")

    EndIf

EndIf

Func ExitScript()
    Exit
EndFunc   ;==>ExitScript

 

Share this post


Link to post
Share on other sites

While you are in "debugging mode", I would recommend removing the line where you modify $_WD_DEBUG. That way, you get the greatest level of feedback in the Scite console panel. Also, it looks like you've commented out the line containing _WD_CreateSession, so that would explain why the browser is no longer being launched.

Finally, be careful with your variable declarations. I see where you are declaring some variables as Global and then redeclaring them as Local ($sDesiredCapabilities for example).

Share this post


Link to post
Share on other sites

Ok. I removed the debugging mode. I commented out the line containing the _WD_CreateSession because I don´t want to open a new Firefox Windows, I just want to move to the next tab on the right, open a web site, wait for it to finish loading and move on, and finally I don´t undertand about variables and declarations :(  pls help me to fix the code, and also can you tell me what´s the meaning of "DesiredCapabilities" sound funny to me. English is not my first language.

The main reason I want to use Webdrive is because sometimes the web site I´m trying to access in Firefox takes longer to completely load than usual so if I use "Sleep" is not very accurate.

Thank you kindly.

 

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By FUD
      hello 
      please i need help 
      i need to open link in default browser only one windows without duplicate if i try to open the same link 
       
      thanks 
    • By water
      Internet Explorer is nearly dead, newer versions of Firefox can't any longer be automated using Stilgar's FF UDF.
      Hence more and more users (including me) need to look at automating Webbrowsers using WebDriver.
      That's why I have started to create a tutorial in the wiki.
      It should describe all necessary steps from intallation to usage.

      I'm still collecting ideas for the tutorial - that's where you come into play.
      What do you expect to see in such a tutorial?
      Which browsers should be covered (Firefox, Chrome and Edge are settled)? Any questions for the FAQ? Which (high level) coding examples do you expect (like "How to attach to a running browser instance") ... Like to see your comments
       
      ToDo-List:
      Add "Tools" section and add ChroPath plugin. Done. FAQ: "How to attach to a running browser instance". Done. Explain the difference between iuiautomation, iaccessible, autoit, webdriver. Done. The AutoIt FAQ 40 has been extended. Detailed description of each function. Done Example for "how to deal with downloading". Use function _WD_DownloadFile. Example for "how to deal with popups (alerts, print or save dialog). Use function_WD_AlertRespond to respond to a user prompt. Example for "how to deal with multiple tabs". Use functions _WD_NewTab (create a new tab), _WD_Window (close or switch to a tab) and _WD_Attach (attach to existing tab).
    • By ThePoro
      Hi everyone.
      I want to ask about this : 
      I want it runs from 1 to 100 and It opens 10 firefox profiles then access youtube. After I close a firefox window, the loop runs and wait for another window close until loop ends
      I have a loop like this.
      Func launch() Local $from = Int(GUICtrlRead($input1)) Local $to = Int(GUICtrlRead($input2)) If $to <> "" Then While $from <= $to Local $profile = $to _RunDos("start firefox.exe -p " & $profile & " -no-remote youtube.com") $to=$to+1 WEnd Else Local $profile = $to _RunDos("start firefox.exe -p " & $profile & " -no-remote youtube.com") EndIf EndFunc Is there any solution?
      Thank you!
    • By nooneclose
      my FF.au3 does get included but my script does not open firefox. 
      here is my code so far:
      #include <FF.au3> _FFStart("https://www.google.com", Default, 0) I am using firefox portable version 52.0 Any and all help would be greatly appreciated.  
      The code runs but nothing happens. I think the FF.au3 cannot find or connect to the firefox portable.  
    • By Carm01
      All,
      I have decided to release my code for the automated clean install, set up and configuration of Mozilla Firefox with a Mozilla.cfg file included in my example as well. I seen an older version of this and decided to post mine on here. This is Windows 10 friendly.
      The whole process once compiled executes in about 15 seconds on my machine from start to finish as it is extremely fast.
      If you want to include your own Mozilla.cfg into the mix simply place Your Mozilla.cfg file in the same directory as the exe when it is run. If you do not wish to embed the Mozilla.cfg file into the script as a back up in case you forget you need to remove that line of code to embed it.
      I hope this helps some people esp those wanting to understand how to use a cfg file to set default settings for all users without having to do it by putting all those files and folders in the defaultapp data folders.
      #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Clear-App-firefox.ico #AutoIt3Wrapper_Outfile=FirefoxUpdater(x64Stable)_x.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_Comment=Preformes a clean install of Firefox 64bit Stable version. Auto downloads latest version. #AutoIt3Wrapper_Res_Description=Updates to the Latest 64bit Stable #AutoIt3Wrapper_Res_Fileversion=2.5.0.0 #AutoIt3Wrapper_Res_ProductVersion=2.5.0.0 #AutoIt3Wrapper_Res_Language=1033 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <InetConstants.au3> #include <EventLog.au3> #include <Inet.au3> #include <File.au3> #include <array.au3> #include <Misc.au3> #include <TrayConstants.au3> ; Required for the $TRAY_CHECKED and $TRAY_ICONSTATE_SHOW constants. If UBound(ProcessList(@ScriptName)) > 2 Then Exit TraySetToolTip("Firefox Updater") HotKeySet("^!m", "MyExit") ; ctrl+Alt+m kills program ( hotkey ) Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode. Opt("TrayOnEventMode", 1) ; Enable TrayOnEventMode. TrayCreateItem("About") TrayItemSetOnEvent(-1, "About") TrayCreateItem("") ; Create a separator line. TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "ExitScript") TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "About") ; Display the About MsgBox when the tray icon is double clicked on with the primary mouse button. TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu. Local $sVersion, $CVersion, $ecode ;https://www.mozilla.org/en-US/firefox/developer/all/ ;https://www.mozilla.org/en-US/firefox/all/# ;https://www.mozilla.org/en-US/firefox/all/#en-US ;https://www.mozilla.org/en-US/firefox/beta/all/#en-US ;https://archive.mozilla.org/pub/firefox/candidates/48.0b1-candidates/build2/ ;https://archive.mozilla.org/pub/firefox/candidates/ getfiles() compare() killapps() uninstall() dlinstall() Exit Func killapps() ; kill firefox and plugin if running If FileExists("C:\Program Files\Mozilla Firefox\") Then $cmd = "taskkill.exe /im firefox.exe /f /t" RunWait('"' & @ComSpec & '" /c ' & $cmd, @SystemDir, @SW_HIDE) Sleep(300) $cmd = "taskkill.exe /im plugin* /f /t" RunWait('"' & @ComSpec & '" /c ' & $cmd, @SystemDir, @SW_HIDE) Sleep(300) Call("remcfg64") EndIf If FileExists("C:\Program Files (x86)\Mozilla Firefox\") Then $cmd = "taskkill.exe /im firefox.exe /f /t" RunWait('"' & @ComSpec & '" /c ' & $cmd, @SystemDir, @SW_HIDE) Sleep(300) $cmd = "taskkill.exe /im plugin* /f /t" RunWait('"' & @ComSpec & '" /c ' & $cmd, @SystemDir, @SW_HIDE) Sleep(300) Call("remcfg32") EndIf EndFunc ;==>killapps Func remcfg64() ; delete existing config file if exist $SSlist = _FileListToArrayRec("C:\Program Files\Mozilla Firefox\", "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) For $i = 1 To UBound($SSlist) - 1 If StringInStr($SSlist[$i], "mozilla.cfg") > 1 Then FileDelete($SSlist[$i]) ElseIf StringInStr($SSlist[$i], "override.ini") > 1 Then FileDelete($SSlist[$i]) ElseIf StringInStr($SSlist[$i], "local-settings.js") > 1 Then FileDelete($SSlist[$i]) EndIf Next EndFunc ;==>remcfg64 Func remcfg32() $SSlist = _FileListToArrayRec("C:\Program Files (x86)\Mozilla Firefox\", "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) For $i = 1 To UBound($SSlist) - 1 If StringInStr($SSlist[$i], "mozilla.cfg") > 1 Then FileDelete($SSlist[$i]) ElseIf StringInStr($SSlist[$i], "override.ini") > 1 Then FileDelete($SSlist[$i]) ElseIf StringInStr($SSlist[$i], "local-settings.js") > 1 Then FileDelete($SSlist[$i]) EndIf Next EndFunc ;==>remcfg32 Func uninstall() ; uninstall existing Firefox If FileExists("C:\Program Files\Mozilla Firefox\Firefox.exe") Then ShellExecuteWait("helper.exe", " /S", "C:\Program Files\Mozilla Firefox\uninstall") EndIf If FileExists("C:\Program Files (x86)\Mozilla Firefox\Firefox.exe") Then ShellExecuteWait("helper.exe", " /S", "C:\Program Files (x86)\Mozilla Firefox\uninstall") EndIf Sleep(1500) DirRemove("C:\Program Files (x86)\Mozilla Firefox\", 1) DirRemove("C:\Program Files\Mozilla Firefox\", 1) EndFunc ;==>uninstall Func getfiles() ; get latest download Local $sTxt, $sTxt1 $xjs = "C:\windows\temp\xjs.tmp" $xjs1 = "C:\windows\temp\xjs1.tmp" ;$sSite = "https://www.mozilla.org/en-US/firefox/beta/all/" $sSite = "https://www.mozilla.org/en-US/firefox/all/" ;$sNotes = "https://www.mozilla.org/en-US/firefox/beta/notes/" $sNotes = "https://www.mozilla.org/en-US/firefox/notes/" SplashTextOn("Progress", "", 210, 75, -1, -1, 18, "Tahoma", 10) ControlSetText("Progress", "", "Static1", "Initializing", 2) $source = _INetGetSource($sSite) $sTxt = StringSplit($source, @LF) $q = 0 $i = 0 For $i = 1 To UBound($sTxt) - 1 ; is like saying read the line number ;GUIGetMsg();prevent high cpu usage If StringInStr($sTxt[$i], "=win64&amp;lang=en-US") > 1 Then $sActiveX1 = StringSplit($sTxt[$i], 'href="', 1) $sActiveX2 = StringSplit($sActiveX1[2], '"') Global $dia = $sActiveX2[1] $q = 1 EndIf If UBound($sTxt) - 1 = $i Then $ecode = '404' EventLog() Exit EndIf If $q = 1 Then ExitLoop EndIf Next ; FIND VERSION $source = _INetGetSource($sNotes) $sTxt1 = StringSplit($source, @LF) $q = 0 $i = 0 For $i = 1 To UBound($sTxt1) - 1 ; is like saying read the line number ;GUIGetMsg();prevent high cpu usage If StringInStr($sTxt1[$i], "<title>Firefox") > 1 Then $sActiveX1 = StringSplit($sTxt1[$i], '<title>Firefox', 1) $sActiveX2 = StringSplit($sActiveX1[2], ',') $sVersion = StringStripWS($sActiveX2[1], 3) $q = 1 EndIf If $sVersion = "" Then ; error correcting if mozilla changes page where version notes are located. $sVersion = "Current Version" EndIf If $q = 1 Then ExitLoop EndIf Next SplashOff() EndFunc ;==>getfiles Func dlinstall() ; download and install $Version = $sVersion & " - 64 bit" _webDownloader($dia, "FFInstall.exe", $Version) SplashTextOn("Progress", "", 210, 75, -1, -1, 18, "Tahoma", 10) ControlSetText("Progress", "", "Static1", "Installing Version " & $sVersion, 2) ShellExecuteWait("FFInstall.exe", " -ms", "C:\Windows\Temp\") If FileExists(@ScriptDir & "\mozilla.cfg") Then FileCopy(@ScriptDir & "\mozilla.cfg", "C:\Program Files\Mozilla Firefox\mozilla.cfg", 1) Else FileInstall("G:\Users\username\Documents\Project\FirefoxDefault\mozilla.cfg", "C:\Program Files\Mozilla Firefox\mozilla.cfg", 1) EndIf FileWrite("C:\Program Files\Mozilla Firefox\defaults\pref\local-settings.js", 'pref("general.config.obscure_value", 0);' & @CRLF & 'pref("general.config.filename", "mozilla.cfg");' & @CRLF) FileWrite("C:\Program Files\Mozilla Firefox\browser\override.ini", '[XRE]' & @CRLF & 'EnableProfileMigrator=false' & @CRLF) FileDelete("C:\windows\temp\" & "\FFInstall.exe") $CVersion = FileGetVersion('C:\Program Files\Mozilla Firefox\firefox.exe', $FV_PRODUCTVERSION) SplashOff() EndFunc ;==>dlinstall Func _webDownloader($sSourceURL, $sTargetName, $sVisibleName, $sTargetDir = "C:\windows\temp", $bProgressOff = True, $iEndMsgTime = 2000, $sDownloaderTitle = "Mozilla Firefox") ; Declare some general vars Local $iMBbytes = 1048576 ; If the target directory doesn't exist -> create the dir If Not FileExists($sTargetDir) Then DirCreate($sTargetDir) ; Get download and target info Local $sTargetPath = $sTargetDir & "\" & $sTargetName Local $iFileSize = InetGetSize($sSourceURL) Local $hFileDownload = InetGet($sSourceURL, $sTargetPath, $INET_LOCALCACHE, $INET_DOWNLOADBACKGROUND) ; Show progress UI ProgressOn($sDownloaderTitle, "" & $sVisibleName) GUISetFont(8, 400) ; Keep checking until download completed Do Sleep(250) ; Set vars Local $iDLPercentage = Round(InetGetInfo($hFileDownload, $INET_DOWNLOADREAD) * 100 / $iFileSize, 0) Local $iDLBytes = Round(InetGetInfo($hFileDownload, $INET_DOWNLOADREAD) / $iMBbytes, 2) Local $iDLTotalBytes = Round($iFileSize / $iMBbytes, 2) ; Update progress UI If IsNumber($iDLBytes) And $iDLBytes >= 0 Then ProgressSet($iDLPercentage, $iDLPercentage & "% - Downloaded " & $iDLBytes & " MB of " & $iDLTotalBytes & " MB") Else ProgressSet(0, "Downloading '" & $sVisibleName & "'") EndIf Until InetGetInfo($hFileDownload, $INET_DOWNLOADCOMPLETE) ; If the download was successfull, return the target location If InetGetInfo($hFileDownload, $INET_DOWNLOADSUCCESS) Then ProgressSet(100, "Downloading '" & $sVisibleName & "' completed") If $bProgressOff Then Sleep($iEndMsgTime) ProgressOff() EndIf Return $sTargetPath ; If the download failed, set @error and return False Else Local $errorCode = InetGetInfo($hFileDownload, $INET_DOWNLOADERROR) ProgressSet(0, "Downloading '" & $sVisibleName & "' failed." & @CRLF & "Error code: " & $errorCode) If $bProgressOff Then Sleep($iEndMsgTime) ProgressOff() EndIf SetError(1, $errorCode, False) FileDelete("C:\windows\temp\" & "\FFInstall.exe") SplashOff() EndIf EndFunc ;==>_webDownloader Func compare() $CVersion = FileGetVersion('C:\Program Files\Mozilla Firefox\firefox.exe', $FV_PRODUCTVERSION) If $sVersion = $CVersion Then $ecode = '411' MsgBox(64, "Firefox says:", 'You have the latest version ' & $CVersion , 5) EventLog() Exit EndIf EndFunc ;==>compare Func EventLog() If $ecode = '404' Then Local $hEventLog, $aData[4] = [0, 4, 0, 4] $hEventLog = _EventLog__Open("", "Application") _EventLog__Report($hEventLog, 1, 0, 404, @UserName, @UserName & ' No "exe" found for Mozilla Firefox. The webpage and/or download link might have changed. ' & @CRLF, $aData) _EventLog__Close($hEventLog) EndIf If $ecode = '411' Then Local $hEventLog, $aData[4] = [0, 4, 1, 1] $hEventLog = _EventLog__Open("", "Application") _EventLog__Report($hEventLog, 0, 0, 411, @UserName, @UserName & " Mozilla Firefox " & "version " & $CVersion & " successfully installed." & @CRLF, $aData) _EventLog__Close($hEventLog) EndIf EndFunc ;==>EventLog Func MyExit() Exit EndFunc ;==>MyExit Func About() ; Display a message box about the AutoIt version and installation path of the AutoIt executable. MsgBox($MB_SYSTEMMODAL, "", "Firefox Update Tool" & @CRLF & @CRLF & _ "Version: 2.5.0.0" & @CRLF & _ "Firefox Updater by Carm0@Sourceforge" & @CRLF & "CTRL+ALT+m to kill", 5) ; Find the folder of a full path. EndFunc ;==>About Func ExitScript() Exit EndFunc ;==>ExitScript #comments-start http://superuser.com/questions/823530/change-some-default-settings-for-firefox-globally http://mxr.mozilla.org/mozilla-release/source/browser/app/profile/firefox.js#387 http://smallbusiness.chron.com/change-default-homepage-users-54727.html https://developer.mozilla.org/en-US/Firefox/Enterprise_deployment https://mike.kaply.com/2012/03/16/customizing-firefox-autoconfig-files/ https://wiki.mozilla.org/Installer:Command_Line_Arguments https://support.mozilla.org/en-US/questions/971189 http://forums.mozillazine.org/viewtopic.php?p=2228066 http://forums.mozillazine.org/viewtopic.php?f=38&t=2950829 ; updates auto http://forums.mozillazine.org/viewtopic.php?f=8&t=2753795 http://superuser.com/questions/697018/how-to-disable-popups-in-firefox-without-add-ons http://www.itninja.com/blog/view/deploy-popup-allowed-sites-with-firefox deploy with certain opous enabled #ce Mozilla.cfg file:
      // pref("browser.search.geoSpecificDefaults", false); pref("browser.search.defaultenginename.US", "data:text/plain,browser.search.defaultenginename.US=Google"); //https://support.mozilla.org/en-US/questions/1034136 // set Firefox Default homepage defaultPref("browser.startup.homepage", "data:text/plain,browser.startup.homepage=https://www.startpage.com/do/mypage.pl?prf=381c658b828c3fe50ec7563137fef98f"); // Don't show WhatsNew on first run after every update pref("browser.startup.homepage_override.mstone","ignore"); // disables the 'know your rights' button from displaying on first run pref("browser.rights.3.shown", true); pref("browser.usedOnWindows10", true); pref("browser.rights.override", true); // Do not perform system default browser check on startup pref("browser.shell.checkDefaultBrowser", false); // set all plugins to always activated - two settings pref("plugin.default.state", 2); // https://support.mozilla.org/en-US/questions/982143 reference about click to play flash // set flash and silverlight always ask = 1 always activate = 2 defaultPref("plugin.state.flash", 2); // hide choose what i share which pops up at the bottom after a minute lockPref("datareporting.policy.dataSubmissionPolicyBypassNotification", true); // https://groups.google.com/forum/#!topic/mozilla.support.firefox/DRXvfTA6Hnc //disable the "Improve Firefox" suggestion pref("toolkit.telemetry.prompted", 2); //https://support.mozilla.org/en-US/questions/898549 // do not block popups - can only be default or locked pref defaultPref("dom.disable_open_during_load", false); //http://superuser.com/questions/697018/how-to-disable-popups-in-firefox-without-add-ons //lockpref("privacy.sanitize.migrateFx3Prefs", true); // http://www.pcc-services.com/kixtart/firefox-lockdown.html //pref("browser.privatebrowsing.autostart", true); // prevent reader view from popping down at the top pref("reader.parse-on-load.enabled",false); // click to play - disabled so you are not prompted - https://support.mozilla.org/en-US/questions/934809 pref("plugins.click_to_play", false); // below will set the cache only to clear on exit, you need to tell it what to do with the reset of the data not just cache leave cache out. Just add a '\\' to whatever you want to clear on browser exit. //defaultPref("privacy.clearOnShutdown.cookies", false); defaultPref("privacy.clearOnShutdown.downloads", false); defaultPref("privacy.clearOnShutdown.formdata", false); defaultPref("privacy.clearOnShutdown.history", false); defaultPref("privacy.clearOnShutdown.sessions", false); defaultPref("privacy.sanitize.migrateClearSavedPwdsOnExit", false); defaultPref("privacy.sanitize.sanitizeOnShutdown", true); //pref("browser.privatebrowsing.autostart", true); //prevent autoplay https://support.mozilla.org/en-US/questions/1103127 //defaultPref("media.autoplay.enabled", false); //https://wiki.mozilla.org/Electrolysis //pref("browser.tabs.remote.autostart", true); //pref("browser.tabs.remote.force-enable", true); // ref: http://www.itninja.com/question/firefox-22-for-enterprise-deployment-default-preferences // Prevent refresh message showing at the bottom if firefox is not used in a while - http://techdows.com/2016/05/firefox-reinstall-to-prompt-for-a-refresh.html https://support.mozilla.org/en-US/questions/1084402 pref("browser.disableResetPrompt", true); // disable plugin check - https://support.mozilla.org/en-US/questions/968056 //defaultPref("plugin.scan.plid.all",false); //defaultPref("plugins.update.url",""); // disable remember preferences //defaultPref("signon.rememberSignons", false); //https://twitter.com/HighTechDad/status/955916813178691584 //https://t.co/YTvSy9EBJ1 // defaultPref can also be lockPref defaultPref("privacy.donottrackheader.enabled", true); //defaultPref("privacy.trackingprotection.enabled", true); lockPref("privacy.trackingprotection.introCount", 20);  
×
×
  • Create New...