Sign in to follow this  
Followers 0
MasonMill

autoit prevented from continuing

1 post in this topic

I use $h_webpage = ShellExecute($webpage) to open a webpage and then shut it down, after a few times i get a message box that says:

Windows cannot find http://www.mypage.com Make sure you typed the name correctly, and the ntry again. To search for a file, click on start button, and then search."

When this message box pops up, my script does not continue. I have to manually go click on the ok button on that message. Is there a way around this? Any help is appreciated! Thanks!

Here is my code

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.6.1

Author: myName

Script Function:

Template AutoIt script.

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

; Script Start - Add your code below here

#include <GDIPlus.au3>

#include <ScreenCapture.au3>

#include <WinAPI.au3>

#include <array.au3>

#include <Timers.au3>

HotKeySet("{PAUSE}", "TogglePause")

HotKeySet("{END}", "Terminate")

Global $ToolTipX = 2200

Global $ToolTipY = 88

Global $Debug = 1

Global $webpage = "http://www.mywebpage.com/en/"

Global $RelogTimer = 2000

Global $coords[2]

While 1

$h_webpage = ShellExecute($webpage) ; Your page

ToolTip("Reseting...")

Sleep(1000)

For $i = 1 to 4

ToolTip("Searching for images...")

$www_okbutton = _ImageSearch(@ScriptDir & "\www_okbutton.bmp", 1, $coords[0], $coords[1], 20)

$firefox_okbutton = _ImageSearch(@ScriptDir & "\firefox_okbutton.bmp", 1, $coords[0], $coords[1], 20)

$darkblue = PixelSearch(1628,139,1628,139,0x2D57A1,5)

$lightblue = PixelSearch(1641,126,1641,126,0x0181C0,5)

If IsArray($darkblue) Then

ToolTip("Found dark blue")

MouseMove(2343,150,0)

Sleep(500)

ToolTip("maneuvering to username/password fields...")

MouseClick("left")

Sleep(1000)

ToolTip("Entering username/password...")

Send("login")

Send("{TAB}")

Sleep(1000)

Send("password")

Send("{ENTER}")

ToolTip("Waiting 6 seconds to log back log out or exit...")

for $h = 1 to 3

Send("{PGUP}")

sleep(1000)

Next

MouseMove(1820,989,0);logout button

Sleep(1000)

MouseClick("left")

ElseIf IsArray($lightblue) Then ;change this to log out first since dark blue logged you in

ToolTip("Found light blue...")

MouseMove(2300,545,0)

Sleep(500)

MouseClick("left")

ToolTip("Clicking on loging...")

Sleep(1000)

ToolTip("Entering username/password...")

Send("login")

Send("{TAB}")

Sleep(1000)

Send("password")

Send("{ENTER}")

Sleep(1000)

MouseMove(1719,95,0);browser tab

ToolTip("Making sure im on first tab...")

MouseClick("left")

Sleep(2000)

ToolTip("Waiting 6 seconds to log back log out or exit...")

for $h = 1 to 3

Send("{PGUP}")

sleep(1000)

Next

MouseMove(1820,989,0);logout button

Sleep(1000)

MouseClick("left")

ElseIf $www_okbutton Then

ToolTip("Found www_okbutton...")

$www_okbutton_X = $coords[0]

$www_okbutton_Y = $coords[1]

MouseClick("left", $coords[0], $coords[1])

Sleep(1000)

ElseIf $firefox_okbutton Then

ToolTip("Found firefox_okbutton...")

$firefox_okbutton_X = $coords[0]

$firefox_okbutton_Y = $coords[1]

MouseClick("left", $coords[0], $coords[1])

Sleep(1000)

EndIf

ToolTip("waiting to relog...")

Sleep(5000)

;~ $begin = TimerInit()

;~ $timer = 0

;~ while $timer < $RelogTimer

;~ $timer = TimerDiff($begin)

;~ ToolTip("" & round($RelogTimer/1000 - $timer/1000) & " seconds until relogin...")

;~ Sleep(100)

;~ WEnd

Next

MouseMove(2790,12,0);exit button

Sleep(1000)

MouseClick("left")

WEnd

Func _ImageSearch($findImage,$resultPosition,ByRef $x, ByRef $y,$tolerance)

return _ImageSearchArea($findImage,$resultPosition,0,0,@DesktopWidth,@DesktopHeight,$x,$y,$tolerance)

EndFunc

Func _ImageSearchArea($findImage,$resultPosition,$x1,$y1,$right,$bottom,ByRef $x, ByRef $y, $tolerance)

;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom)

if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage

$result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage)

; If error exit

if $result[0]="0" then return 0

; Otherwise get the x,y locating of the match and the size of the image to

; compute the centre of search

$array = StringSplit($result[0],"|")

$x=Int(Number($array[2]))

$y=Int(Number($array[3]))

if $resultPosition=1 then

$x=$x + Int(Number($array[4])/2)

$y=$y + Int(Number($array[5])/2)

endif

return 1

EndFunc

Func Terminate()

exit(0)

EndFunc

Func TogglePause()

$Paused = Not $Paused

While $Paused

Sleep(100)

ToolTip('Script is "Paused"', 0, 0)

WEnd

ToolTip("")

EndFunc ;==>TogglePause

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
Sign in to follow this  
Followers 0