#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.6.0 Author: Yannick Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- #include ; Under Vista the Windows API "SetSystemTime" may be rejected due to system security ;NOTE: AMOR parameters ; Average tilting time : 7 minutes ; ... ;Coortinates of AMOR's onglets (if upleft corner is [0;0]) ;Initialization Global $detailuser[2] = [425, 326] Global $adjustlight[2] = [425, 368] Global $OkgotoAmor[2] = [497, 465] Global $Okmanuelmode[2] = [878, 173] ;Title: Settings singlemode Global $Loadcustom[2] = [90, 518] Global $entermanuel[2] = [93, 558] ;Field zone Global $fieldinit[2] = [277, 172] Global $fieldlast[2] = [243, 172] ;Magnification zone Global $zoominit[2] = [677, 172] Global $zoomlast[2] = [643, 172] ;Autocenter Global $autocenter[2] = [906, 325] ;Autofocus Global $autofocus[2] = [906, 373] ;Autotilt Global $autotilt[2] = [906, 419] ;Automagnificate Global $automag[2] = [906, 462] ;Autorotate Global $autorotate[2] = [906, 506] ;Capture Global $autocapture[2] = [906, 691] ;Exit Global $autoExit[2] = [906, 743] ;Saving dialog parameter Global $Saveunder[2] = [405, 65] Global $save[2] = [458, 108] ;Global Variables for functions Global $Time Global $Hour[9] Global $Minutes[9] Global $Second[9] Global $Heure Global $Dim Global $Pas ;handle variables Global $Handle_AMOR Global $Handle_Pad Global $Handle_rep Global $handle_Error ;Other variables Dim $check Dim $Exitchoice Dim $file, $answer Dim $Sample Dim $send Dim $Slide Dim $Specimen Dim $timeout Dim $titlepad = "Dokument - WordPad" Dim $titlepad_name Dim $titletcheck Dim $path Dim $case ;set the emergency and soft exits HotKeySet("!^q", "MyExit") HotKeySet("!^s", "softexit") ; Prompt the user to run the script - use a Yes/cancel prompt $answer = MsgBox(1, "AMDS", "You are about to run Amor Manual Driving Script (AMDS)" & @CRLF & "This AutoIt made script will allow you to let Amor work alone, in manual mode." & @CRLF & "" & @CRLF & "" & @CRLF & "Version 1.4 By Yannick Mary and Michael Knappertsbusch") ; If "No" was clicked (7) then exit the script If $answer = 2 Then MsgBox(0, "AMDS", "You are about to leave Amor Manual Driving, have a nice day") Exit EndIf ; information prompts MsgBox(0, "AMDS", "IMPORTANT -------------------------------------------------- IMPORTANT" & @CRLF & "" & @CRLF & "" & @CRLF & "To interrupt AMDS while it is running, press simultaneously Alt+Ctrl+Q keys") MsgBox(0, "AMDS", "IMPORTANT -------------------------------------------------- IMPORTANT" & @CRLF & "" & @CRLF & "" & @CRLF & "The list of files file would be located on the desktop ") $Exitchoice = MsgBox(4, "AMDS", "Do you want to shut AMOR at the end of the run ?") $Sample = InputBox("AMDS", "Please enter sample code" & @CRLF & "" & @CRLF & "" & @CRLF & "The sample code will be written in picture names. Example:" & @CRLF & "503A202105K") $Slide = InputBox("AMDS", "Please enter the Slide number") $path = InputBox("AMDS", "Please enter the path to the Amor Slide Calibration file" & @CRLF & "NB: The full path is written on the properties of the file") MsgBox(0, "AMDS", "NB: The pictures will be saved in folder where the calibration file is located") ; let the user the possibility to escape the script $answer = MsgBox(1, "AMDS", "Be sure Amor is open, than do the calibration and enter the manual mode") If $answer = 2 Then MsgBox(0, "AMDS", "You are about to leave Amor Manual Driving, have a nice day") Exit EndIf ;Creation du GUI pour la selection des specimens. Oui c'est long... GUICreate("AMDS - Specimen choice", 675, 300) ;Ligne 1 $specimen1 = GUICtrlCreateCheckbox("Spe 1", 5, 5, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen2 = GUICtrlCreateCheckbox("Spe 2", 5, 25, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen3 = GUICtrlCreateCheckbox("Spe 3", 5, 45, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen4 = GUICtrlCreateCheckbox("Spe 4", 5, 65, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen5 = GUICtrlCreateCheckbox("Spe 5", 5, 85, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen6 = GUICtrlCreateCheckbox("Spe 6", 5, 105, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen7 = GUICtrlCreateCheckbox("Spe 7", 5, 125, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen8 = GUICtrlCreateCheckbox("Spe 8", 5, 145, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen9 = GUICtrlCreateCheckbox("Spec 9", 5, 165, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen10 = GUICtrlCreateCheckbox("Spec 10", 5, 185, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen11 = GUICtrlCreateCheckbox("Spe 11", 5, 205, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen12 = GUICtrlCreateCheckbox("Spe 12", 5, 225, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) ;Ligne 2 $specimen13 = GUICtrlCreateCheckbox("Spe 13", 135, 5, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen14 = GUICtrlCreateCheckbox("Spe 14", 135, 25, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen15 = GUICtrlCreateCheckbox("Spe 15", 135, 45, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen16 = GUICtrlCreateCheckbox("Spe 16", 135, 65, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen17 = GUICtrlCreateCheckbox("Spe 17", 135, 85, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen18 = GUICtrlCreateCheckbox("Spe 18", 135, 105, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen19 = GUICtrlCreateCheckbox("Spe 19", 135, 125, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen20 = GUICtrlCreateCheckbox("Spe 20", 135, 145, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen21 = GUICtrlCreateCheckbox("Spe 21", 135, 165, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen22 = GUICtrlCreateCheckbox("Spe 22", 135, 185, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen23 = GUICtrlCreateCheckbox("Spe 23", 135, 205, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen24 = GUICtrlCreateCheckbox("Spec 24", 135, 225, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) ;Ligne 3 $specimen25 = GUICtrlCreateCheckbox("Spe 25", 265, 5, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen26 = GUICtrlCreateCheckbox("Spe 26", 265, 25, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen27 = GUICtrlCreateCheckbox("Spe 27", 265, 45, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen28 = GUICtrlCreateCheckbox("Spe 28", 265, 65, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen29 = GUICtrlCreateCheckbox("Spe 29", 265, 85, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen30 = GUICtrlCreateCheckbox("Spe 30", 265, 105, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen31 = GUICtrlCreateCheckbox("Spe 31", 265, 125, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen32 = GUICtrlCreateCheckbox("Spe 32", 265, 145, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen33 = GUICtrlCreateCheckbox("Spe 33", 265, 165, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen34 = GUICtrlCreateCheckbox("Spe 34", 265, 185, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen35 = GUICtrlCreateCheckbox("Spe 35", 265, 205, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen36 = GUICtrlCreateCheckbox("Spe 36", 265, 225, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) ;Ligne 4 $specimen37 = GUICtrlCreateCheckbox("Spe 37", 395, 5, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen38 = GUICtrlCreateCheckbox("Spe 38", 395, 25, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen39 = GUICtrlCreateCheckbox("Spe 39", 395, 45, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen40 = GUICtrlCreateCheckbox("Spe 40", 395, 65, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen41 = GUICtrlCreateCheckbox("Spe 41", 395, 85, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen42 = GUICtrlCreateCheckbox("Spe 42", 395, 105, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen43 = GUICtrlCreateCheckbox("Spe 43", 395, 125, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen44 = GUICtrlCreateCheckbox("Spe 44", 395, 145, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen45 = GUICtrlCreateCheckbox("Spe 45", 395, 165, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen46 = GUICtrlCreateCheckbox("Spe 46", 395, 185, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen47 = GUICtrlCreateCheckbox("Spe 47", 395, 205, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen48 = GUICtrlCreateCheckbox("Spe 48", 395, 225, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) ;Ligne 5 $specimen49 = GUICtrlCreateCheckbox("Spe 49", 525, 5, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen50 = GUICtrlCreateCheckbox("Spe 50", 525, 25, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen51 = GUICtrlCreateCheckbox("Spe 51", 525, 45, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen52 = GUICtrlCreateCheckbox("Spe 52", 525, 65, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen53 = GUICtrlCreateCheckbox("Spe 53", 525, 85, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen54 = GUICtrlCreateCheckbox("Spe 54", 525, 105, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen55 = GUICtrlCreateCheckbox("Spe 55", 525, 125, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen56 = GUICtrlCreateCheckbox("Spe 56", 525, 145, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen57 = GUICtrlCreateCheckbox("Spe 57", 525, 165, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen58 = GUICtrlCreateCheckbox("Spe 58", 525, 185, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen59 = GUICtrlCreateCheckbox("Spe 59", 525, 205, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) $specimen60 = GUICtrlCreateCheckbox("Spe 60", 525, 225, 80, 17) GUICtrlSetState(-1, $GUI_CHECKED) ;Fin de creation du Gui $verif = GUICtrlCreateButton("RUN AMDS", 250, 265, 80, 30) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $verif ExitLoop EndSelect WEnd GUISetState(@SW_HIDE) Sleep(2000) ; Open wordpad ! WORDPAD GERMAN ONLY ; Attention : l'ordinateur sur lequel doit tourner ce programme est en allemand. D'ou les references bizarres... Run("C:\Programme\Windows NT\Zubehör\wordpad.exe") WinWaitActive($titlepad) $Handle_Pad = WinGetHandle($titlepad) WinMove("Dokument - WordPad", "", 0, 0) Sleep(100) Send("^s") $titlepad_name = "List_of_files" ;verifie la presence d un fichier list_of_files:txt $titletcheck = FileExists("C:\Dokumente und Einstellungen\snmmic\Desktop\List_of_files.txt") If $titletcheck = 1 Then MsgBox(0, "AMDS", "The List_of_files file already exists. Please remove it and restart the Script") Exit EndIf ;saving the file Send($titlepad_name) Send("{ENTER}") Sleep(150) Send("{ENTER}") Sleep(150) ;moving the position of the wordpad prompt to perform further manipulations WinMove($Handle_Pad, "", 0, 0) Sleep(150) ;and good night word pad WinMinimizeAll() Sleep(250) ;creating the report file Run("C:\Programme\Windows NT\Zubehör\wordpad.exe") WinWaitActive($titlepad) $Handle_rep = WinGetHandle($titlepad) WinMove($titlepad, "", 0, 0) Sleep(100) Send("^s") ;saving the file $titlepad_name = "Report_run" Send($titlepad_name) Send("{ENTER}") Sleep(150) Send("{ENTER}") Sleep(150) Call("Time") Send($Heure) $send = " Début du Run" Send($send) Send("{ENTER}") Send("^s") Sleep(1000) Send("{ENTER}") Sleep(1000) Send("{ENTER}") Sleep(1000) ;minimizing again WinMinimizeAll() Sleep(250) ;AMOR Phase. AMOR WinActivate("AMOR") $Handle_AMOR = WinGetHandle("AMOR") Sleep(1500) ;Focus on AMOR, search for any "ERROR" prompt AdlibRegister("Errors") ;--------------------------------main loop for picturing and orientation---------------------------------- ;NB: les boucles Do Until pas = 0 sont utilisés pour détecter les erreurs eventuelles. Si une erreur survient, le $pas sera modifié forcant le script a refaire la boucle ;jusqu'a ce que ça passe. La presence d'une fenetre d'erreur modifie la valeur de $Pas C'est sale, mais j'ai pas trouver mieux. ;NB2: AMOR est un microscope robot. D'ou les focus, magnificate, etc. Cf description sur le forum. WinMove($Handle_AMOR, "", 0, 0) $Specimen = 0 For $i = $specimen1 To $specimen60 $Specimen = $Specimen + 1 If GUICtrlRead($i) = $GUI_CHECKED Then WinActivate($Handle_rep) WinWaitActive($Handle_rep) Call("Time") Send($Heure & " ") $send = "Specimen n°" & $Specimen & "____________________________________________________________________________ " Send($send) Sleep(1000) Send("^s") Sleep(1000) Send("{ENTER}") Sleep(1000) Send("{ENTER}") Sleep(1000) WinSetState($Handle_rep, "", @SW_MINIMIZE) ;Give focus to Amor Do $Pas = 0 WinActivate($Handle_AMOR) Sleep(1000) Until $Pas = 0 ;Specimen Selection Do $Pas = 0 WinActivate($Handle_AMOR) Sleep(1500) MouseClickDrag("left", $fieldinit[0], $fieldinit[1], $fieldlast[0], $fieldlast[1], 1) Sleep(1000) Send($Specimen) Sleep(1000) Send("{ENTER}") Sleep(25000) Until $Pas = 0 ;Autocenter (just in case) Do $Pas = 0 WinActivate($Handle_AMOR) Sleep(1500) MouseClick("left", $autocenter[0], $autocenter[1]) Sleep(2000) MouseClick("left", $autocenter[0], $autocenter[1]) Sleep(2000) Until $Pas = 0 ;Automagnificate Do $Pas = 0 WinActivate($Handle_AMOR) Sleep(1500) MouseClick("left", $automag[0], $automag[1]) Sleep(1000) $timeout = WinWaitClose("Automagnificate", "", 600) ;Include reboot Amor Statement If $timeout = 0 Then WinActivate($Handle_rep) WinWaitActive($Handle_rep) Call("Time") Send($Heure & " ") $send = $Specimen & " Automagnificate timeout. Amor rebooted" Send($send) Sleep(1000) Send("^s") Sleep(1000) Send("{ENTER}") Sleep(1000) Send("{ENTER}") Sleep(1000) WinSetState($Handle_rep, "", @SW_MINIMIZE) Sleep(500) $case = 1 Call("Reload") EndIf Sleep(500) Until $Pas = 0 ;Autotilt Do $Pas = 0 Sleep(500) WinActivate($Handle_AMOR) Sleep(1500) MouseClick("left",$autotilt[0],$autotilt[1]) Sleep(1000) $timeout=WinWaitClose("Autotilt","",1800) ;Include reboot Amor Statement if $timeout= 0 then Winactivate($handle_rep) WinWaitActive($handle_rep) Call("Time") send($heure&" ") $send=$specimen&" Autotilt timeout. Amor rebooted" send($send) sleep(1000) Send("^s") sleep(1000) send("{ENTER}") sleep(1000) send("{ENTER}") sleep(1000) WinSetState($handle_rep, "", @SW_MINIMIZE) sleep(500) $case=2 call("Reload") EndIf Sleep(2000) Until $Pas = 0 ;Automagnificate again Do $Pas = 0 WinActivate($Handle_AMOR) Sleep(1500) MouseClick("left", $automag[0], $automag[1]) Sleep(1000) $timeout = WinWaitClose("Automagnificate", "", 600) ;Include reboot Amor Statement If $timeout = 0 Then WinActivate($Handle_rep) WinWaitActive($Handle_rep) Call("Time") Send($Heure & " ") $send = $Specimen & " Automagnificate timeout. Amor rebooted" Send($send) Sleep(1000) Send("^s") Sleep(1000) Send("{ENTER}") Sleep(1000) Send("{ENTER}") Sleep(1000) WinSetState($Handle_rep, "", @SW_MINIMIZE) Sleep(500) $case = 3 Call("Reload") EndIf Sleep(500) Until $Pas = 0 ;Autocenter again Do $Pas = 0 WinActivate($Handle_AMOR) Sleep(1500) MouseClick("left", $autocenter[0], $autocenter[1]) Sleep(2000) MouseClick("left", $autocenter[0], $autocenter[1]) Sleep(2000) Until $Pas = 0 ;Autofocus again Do $Pas = 0 WinActivate($Handle_AMOR) Sleep(1500) MouseClick("left", $autofocus[0], $autofocus[1]) Sleep(1000) $timeout = WinWaitClose("Autofocus", "", 600) If $timeout = 0 Then WinActivate($Handle_rep) WinWaitActive($Handle_rep) Call("Time") Send($Heure & " ") $send = $Specimen & " Autofocus timeout. Amor rebooted" Send($send) Sleep(1000) Send("^s") Sleep(1000) Send("{ENTER}") Sleep(1000) Send("{ENTER}") Sleep(1000) WinSetState($Handle_rep, "", @SW_MINIMIZE) Sleep(500) $case = 4 Call("Reload") EndIf Sleep(500) Until $Pas = 0 ;Rotating Do $Pas = 0 WinActivate($Handle_AMOR) Sleep(1500) Sleep(500) MouseClick("left", $autorotate[0], $autorotate[1]) Sleep(2500) Until $Pas = 0 ;Capture statements Do $Pas = 0 WinActivate($Handle_AMOR) Sleep(1500) MouseClick("left", $autocapture[0], $autocapture[1]) WinWaitActive("Save...") WinMove("Save...", "", 0, 0) Sleep(1000) MouseClick("left", $Saveunder[0], $Saveunder[1]) WinWaitActive("Datei speichern unter") Sleep(1000) Send($Sample) Sleep(100) If $Specimen < 10 Then Send("0") EndIf Send($Specimen) Sleep(100) Send($Slide) Sleep(100) If $check = 1 Then $send = "_rollerror" Send($send) $check = 0 EndIf Send("{ENTER}") Sleep(1000) WinActivate("Save...") Sleep(1000) MouseClick("left", $save[0], $save[1]) Sleep(2000) WinActivate("AMOR") Sleep(1500) Until $Pas = 0 ;writing report WinActivate($Handle_rep) WinWaitActive($Handle_rep) Call("Time") Send($Heure & " ") Send($Specimen) $send = "------ Specimen finished" Send($send) Send("^s") Sleep(1000) Send("{ENTER}") Sleep(1000) Send("{ENTER}") Sleep(1000) Send("{ENTER}") Sleep(1000) WinSetState($Handle_rep, "", @SW_MINIMIZE) ;Writing the Magnification in the "list of file" file WinActivate($Handle_AMOR) MouseClickDrag("left", $zoominit[0], $zoominit[1], $zoomlast[0], $zoomlast[1]) Send("^c") Sleep(500) WinActivate($Handle_Pad) Sleep(1500) If $Specimen < 10 Then Send("0") EndIf Send($Specimen) Send($Slide) Send("r") Send(",") Send("^v") Send("{ENTER}") Send("^s") Sleep(1000) Send("{ENTER}") Sleep(1000) EndIf Next WinMinimizeAll() Sleep(1000) WinActivate($Handle_Pad) Send("^s") Sleep(500) Send("{ENTER}") Sleep(1000) Send("{ENTER}") Sleep(1000) Send("{ENTER}") Sleep(1000) ;writing report WinActivate($Handle_rep) WinWaitActive($Handle_rep) Call("Time") Send($Heure & " ") Send($Specimen) $send = "------ RUN finished ---------------------------------------" Send($send) Send("^s") Sleep(1000) Send("{ENTER}") Sleep(1000) Send("{ENTER}") Sleep(1000) Send("{ENTER}") Sleep(1000) If $Exitchoice = 6 Then Call("softexit") EndIf While 1 Sleep(500) MsgBox(0, "AMDS", "Job finished !") WEnd ;Error detection function Func Errors() $Dim = WinExists("[W:338;H:324]", "") If $Dim = 1 Then $handle_Error = WinGetHandle("[W:338;H:324]", "") WinMinimizeAll() Sleep(500) WinActivate($Handle_rep) WinWaitActive($Handle_rep) Call("Time") Send($Heure & " ") Send($Specimen) $send = "-----------Imaq Error-----------" Send($send) Send("^s") Sleep(1000) Send("{ENTER}") Sleep(1000) Send("{ENTER}") Sleep(1000) WinSetState($Handle_rep, "", @SW_MINIMIZE) Sleep(500) WinActivate($handle_Error) Send("{ENTER}") Send("{ENTER}") WinActivate($Handle_AMOR) $Pas = 10 EndIf $Dim = WinExists("[W:670;H:162]", "") If $Dim = 1 Then $handle_Error = WinGetHandle("[W:338;H:324]", "") WinMinimizeAll() Sleep(500) WinActivate($Handle_rep) WinWaitActive($Handle_rep) Call("Time") Send($Heure & " ") Send($Specimen) $send = "-----------ROLL Error-----------" Send($send) Send("^s") Sleep(1000) Send("{ENTER}") Sleep(1000) Send("{ENTER}") Sleep(1000) WinSetState($Handle_rep, "", @SW_MINIMIZE) Sleep(500) WinActivate($handle_Error) Send("{ENTER}") Send("{ENTER}") WinActivate($Handle_AMOR) $check = 1 EndIf EndFunc ;==>Errors ;function reload ;Reload Amor in case of failure Func Reload() Sleep(500) ProcessClose("amor3.10.exe") Sleep(1500) WinActivate($Handle_rep) WinWaitActive($Handle_rep) Call("Time") Send($Heure & " ") Send($Specimen) $send = "-----------AMOR RELOADED-----------" Send($send) Send("^s") Sleep(1000) Send("{ENTER}") Sleep(1000) Send("{ENTER}") Sleep(1000) WinSetState($Handle_rep, "", @SW_MINIMIZE) Sleep(3500) Run("C:\Programme\AMOR3.10\amor3.10.exe", "", @SW_MAXIMIZE) WinWaitActive("AMOR") Sleep(500) WinActivate("AMOR") Sleep(1500) $Handle_AMOR = WinGetHandle("AMOR") Sleep(1500) WinMove("AMOR", "", 0, 0) Sleep(500) MouseClick("left", $detailuser[0], $detailuser[1]) Sleep(1500) MouseClick("left", $adjustlight[0], $adjustlight[1]) Sleep(1500) MouseClick("left", $OkgotoAmor[0], $OkgotoAmor[1]) Sleep(3500) Send("{ENTER}") Sleep(120000) WinActivate("AMOR") Sleep(500) WinMove("AMOR", "", 0, 0) Sleep(1000) MouseClick("left", $Okmanuelmode[0], $Okmanuelmode[1]) Sleep(2000) WinMove("Settings singlemode", "", 0, 0) Sleep(1500) MouseClick("left", $Loadcustom[0], $Loadcustom[1]) Sleep(1500) Send($path) Sleep(1000) Send("{ENTER}") Sleep(1500) Send("{ENTER}") Sleep(1500) MouseClick("left", $entermanuel[0], $entermanuel[1]) Sleep(15000) WinActivate("AMOR") Sleep(500) WinMove("AMOR", "", 0, 0) ; first Automagnification failure If $case >= 1 Then ;Specimen Selection Do $Pas = 0 WinActivate($Handle_AMOR) Sleep(1500) MouseClickDrag("left", $fieldinit[0], $fieldinit[1], $fieldlast[0], $fieldlast[1], 1) Sleep(1000) Send($Specimen) Sleep(1000) Send("{ENTER}") Sleep(25000) Until $Pas = 0 ;Autocenter (just in case) Do $Pas = 0 WinActivate($Handle_AMOR) Sleep(1500) MouseClick("left", $autocenter[0], $autocenter[1]) Sleep(2000) MouseClick("left", $autocenter[0], $autocenter[1]) Sleep(2000) Until $Pas = 0 ;Automagnificate Do $Pas = 0 WinActivate($Handle_AMOR) Sleep(1500) MouseClick("left", $automag[0], $automag[1]) Sleep(1000) $timeout = WinWaitClose("Automagnificate", "", 2200) ;Include reboot Amor Statement If $timeout = 0 Then WinActivate($Handle_rep) WinWaitActive($Handle_rep) Call("Time") Send($Heure & " ") $send = $Specimen & " Automagnificate timeout. Amor rebooted" Send($send) Sleep(1000) Send("^s") Sleep(1000) Send("{ENTER}") Sleep(1000) Send("{ENTER}") Sleep(1000) WinSetState($Handle_rep, "", @SW_MINIMIZE) Sleep(500) $case = 1 Call("Reload") EndIf Sleep(500) Until $Pas = 0 EndIf ; Autotilt Failure If $case >= 2 Then ;Autotilt Do $Pas = 0 Sleep(500) WinActivate($Handle_AMOR) Sleep(1500) MouseClick("left", $autotilt[0], $autotilt[1]) Sleep(1000) $timeout = WinWaitClose("Autotilt", "", 3200) ;Include reboot Amor Statement If $timeout = 0 Then WinActivate($Handle_rep) WinWaitActive($Handle_rep) Call("Time") Send($Heure & " ") $send = $Specimen & " Autotilt timeout. Amor rebooted" Send($send) Sleep(1000) Send("^s") Sleep(1000) Send("{ENTER}") Sleep(1000) Send("{ENTER}") Sleep(1000) WinSetState($Handle_rep, "", @SW_MINIMIZE) Sleep(500) $case = 2 Call("Reload") EndIf Sleep(2000) Until $Pas = 0 EndIf ; Second Automagnification failure If $case >= 3 Then ;Automagnificate again Do $Pas = 0 WinActivate($Handle_AMOR) Sleep(1500) MouseClick("left", $automag[0], $automag[1]) Sleep(1000) $timeout = WinWaitClose("Automagnificate", "", 2200) ;Include reboot Amor Statement If $timeout = 0 Then WinActivate($Handle_rep) WinWaitActive($Handle_rep) Call("Time") Send($Heure & " ") $send = $Specimen & " Automagnificate timeout. Amor rebooted" Send($send) Sleep(1000) Send("^s") Sleep(1000) Send("{ENTER}") Sleep(1000) Send("{ENTER}") Sleep(1000) WinSetState($Handle_rep, "", @SW_MINIMIZE) Sleep(500) $case = 3 Call("Reload") EndIf Sleep(500) Until $Pas = 0 EndIf ;Autofocus failure If $case >= 4 Then ;Autofocus again Do $Pas = 0 WinActivate($Handle_AMOR) Sleep(1500) MouseClick("left", $autofocus[0], $autofocus[1]) Sleep(1000) $timeout = WinWaitClose("Autofocus", "", 1800) If $timeout = 0 Then WinActivate($Handle_rep) WinWaitActive($Handle_rep) Call("Time") Send($Heure & " ") $send = $Specimen & " Autofocus timeout. Amor rebooted" Send($send) Sleep(1000) Send("^s") Sleep(1000) Send("{ENTER}") Sleep(1000) Send("{ENTER}") Sleep(1000) WinSetState($Handle_rep, "", @SW_MINIMIZE) Sleep(500) $case = 4 Call("Reload") EndIf Sleep(500) Until $Pas = 0 EndIf $case = 0 EndFunc ;function to get the time from the system, usefull to write the report file Func Time() $Hour = @HOUR $Minutes = @MIN $Second = @SEC $Heure = $Hour & ":" & $Minutes & ":" & $Second EndFunc ;Function to interrumpt the Script Func MyExit() Exit EndFunc ;Function to close AMOR. Func softexit() Sleep(20000) WinActivate($Handle_Pad) Send("^s") Sleep(1500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(500) WinActivate($Handle_AMOR) WinActivate($Handle_AMOR) WinWaitClose("Autotilt") WinWaitClose("Automagnificate") Sleep(500) MouseClick("left", $autoExit[0], $autoExit[1]) Sleep(9000) Send("{ENTER}") Sleep(20000) $Handle_AMOR = WinGetHandle("AMOR") Sleep(1500) WinMove("AMOR", "", 0, 0) Sleep(500) MouseClick("left", 883, 615) Sleep(2000) Send("{ENTER}") Sleep(8000) Send("{ENTER}") Sleep(60000) $Dim = 0 $Dim = WinExists("AMOR") Select case $Dim =1 WinActivate($Handle_rep) $send = "AMOR CLOSING PROBLEME" Send($send) Send("^s") Sleep(1000) Send("{ENTER}") Sleep(1000) Send("{ENTER}") Case $Dim = 0 WinActivate($Handle_rep) $send = "AMOR CLOSING OK" Send($send) Send("^s") Sleep(1000) Send("{ENTER}") Sleep(1000) Send("{ENTER}") Sleep(1000) EndSelect sleep(1500) WinActivate($Handle_rep) sleep(1500) send("!{F4}") sleep(1500) send("{enter}") sleep(1500) send("{enter}") WinActivate($Handle_Pad) sleep(1500) send("!{F4}") sleep(1500) send("{enter}") sleep(1500) send("{enter}") sleep(50000) Shutdown(9) Exit EndFunc