Jump to content

While loop quits


Recommended Posts

My script will loop 10-20 times then it will just freeze. I cannot figure it out. I also tried a for loop and go the same results. I am running on a Windows 8 VM. Here is my code:

#include <MsgBoxConstants.au3>
#include <array.au3>
#include <IE.au3>

Global $Paused

HotKeySet("p", "TogglePause")
HotKeySet("{ESC}", "Terminate")
$Paused = $Paused

OPT("SendKeyDelay",25)

$File = FileOpen(@DesktopDir & "\email addresses 11-17-2015.txt")
$File1 = FileOpen(@DesktopDir & "\Count.txt")
$aArray = FileReadToArray($File)
Sleep(5000)
;~ _ArrayDisplay($aArray)

Global $Count = 0
While 1
    MouseClick("",909,221);add customer
    MouseMove(691,421)
    Sleep(5000)
    MouseClick("",691,421);email address location
    MouseMove(708,196)
    Sleep(1000)
    Send($aArray[$Count])
    Sleep(500)
    MouseClick("",708,196);save
    MouseMove(691,500)
    Sleep(5000)
    MouseClick("",691,500);Click OK on already exists
    MouseMove(805,206)
    Sleep(3000)
    MouseClick("",805,206);Click Cancel
    MouseMove(909,221)
    Sleep(5000)
;~  Local $PCS = PixelChecksum(662,479,762,510)
;~      If $PCS == 361411749 Then
;~          MouseClick("",715,496)
;~          Sleep(1000)
;~          MouseClick("",778,198)
;~          Sleep(2000)
;~      EndIf

    $Count += 1
WEnd





Func TogglePause()
    $Paused = Not $Paused
    While 1
        Sleep(100)
        ToolTip('Paused', 0, 0)
    WEnd

    ToolTip("")
EndFunc   ;==>TogglePause



Func Terminate()
    FileClose($File1)
    Exit 0
EndFunc   ;==>Terminate

It takes a list of email addresses and adds them to a mailing list online. Is this a bug?

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

As there are no blocking functions in your script I assume that a Send doesn't reach the desired control or a MouseClick doesn't trigger the intended action.
As you include the IE UDF I assume you are automating a web application. Correct?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

That was included because I started to make the script open the webpage and login to the site but I just did that manually as I only need to do this once. As for blocking, the same thing happened when I used a for loop with ubound($aArray) - 1 instead of the while loop. I added several seconds between entries for random load times between the prompts and the problem isn't that the mouse is clicking in the wrong places it's that the script just stops working. It still runs but it just freezes. I can send the data if you want to try to reproduce. It's just a text file with 3600 email addresses in it. Nothing special that should affect my script in this manner. I have run scripts for many weeks on my VM's for other purposes in the past so I dont thing it's my VM.

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

  • Developers

Add 

Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info

 , add some consolewrite() statements showing what is being processed each loop(or write to logfile)  and see where your script gets "stuck".

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

SMH. Yes genuine question. I figured it out. When I hover over the tray icon it says line 52 sleep(100).

 

I see the problem. I was using "p" instead of my usual "{PAUSE}" button for toggle pause.

Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

  • Developers

Sorry for asking but you do realize you made 936 posts and are a member around here for 7+ years, so somewhere you missed picking up some basics. ;)

Jos 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

 

Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info
Opt("TrayAutoPause", 0) ;0=no info, 1=debug line info
#include <MsgBoxConstants.au3>
#include <array.au3>
#include <IE.au3>

Global $Paused=0

HotKeySet("p", "_Pause")
HotKeySet("n", "_Continue")
HotKeySet("{ESC}", "Terminate")

OPT("SendKeyDelay",25)

Global $hFile = FileOpen(@DesktopDir & "\email addresses 11-17-2015.txt")
;Global $hFile1 = FileOpen(@DesktopDir & "\Count.txt")
Global $aArray = FileReadToArray($hFile)
Sleep(5000)
;~ _ArrayDisplay($aArray)

Global $Count = 0
While 1
    MouseClick("",909,221);add customer
    MouseMove(691,421)
    Sleep(5000)
    MouseClick("",691,421);email address location
    MouseMove(708,196)
    Sleep(1000)
    Send($aArray[$Count])
    Sleep(500)
    MouseClick("",708,196);save
    MouseMove(691,500)
    Sleep(5000)
    MouseClick("",691,500);Click OK on already exists
    MouseMove(805,206)
    Sleep(3000)
    MouseClick("",805,206);Click Cancel
    MouseMove(909,221)
    Sleep(5000)
;~  Local $PCS = PixelChecksum(662,479,762,510)
;~      If $PCS == 361411749 Then
;~          MouseClick("",715,496)
;~          Sleep(1000)
;~          MouseClick("",778,198)
;~          Sleep(2000)
;~      EndIf

    $Count += 1
WEnd

Func _Pause()
    $Paused = 1
    While $Paused
        Sleep(100)
        ToolTip('Paused', 0, 0)
    WEnd
    ToolTip("")
EndFunc   ;==>TogglePause

Func _Continue()
    $Paused = 0
EndFunc   ;==>TogglePause

Func Terminate()
;    FileClose($hFile1)
    FileClose($hFile)
    Exit 0
EndFunc   ;==>Terminate

 

Regards,
 

Link to comment
Share on other sites

Just chiming in with my usual response....you will NEVER have an accurately nor precise script when you use generic functions like mouseclick, send, mousemove.

Use ControlClick, ControlSetText.

Since this is 'online'...use the _IE functions.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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...