computergroove

While loop quits

12 posts in this topic

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

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Where will I see the output for this? Im running with F5 from Scite.


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

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

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 


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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,
 

Share this post


Link to post
Share on other sites

The problem is that the togglepause is initiated when the letter p is sent and there are p's in some email addresses.


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

Share this post


Link to post
Share on other sites

Where will I see the output for this? Im running with F5 from SciTe

Considering your tenure this is what is alarming.  Hopefully hust a misunderstanding 


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

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.

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