Sign in to follow this  
Followers 0
pezo89

help requested

8 posts in this topic

hi,

2.

i have a rather plaint script made, and it contains a few pixelsearch commands and ect, and i was wondering,

when encounter an error in the search, is there a way to have it go to the top of the script, instead of exit and then run c:\xxx command?

2.:

is there a way i can have a wait on browser load like the _ieload command thingy?

best regards and thanks for replies in advance

Andreas.

Share this post


Link to post
Share on other sites



Nothin?

Share this post


Link to post
Share on other sites

Too vague to answer.

What does "when encounter an error in the search" mean?

What kind of error are you getting?

What happens now when you get it?

What exactly did you want to happen?

:blink:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

hi,

2.

i have a rather plaint script made, and it contains a few pixelsearch commands and ect, and i was wondering,

when encounter an error in the search, is there a way to have it go to the top of the script, instead of exit and then run c:\xxx command?

2.:

is there a way i can have a wait on browser load like the _ieload command thingy?

best regards and thanks for replies in advance

Andreas.

1. the listing in the help file for PixelSearch gives an example of responding to an error with that function...

2. if you're using a browser other than ie, it would probably be helpful to specify which; but you may be able to watch the status bar for "finished" or something


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

1. the listing in the help file for PixelSearch gives an example of responding to an error with that function...

2. if you're using a browser other than ie, it would probably be helpful to specify which; but you may be able to watch the status bar for "finished" or something

well, for Question 1. it is like if @error then (mousemoves, then start all the way to the top of the script)

as it is now, it will does a few mousemoves, ect. and terminate.

then i need to rerun the script to have it start on the top again.

Q2. it is Mozilla Firefox.

the script itself: removed some lines that is not too be seen, replaced them with ??xx??

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
;farge på sperret; 14,208,726,308,0xFFFF00
HotKeySet("{Pause}", "TogglePause")
HotKeySet("{Insert}", "Terminate")



Opt('MustDeclareVars', 1)



 Local $msg, $Button_2,$Input1, $pos1, $i
 Global $Paused





    GUICreate("??xx??") ; will create a dialog box that when displayed is centered
    GUISetState(@SW_SHOW) ; will display an empty dialog box

GUICtrlCreateLabel("FØR DU STARTER. SJEKK FØLGENDE",0,0)
GUICtrlSetBkColor(-1, 0x00ff00)     ; Green
GUICtrlCreateLabel("1: Riktig fane er valgt i Mozilla firefox",0,30)
GUICtrlSetBkColor(-1, 0x00ff00)     ; Green
GUICtrlCreateLabel("2: Riktig Celle i Exel-arket er valgt",0,50)
GUICtrlSetBkColor(-1, 0x00ff00)     ; Green
GUICtrlCreateLabel("3: Du var sist innom den aktuelle TDS'en ",0,70)
GUICtrlSetBkColor(-1, 0x00ff00)     ; Green
GUICtrlCreateLabel("dvs den med ??xx?? ",0,86)
GUICtrlSetBkColor(-1, 0x00ff00)     ; Green
GUICtrlCreateLabel("4: Du har gått inn på første tur i TDS'en ",0,106)
GUICtrlSetBkColor(-1, 0x00ff00)     ; Green
GUICtrlCreateLabel("Dvs den neste turen du skal bekrefte",0,126)
GUICtrlSetBkColor(-1, 0x00ff00)     ; Green
GUICtrlCreateLabel("©Andreas ??xx?? 2010",0,370)
;GUICtrlSetBkColor(-1, 0x00ff00)     ; Green
 $Button_2 = GUICtrlCreateButton("Start programmet", 0,150,150,40)
$i = 1

$pos1 = InputBox ("Antall turer TT", "Legg  inn antall turer her +1")
$pos1 = int($pos1)


     While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop

            Case $msg = $Button_2

               ;koder som fungere
;WinActivate("Microsoft Excel - ??xx?? ","")
;WinActivate("??xx??","")
GUIDelete()


;Kopier referansenummer
while $i < $pos1

ToolTip('Kopier referansenummer',0,0)

WinActivate("??xx??","")
WinWaitActive ("??xx??","")
mouseclick ("Left", 149,90,2)
sleep (150)
send ("^{c}")
send ("^{c}")
sleep (150)
WinActivate("Microsoft Excel - ??xx?? ","")
WinWaitActive("Microsoft Excel - ??xx?? ","")
sleep (150)
send ("^{v}")
sleep (150)

send ("{tab}")
sleep (150)
;kopierer sjåførnummer
ToolTip('kopierer sjåførnummer',0,0)
WinActivate("??xx??","")
WinWaitActive ("??xx??","")
sleep (150)
mouseclick ("Left",629,586,1,15)
sleep (150)
send ("^{c}")
send ("^{c}")
sleep (150)
WinActivate("Microsoft Excel - ??xx?? ","")
WinWaitActive("Microsoft Excel - ??xx?? ","")
sleep (150)
send ("^{v}")
sleep (150)
send ("{tab}")
sleep (150)
;Kopierer TT-Nummer
ToolTip('Kopierer TT-Nummer',0,0)
WinActivate("??xx??","")
WinWaitActive ("??xx??","")
sleep (150)
MouseClickDrag("Left",840,512,787,514,15)
sleep (150)
send ("^{c}")
send ("^{c}")
sleep (150)
WinActivate("Microsoft Excel - ??xx?? ","")
WinWaitActive("Microsoft Excel - ??xx?? ","")
sleep (150)
send ("^{v}")

;Mozilla Firefox fane:
;Kopierer Sjåførnummer
ToolTip('Kopierer Sjåførnummer',0,0)
sleep (150)
send ("{tab}")
sleep (150)
send ("^{c}")
send ("^{c}")
sleep (150)
WinActivate("??xx??")
WinWaitActive("??xx??")
sleep (150)
mouseclick("Left",596,492,2)
sleep (150)
send ("{C}")
sleep (150)
send ("^{v}")
sleep (150)
send ("{tab}")
sleep (150)
;Kopierer TT-Nummer
ToolTip('Kopierer TT-Nummer',0,0)
WinActivate("Microsoft Excel - ??xx?? ","")
WinWaitActive("Microsoft Excel - ??xx?? ","")
sleep (150)
send ("+{tab}")
sleep (150)
send ("^{c}")
send ("^{c}")
sleep (150)
WinActivate("??xx??")
WinWaitActive("??xx??")
MouseClick("left",674,540,2)
sleep (150)
send ("^{v}")
sleep (150)
send ("{Tab}")
sleep (2000)
PixelSearch(562,458,804,568,0xFF0000)
if  Not @error Then
    MsgBox(1,"Error","Ikke Registrert TT-Nummer")
    sleep (50)

WinActivate("Microsoft Excel - ??xx?? ","")
sleep (150)
WinWaitActive("Microsoft Excel - ??xx?? ","")
sleep (150)
    sleep (150)
    send ("Ikke Registrert TT-kortnummer")
    sleep (150)
    send ("{Right}")
    sleep (150)
    send ("{Left}")
    sleep (150)
    mouseclick("Left", 74,42,1)
    sleep (150)
    mouseclick ("Left",1152,109,1)
sleep (150)
mouseclick ("Left", 1286,89,1)
sleep (150)
send ("{Down}")
sleep (150)
send ("{Left}")
sleep (150)
send ("{Left}")
sleep (150)
sleep (150)
WinActivate("??xx??","")
WinWaitActive ("??xx??","")
sleep (150)
MouseClick ("Left", 874,677,1,15)
sleep (150)
mouseclick ("Left",769,472,1,15)
sleep (150)
send ("{Down}")
sleep (150)
send ("{F3}")
sleep (2000)
WinActivate("??xx??")
WinWaitActive("??xx??")
mouseclick ("Left", 462,379,1,15)
sleep (150)

MsgBox(1,"Beklager!","Du må Starte programmet på nytt nå..  beklager at det ikke er en enklere måte å gjøre dette på..  ennå!")
Exit

EndIf
sleep (2000)
ToolTip( " SØKER ETTER RØDE FELTER",800,815)
MouseClick ("Left",605,586,1,15)
sleep (1000)

PixelSearch(14,208,726,308,0xFFFF00)
    if  Not @error Then
    MsgBox(1,"Error","Kortet Er Sperret!")
    sleep (50)

WinActivate("Microsoft Excel - ??xx?? ","")
sleep (150)
WinWaitActive("Microsoft Excel - ??xx?? ","")
sleep (150)
    sleep (150)
    send ("Kortet Er Sperret!")
    sleep (150)
    send ("{Right}")
    sleep (150)
    send ("{Left}")
    sleep (150)
    mouseclick("Left", 74,42,1)
    sleep (150)
    mouseclick ("Left",1152,109,1)
sleep (150)
mouseclick ("Left", 1079,89,1)
sleep (150)
send ("{Down}")
sleep (150)
send ("{Left}")
sleep (150)
send ("{Left}")
sleep (150)
sleep (150)
WinActivate("??xx??","")
WinWaitActive ("??xx??","")
sleep (150)
MouseClick ("Left", 874,677,1,15)
sleep (150)
mouseclick ("Left",769,472,1,15)
sleep (150)
send ("{Down}")
sleep (150)
send ("{F3}")
sleep (2000)
WinActivate("??xx??")
WinWaitActive("??xx??")
mouseclick ("Left", 462,379,1,15)
sleep (150)

MsgBox(1,"Beklager!","Du må Starte programmet på nytt nå..  beklager at det ikke er en enklere måte å gjøre dette på..  ennå!")
Exit
EndIf

mouseclick ("Left", 1061,493,1,15)
sleep (2000)
;Kopierer Trip informasjonen!
ToolTip('Kopierer Tur informasjonen!',0,0)

;1-Ref nummer
ToolTip( " kopierer REFERANSENUMMER",800,815)
WinActivate("??xx??","")
WinWaitActive ("??xx??","")
mouseclick ("Left", 141,95,2)
sleep (150)
send ("^{C}")
send ("^{C}")
sleep (150)
WinActivate("??xx??")
WinWaitActive("??xx??")
sleep (150)
mouseclick ("Left",635,583)
sleep (150)
send ("^{v}")
sleep (150)
send ("{Tab}")


;2 - Start date
ToolTip( " kopierer STARTDATO",800,815)
WinActivate("??xx??","")
WinWaitActive ("??xx??","")
mouseclick ("Left", 149,222,2)
sleep (150)
send ("^{C}")
send ("^{C}")
sleep (150)
WinActivate("??xx??")
WinWaitActive("??xx??")
sleep (150)
send ("^{v}")
sleep (150)
send ("{Tab}")


;3-Start time
ToolTip( " kopierer KOPIERER STARTTID",800,815)
WinActivate("??xx??","")
WinWaitActive ("??xx??","")
mouseclick ("Left", 209,220,2)
sleep (150)
send ("^{C}")
send ("^{C}")
sleep (150)
WinActivate("??xx??")
WinWaitActive("??xx??")
sleep (150)
send ("^{v}")
sleep (150)
send ("{Tab}")

;9 - End  date
ToolTip( " kopierer KOPIERER ENDEDATO",800,815)
WinActivate("??xx??","")
WinWaitActive ("??xx??","")
sleep (150)
mouseclick ("Left", 894,470,1)
sleep (150)
mouseclick ("Left", 894,470,1)
sleep (150)
mouseclick ("Left", 670,221,2)
sleep (150)
send ("^{C}")
send ("^{C}")
sleep (150)
WinActivate("??xx??")
WinWaitActive("??xx??")
sleep (150)
send ("^{v}")
sleep (150)
send ("{Tab}")



;4 - End time
ToolTip( " kopierer SLUTTTID",800,815)
WinActivate("??xx??","")
WinWaitActive ("??xx??","")
mouseclick ("Left", 729,221,2)
sleep (150)
send ("^{C}")
send ("^{C}")
sleep (150)
WinActivate("??xx??")
WinWaitActive("??xx??")
sleep (150)
send ("^{v}")
sleep (150)
send ("{Tab}")

;5 - Fra adresse
ToolTip( " kopierer  FRA ADRESSE",800,815)
WinActivate("??xx??","")
WinWaitActive ("??xx??","")
sleep (150)
mouseclick ("Left",245,298,1)
sleep (150)
send ("^{C}")
send ("^{C}")
sleep (150)
WinActivate("??xx??")
WinWaitActive("??xx??")
sleep (150)
send ("^{v}")
sleep (150)
;Nr:
WinActivate("??xx??","")
WinWaitActive ("??xx??","")
sleep (150)
mouseclick ("Left",456,298,2)
sleep (150)
send ("^{C}")
send ("^{C}")
sleep (150)
WinActivate("??xx??")
WinWaitActive("??xx??")
sleep (150)
send ("{end}")
sleep (150)
send ("{space}")
sleep (150)
send ("^{v}")
sleep (150)
send ("{Tab}")

;6 - til adresse
ToolTip( " kopierer TIL ADRESSE",800,815)
WinActivate("??xx??","")
WinWaitActive ("??xx??","")
sleep (150)
mouseclick ("Left", 283,344,1)
sleep (150)
send ("^{C}")
send ("^{C}")
sleep (150)
WinActivate("??xx??")
WinWaitActive("??xx??")
sleep (150)
send ("^{v}")
sleep (150)
;Nr:
WinActivate("??xx??","")
WinWaitActive ("??xx??","")
sleep (150)
mouseclick ("Left",456,343,2)
sleep (150)
send ("^{C}")
send ("^{C}")
sleep (150)
WinActivate("??xx??")
WinWaitActive("??xx??")
sleep (150)
send ("{end}")
sleep (150)
send ("{space}")
sleep (150)
send ("^{v}")
sleep (150)
send ("{Tab}")

;7 - Avstand på turen
ToolTip( " kopierer ANTALL KM",800,815)
WinActivate("??xx??","")
WinWaitActive ("??xx??","")
sleep (150)
mouseclick ("Left", 896,408,2)
sleep (150)
send ("^{C}")
send ("^{C}")
sleep (150)
WinActivate("??xx??")
WinWaitActive("??xx??")
sleep (150)
send ("^{v}")
sleep (150)
send ("{Tab}")

;8 - Pris for turen
ToolTip( " kopierer PRIS",800,815)
WinActivate("??xx??","")
WinWaitActive ("??xx??","")
sleep (150)
mouseclick ("Left", 125,535,2)
sleep (150)
send ("^{C}")
send ("^{C}")
sleep (150)
WinActivate("??xx??")
WinWaitActive("??xx??")
sleep (150)
send ("^{v}")
sleep (150)
send ("{Tab}")
sleep (500)
send ("^{NUMPADSUB 3}")
sleep (1000)
ToolTip( "Ser etter Fargeendringer",800,815)
PixelSearch(643,368,921,791,0xFF0000)
if  Not @error Then
    MsgBox(1,"Error","Her er det noe feil..  trykk OK, Rett feilen og  press Pauseknappen")
    sleep (50)
    send ("{Pause}")

EndIf

;MsgBox(1, "ferdig", "Trykk Ok og  Pause Knappen om alt stemmer")

sleep (50)
Beep(900, 100)
;send ("{Pause}")
mouseclick ("Left", 660,742,1,15)
sleep (1000)
mouseclick ("Left",758,447,1,15)
sleep (1000)
send ("^{NUMPAD0}")
sleep (2000)
mouseclick("Left", 459,379,1,15)
sleep (1000)

;;
ToolTip("Neste TT-Reg",0, 0)
sleep (150)
WinActivate("??xx??","")
WinWaitActive ("??xx??","")
sleep (150)
MouseClick ("Left", 874,677,1,15)
sleep (150)
mouseclick ("Left",769,472,1,15)
sleep (150)
send ("{Down}")
sleep (150)
send ("{F3}")
sleep (2000)
WinActivate("Microsoft Excel - ??xx?? ","")
WinWaitActive("Microsoft Excel - ??xx?? ","")
sleep (150)
MOUSECLICK ("lEFT", 1152,111,1,15)
sleep (150)
MouseClick("LEFT",1194,92,1,15)
sleep (150)

send ("{Down}")
sleep (150)
send ("{Left}")
sleep (150)
send ("{Left}")
sleep (150)
;ToolTip("Om du ikke er i referanse feltet nå. er det godt mulig -Scroll Lock- er aktivert. Skru denne av. og velg riktig Celle. trykk så på pauseknappen",0,0)
sleep (1000)
Beep(900, 100)
;send ("{Pause}")

sleep (500)
WinActivate("??xx??","")
WinWaitActive ("??xx??","")
;MsgBox(1, "Er dette korrekt tur","om ja, trykk pause")


$i += 1
WEnd
        EndSelect
        WEnd

    ; Run the GUI until the dialog is closed
Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip("PROGRAMMET ER PÅ PAUSE - TRYKK PÅ PAUSEKNAPPEN FOR Å FORSETTE",30,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Share this post


Link to post
Share on other sites

ok, i've just started looking through your code, and just some quick advice that doesn't apply directly to your question... the way that you're doing things creates a LOT of opportunity for error, especially using sends to populate your spreadsheet. there is an excel udf that could help you a lot, or if you just want to use COM to control excel the things you're doing in excel would not be difficult at all. there are a lot of examples for automating tasks in excel on the forum and you would be saving yourself a lot of headaches and troubleshooting in the future to review a couple of them. that said; i'm going to take a look at your code but i'm looking between calls at work so it may take me a while


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

ok, i've just started looking through your code, and just some quick advice that doesn't apply directly to your question... the way that you're doing things creates a LOT of opportunity for error, especially using sends to populate your spreadsheet. there is an excel udf that could help you a lot, or if you just want to use COM to control excel the things you're doing in excel would not be difficult at all. there are a lot of examples for automating tasks in excel on the forum and you would be saving yourself a lot of headaches and troubleshooting in the future to review a couple of them. that said; i'm going to take a look at your code but i'm looking between calls at work so it may take me a while

looking through the code, i think that pixelsearch may not be the best way to do what you're trying to do. i think there's an ff.au3 to help with controlling and getting info from firefox that you may want to look into also. i know that's not the type of answer that you're looking for, but these suggestions will probably lead you to accomplish your goals a little more efficiently with less chance of errors and a lot more readable code for troubleshooting.


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

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