Jump to content

Can I get a little help with this.


magace
 Share

Recommended Posts

Ok im tryin to work on some Logging for a little script I wrote. I Found some input on how to read my Log file here:

So far everything is logging to the txt file just fine but when it trys to read the log I get this:

Line 691 .....

_FileReadToArray($Log, $s_swportlist)

^error

Error unknown function name.

I have been messing around with it quite a bit and cant seem to figure out why its not working. :( Any help would be great thanks!

Here is the function that is messing up!

Func ReadPOF()
If $ShowLog = True Then
$Log = FileOpen($SaveLogsPath & "log.txt", 1)
Dim $v_sw_down = 0
Dim $v_sw_up = 0
Dim $s_swportlist
_FileReadToArray($Log, $s_swportlist)

;_ArrayDisplay($s_swportlist, "Switch Ports")

; Reads the switch port status
For $x = 1 To UBound($s_swportlist) - 1
If StringInStr($s_swportlist[$x], "Pass") Then
$v_sw_down = ($v_sw_down + 1)
EndIf
If StringInStr($s_swportlist[$x], "Fail") Then
$v_sw_up = ($v_sw_up + 1)
EndIf
Next
ToolTip("Passes: " & $v_sw_down & "Fails: " & $v_sw_up & ".",616,33)
FileClose($Log)
EndIf
EndFunc

Here is the whole script its kinda ugly but works minus the readpof function!!

HotKeySet("{END}", "Terminate")
HotKeySet("{PRINTSCREEN}", "TogglePass")
HotKeySet("{DELETE}", "ToggleFail")
Global $ShowLog = True
Global $SaveLogsPath = "C:\Users\Tester\Desktop\New folder (2)\logs\"

#include <ImageSearch.au3>
#include <GDIPlus.au3>


Global $LogList
$fileA = @ScriptDir & "\POF.png" ;pass or fail
$fileA2 = @ScriptDir & "\POF2.png" ;pass or fail2
$fileB = @ScriptDir & "\PTN.png" ;part number
$fileC = @ScriptDir & "\SUB.png" ;SUMBIT BOX
$fileD = @ScriptDir & "\PGL.png" ;PAGE LOADED
$fileE = @ScriptDir & "\SUB2.png" ;SUBMIT ITEM
$fileF = @ScriptDir & "\DAT.png" ;DATA BOX FAIL REASON OR PASS REASON
$fileG = @ScriptDir & "\DAT2.png" ;DATA BOX FAIL REASON OR PASS REASON



While 1

While 1

$go3 = 1
While $go3 = 1
$coord = PixelSearch(22, 90, 24, 92, 0x4E5869, 10)
If Not @error Then
$go3 = 1
; ToolTip("PRINT SCREEN=PASS,DELETE=FAIL,HOME=LOGIN",616,33)
ReadPOF()
Else
$go3 = 0
tooltip("",Random(513,1583),Random(74,147))
EndIf
WEnd

sleep(500)
WEnd

WEnd


func TogglePass()
Local $answer = InputBox("Question", "What part number?", "....", "", _
- 1, -1, 0, 0)
Local $answer2 = InputBox("Question", "How many should we print?", "....", "", _
- 1, -1, 0, 0)
Global $DATA = InputBox("Optional", "Vendor and Date?", "", "", _
- 1, -1, 0, 0)

SEND("{HOME}")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$go1 = 1
while $go1 = 1
_GDIPlus_Startup()
$hImageA =_GDIPlus_ImageLoadFromFile($fileB) ;this is the PART NUMBER BOX
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)
$x = 0
$y = 0
$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0) ;Zero will search against your active screen
If $result > 0 Then
ToolTip("WE FOUND PART NUMBER BOX",0,0)
MouseMove($x, $y)
$go1 = 0
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
Else
ToolTip("CANT FIND PART NUMBER BOX",0,0)
SLEEP(500)
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
EndIf
WEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MOUSECLICK("LEFT")
send($answer) ;sends first input box
sleep(800)
send("{ENTER}")
sleep(1000)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

$go2 = 1
while $go2 = 1
_GDIPlus_Startup()
$hImageA =_GDIPlus_ImageLoadFromFile($fileC) ;this is the SUBMIT BOX
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)
$x = 0
$y = 0
$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0) ;Zero will search against your active screen
If $result > 0 Then
ToolTip("FOUND THE SUBMIT BOX",0,0)
MouseMove($x, $y)
$go2 = 0
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
Else
ToolTip("CANT FIND SUBMIT BOX",0,0)
SLEEP(500)
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
EndIf
sleep(1000)
mouseclick("left") ;clicks it
sleep(6000)
WEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

$go = 1
while $go = 1

_GDIPlus_Startup()
$hImageA =_GDIPlus_ImageLoadFromFile($fileD) ;this is the PAGE LOADED
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)
$x = 0
$y = 0
$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0) ;Zero will search against your active screen
If $result > 0 Then
ToolTip("PAGE IS LOADED",0,0)
$go = 0
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
Else
ToolTip("WAITING FOR PAGE TO LOAD",0,0)
SLEEP(1000)
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
EndIf
WEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



$go3 = 1
while $go3 = 1
_GDIPlus_Startup()
$hImageA =_GDIPlus_ImageLoadFromFile($fileA) ;this is the PASS OR FAIL
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)
$x = 0
$y = 0
$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0) ;Zero will search against your active screen
If $result > 0 Then
ToolTip("FOUND PASS/FAIL",0,0)
$go3 = 0
MouseMove($x, $y)
MOUSECLICK("LEFT")
SLEEP(500)
send("P")
sleep(500)
send("{ENTER}")
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
Else
ToolTip("CANT FIND PASS/FAIL LETS TRY SOMETHING ELSE...",0,0)







$go8 = 1
IF $go8 = 1 Then

_GDIPlus_Startup()
$hImageA =_GDIPlus_ImageLoadFromFile($fileA2) ;this is the PASS OR FAIL
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)
$x = 0
$y = 0
$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0) ;Zero will search against your active screen
If $result > 0 Then
ToolTip("FOUND PASS/FAIL THE SECOND TIME AROUND",0,0)
$go8 = 0
$go3 = 0
MouseMove($x, $y)
MOUSECLICK("LEFT")
SLEEP(500)
send("P")
sleep(500)
send("{ENTER}")
Else
ToolTip("STILL CANT FIND PASS/FAIL...",0,0)

_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()

EndIf
EndIf














SLEEP(1000)
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
EndIf
WEnd


$goZ = 1
while $goZ = 1
_GDIPlus_Startup()
$hImageA =_GDIPlus_ImageLoadFromFile($fileF) ;this is theDATA BOX
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)
$x = 0
$y = 0
$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0) ;Zero will search against your active screen
If $result > 0 Then
ToolTip("FOUND DATA BOX",0,0)
$goZ = 0
MouseMove($x, $y)
MOUSECLICK("LEFT")


_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
Else
ToolTip("CANT FIND DATA BOX",0,0)
SLEEP(1000)
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
EndIf
WEnd



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
While $answer2 > 0
$answer2 = $answer2 - 1
Global $answer3 = $answer2
Print()
Sleep(1000)
WEnd
SEND("{HOME}")
EndFunc


;----------------------------------------------------------------------------------------------------------------------------------------------;
func ToggleFail()
Local $answer = InputBox("Question", "What part number?", "....", "", _
- 1, -1, 0, 0)
Local $answer2 = InputBox("Question", "How many should we print?", "....", "", _
- 1, -1, 0, 0)
Global $DATA2 = InputBox("OPTIONAL", "VENDOR/DATE?", "", "", _
- 1, -1, 0, 0)

SEND("{HOME}")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$go1 = 1
while $go1 = 1
_GDIPlus_Startup()
$hImageA =_GDIPlus_ImageLoadFromFile($fileB) ;this is the PART NUMBER BOX
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)
$x = 0
$y = 0
$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0) ;Zero will search against your active screen
If $result > 0 Then
ToolTip("WE FOUND PART NUMBER BOX",0,0)
MouseMove($x, $y)
$go1 = 0
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
Else
ToolTip("CANT FIND PART NUMBER BOX",0,0)
SLEEP(500)
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
EndIf
WEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MOUSECLICK("LEFT")
send($answer) ;sends first input box
sleep(800)
send("{ENTER}")
sleep(1000)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

$go2 = 1
while $go2 = 1
_GDIPlus_Startup()
$hImageA =_GDIPlus_ImageLoadFromFile($fileC) ;this is the SUBMIT BOX
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)
$x = 0
$y = 0
$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0) ;Zero will search against your active screen
If $result > 0 Then
ToolTip("FOUND THE SUBMIT BOX",0,0)
MouseMove($x, $y)
$go2 = 0
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
Else
ToolTip("CANT FIND SUBMIT BOX",0,0)
SLEEP(500)
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
EndIf
sleep(1000)
mouseclick("left") ;clicks it
sleep(6000)
WEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

$go = 1
while $go = 1

_GDIPlus_Startup()
$hImageA =_GDIPlus_ImageLoadFromFile($fileD) ;this is the PAGE LOADED
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)
$x = 0
$y = 0
$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0) ;Zero will search against your active screen
If $result > 0 Then
ToolTip("PAGE IS LOADED",0,0)
$go = 0
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
Else
ToolTip("WAITING FOR PAGE TO LOAD",0,0)
SLEEP(1000)
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
EndIf
WEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



$go3 = 1
while $go3 = 1
_GDIPlus_Startup()
$hImageA =_GDIPlus_ImageLoadFromFile($fileA) ;this is the PASS OR FAIL
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)
$x = 0
$y = 0
$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0) ;Zero will search against your active screen
If $result > 0 Then
ToolTip("FOUND PASS/FAIL",0,0)
$go3 = 0
MouseMove($x, $y)
MOUSECLICK("LEFT")
SLEEP(500)
send("P")
sleep(500)
send("{ENTER}")
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
Else
ToolTip("CANT FIND PASS/FAIL LETS TRY SOMETHING ELSE...",0,0)







$go8 = 1
IF $go8 = 1 Then

_GDIPlus_Startup()
$hImageA =_GDIPlus_ImageLoadFromFile($fileA2) ;this is the PASS OR FAIL
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)
$x = 0
$y = 0
$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0) ;Zero will search against your active screen
If $result > 0 Then
ToolTip("FOUND PASS/FAIL THE SECOND TIME AROUND",0,0)
$go8 = 0
$go3 = 0
MouseMove($x, $y)
MOUSECLICK("LEFT")
SLEEP(500)
send("f")
sleep(500)
send("{ENTER}")
Else
ToolTip("STILL CANT FIND PASS/FAIL...",0,0)

_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()

EndIf
EndIf














SLEEP(1000)
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
EndIf
WEnd


$goZZ = 1
while $goZZ = 1
_GDIPlus_Startup()
$hImageA =_GDIPlus_ImageLoadFromFile($fileF) ;this is theDATA BOX
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)
$x = 0
$y = 0
$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0) ;Zero will search against your active screen
If $result > 0 Then
ToolTip("FOUND DATA BOX",0,0)
$goZZ = 0
MouseMove($x, $y)
MOUSECLICK("LEFT")


_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
Else
ToolTip("CANT FIND DATA BOX",0,0)
SLEEP(1000)
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
EndIf
WEnd



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
While $answer2 > 0
$answer2 = $answer2 - 1
Global $answer3 = $answer2
Print2()
Sleep(1000)
WEnd
SEND("{HOME}")
EndFunc
;--------------------------------------------------------------------------------------------------------------------------------------------------------;





func Print()
ToolTip($answer3& " LEFT TO PRINT" ,0,63)


SEND($DATA)



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$go4 = 1
while $go4 = 1
_GDIPlus_Startup()
$hImageA =_GDIPlus_ImageLoadFromFile($fileE) ;this is the SUMBIT ITEM
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)
$x = 0
$y = 0
$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0) ;Zero will search against your active screen
If $result > 0 Then
ToolTip("FOUND SUBMIT ITEM",0,0)
$go4 = 4
MouseMove($x, $y)
MOUSECLICK("LEFT")

_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
Else
ToolTip("CANT FIND SUBMIT ITEM",0,0)
SLEEP(1000)
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
EndIf
WEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ToLog("Pass")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$go = 1
while $go = 1

_GDIPlus_Startup()
$hImageA =_GDIPlus_ImageLoadFromFile($fileD) ;this is the PAGE LOADED
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)
$x = 0
$y = 0
$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0) ;Zero will search against your active screen
If $result > 0 Then
ToolTip("PAGE IS LOADED",0,0)
$go = 0
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
Else
ToolTip("WAITING FOR PAGE TO LOAD",0,0)
SLEEP(1000)
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
EndIf
WEnd



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$go5 = 1
while $go5 = 1
_GDIPlus_Startup()
$hImageA =_GDIPlus_ImageLoadFromFile($fileC) ;this is the SUBMIT BOX
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)
$x = 0
$y = 0
$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0) ;Zero will search against your active screen
If $result > 0 Then
ToolTip("FOUND THE SUBMIT BOX",0,0)
MouseMove($x, $y)
$go5 = 0
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
Else
ToolTip("CANT FIND SUBMIT BOX",0,0)
SLEEP(1100)
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
EndIf
sleep(1000)
mouseclick("left") ;clicks it
WEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

$go = 1
while $go = 1

_GDIPlus_Startup()
$hImageA =_GDIPlus_ImageLoadFromFile($fileD) ;this is the PAGE LOADED
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)
$x = 0
$y = 0
$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0) ;Zero will search against your active screen
If $result > 0 Then
ToolTip("PAGE IS LOADED",0,0)
$go = 0
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
Else
ToolTip("WAITING FOR PAGE TO LOAD",0,0)
SLEEP(1000)
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
EndIf
WEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

EndFunc

func Print2()
ToolTip($answer3& " LEFT TO PRINT" ,0,63)


SEND($DATA2)



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$go4 = 1
while $go4 = 1
_GDIPlus_Startup()
$hImageA =_GDIPlus_ImageLoadFromFile($fileE) ;this is the SUMBIT ITEM
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)
$x = 0
$y = 0
$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0) ;Zero will search against your active screen
If $result > 0 Then
ToolTip("FOUND SUBMIT ITEM",0,0)
$go4 = 4
MouseMove($x, $y)
MOUSECLICK("LEFT")

_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
Else
ToolTip("CANT FIND SUBMIT ITEM",0,0)
SLEEP(1000)
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
EndIf
WEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ToLog("Fail")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$go = 1
while $go = 1

_GDIPlus_Startup()
$hImageA =_GDIPlus_ImageLoadFromFile($fileD) ;this is the PAGE LOADED
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)
$x = 0
$y = 0
$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0) ;Zero will search against your active screen
If $result > 0 Then
ToolTip("PAGE IS LOADED",0,0)
$go = 0
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
Else
ToolTip("WAITING FOR PAGE TO LOAD",0,0)
SLEEP(1000)
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
EndIf
WEnd



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$go5 = 1
while $go5 = 1
_GDIPlus_Startup()
$hImageA =_GDIPlus_ImageLoadFromFile($fileC) ;this is the SUBMIT BOX
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)
$x = 0
$y = 0
$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0) ;Zero will search against your active screen
If $result > 0 Then
ToolTip("FOUND THE SUBMIT BOX",0,0)
MouseMove($x, $y)
$go5 = 0
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
Else
ToolTip("CANT FIND SUBMIT BOX",0,0)
SLEEP(1100)
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
EndIf
sleep(1000)
mouseclick("left") ;clicks it
WEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

$go = 1
while $go = 1

_GDIPlus_Startup()
$hImageA =_GDIPlus_ImageLoadFromFile($fileD) ;this is the PAGE LOADED
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)
$x = 0
$y = 0
$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0) ;Zero will search against your active screen
If $result > 0 Then
ToolTip("PAGE IS LOADED",0,0)
$go = 0
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
Else
ToolTip("WAITING FOR PAGE TO LOAD",0,0)
SLEEP(1000)
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()
EndIf
WEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

EndFunc

Func ReadPOF()
If $ShowLog = True Then
$Log = FileOpen($SaveLogsPath & "log.txt", 1)
Dim $v_sw_down = 0
Dim $v_sw_up = 0
Dim $s_swportlist
_FileReadToArray($Log, $s_swportlist)

;_ArrayDisplay($s_swportlist, "Switch Ports")

; Reads the switch port status
For $x = 1 To UBound($s_swportlist) - 1
If StringInStr($s_swportlist[$x], "Pass") Then
$v_sw_down = ($v_sw_down + 1)
EndIf
If StringInStr($s_swportlist[$x], "Fail") Then
$v_sw_up = ($v_sw_up + 1)
EndIf
Next
ToolTip("Passes: " & $v_sw_down & "Fails: " & $v_sw_up & ".",616,33)
FileClose($Log)
EndIf
EndFunc



Func ToLog($Text)
If $ShowLog = True Then

$Log = FileOpen($SaveLogsPath & "log.txt", 1)
FileWriteLine($Log, "<" & @MON & @MDAY & @YEAR & "><" & @HOUR & ":" & @MIN & ":" & @SEC & "> " & $Text)
FileClose($Log)
EndIf
EndFunc



Func Terminate()
Exit 0
EndFunc
Link to comment
Share on other sites

LOL I knew I was being a noob however its showing Pass 0 Fail 0 in my tooltip when I know for a fact my log file has this in it.

<09142012><08:51:17> Pass

<09142012><08:52:25> Pass

<09142012><08:53:02> Fail

<09142012><09:37:15> Pass

Edit hopefully im not too far in over my head here that function has me a little lost! I learned everything I wrote in there from reading and trial/error however this just has me really confused!

Edited by magace
Link to comment
Share on other sites

Again sorry but im not too sure I know what to do when you ask if i can see it in my array. I tried using this:

_ArrayDisplay($s_swportlist, "Switch Ports")

And nothing shows up from what I read it should be bringing up a box similar to a msgbox?

So do I need to write the array to a txt or something? Sorry pretty lost here! :o

Link to comment
Share on other sites

_FileReadToArray can't use the file handle returned for a FileOpen, it needs a path and filename to work. You're trying to read the file with the handle returned by this line $Log = FileOpen($SaveLogsPath & "log.txt", 1), and it's failing, which is why your _ArrayDisplay isn't showing anything, because there's no array.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

_FileReadToArray can't use the file handle returned for a FileOpen, it needs a path and filename to work. You're trying to read the file with the handle returned by this line $Log = FileOpen($SaveLogsPath & "log.txt", 1), and it's failing, which is why your _ArrayDisplay isn't showing anything, because there's no array.

Hah I see that made it work perfectly thanks a bunch!!! Now im going places!

Link to comment
Share on other sites

well you probably should go through first.

Then become friends with the help file.

change this

_FileReadToArray($Log, $s_swportlist)

;_ArrayDisplay($s_swportlist, "Switch Ports")

to this

local $iReturn
local $sHugh


$iReturn=_FileReadToArray($Log, $s_swportlist)
switch @error
case 0
$hugh="Okey Dokey"
case 1
$hugh="Error opening specified file"
case 2
$hugh="Unable to Split the file"
endswitch
msgbox(0,"OmGz whats with log"& $Log, "if $iReturn is not 1 and error is not error is not zero, there is a problem, $iReturn="&$iReturn&" @error="&$hugh)
_ArrayDisplay($s_swportlist, "Switch Ports")

;uncommnented array
Link to comment
Share on other sites

Sorry for double post but there is one more thing I would like to accomplish I would like to make it search the date first then for pass or fail so it will reset daily I was hoping I could do something simple like this:

top of script:

$DATE = @MON & @MDAY & @YEAR

ReadPOF function:

Func ReadPOF()

If $ShowLog = True Then

Dim $v_sw_down = 0

Dim $v_sw_up = 0

Dim $s_swportlist

_FileReadToArray("C:\Users\Tester\Desktop\New folder (2)\logs\log.txt", $s_swportlist)

; Reads the switch port status

For $x = 1 To UBound($s_swportlist) - 1

If StringInStr($s_swportlist[$x], $DATE & "Pass") Then

$v_sw_down = ($v_sw_down + 1)

EndIf

If StringInStr($s_swportlist[$x], $DATE & "Fail") Then

$v_sw_up = ($v_sw_up + 1)

EndIf

Next

ToolTip("Passes: " & $v_sw_down & " Fails: " & $v_sw_up & ".",57,67)

;_ArrayDisplay($s_swportlist, "Switch Ports")

EndIf

EndFunc

All I did was add the BOLD and now its showing 0 pass and 0 fail my log file looks like this:

<09142012><08:51:17> Pass

<09142012><08:52:25> Pass

<09142012><08:53:02> Fail

<09142012><09:37:15> Pass

<09142012><10:23:53> Pass

<09142012><10:24:02> Pass

<09142012><10:24:11> Pass

<09142012><10:24:20> Pass

<09142012><10:24:29> Pass

<09142012><10:24:38> Pass

<09142012><10:24:47> Pass

<09142012><10:24:55> Pass

<09142012><10:25:04> Pass

<09142012><10:25:15> Pass

<09142012><10:25:24> Pass

<09142012><10:25:34> Pass

<09142012><10:25:43> Pass

I guess its not that easy even tho im sure it is! Again any help would be great thanks!!
Link to comment
Share on other sites

This: <09142012><08:51:17> Pass

Does not equal 09142102Pass

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

change

For $x = 1 To UBound($s_swportlist) - 1
If StringInStr($s_swportlist[$x], $DATE & "Pass") Then
$v_sw_down = ($v_sw_down + 1)
EndIf
If StringInStr($s_swportlist[$x], $DATE & "Fail") Then
$v_sw_up = ($v_sw_up + 1)
EndIf

to

For $x = 1 To UBound($s_swportlist) - 1
if stringinstr($s_swportlist[$x],$DATE) then
;something here if you want
else
continue loop
endif
If StringInStr($s_swportlist[$x],"Pass") Then
$v_sw_down = ($v_sw_down + 1)
else
$v_sw_up = ($v_sw_up + 1)
EndIf
Edited by DicatoroftheUSA
Link to comment
Share on other sites

Thanks a ton for all the help love these forums members are always so kind!

I also added a function to search specific dates and it works great!

My next and final project for this is to add another function to search between two dates and get the totals!

My search function for a single date(working):

Func ToggleSearch()
 If $ShowLog = True Then
 Local $answer = InputBox("Question", "What Date?", "....", "", _
- 1, -1, 0, 0)
Dim $v_sw_down = 0
Dim $v_sw_up = 0
Dim $s_swportlist
_FileReadToArray("C:UsersTesterDesktopNew folder (2)logslog.txt", $s_swportlist)
; Reads the switch port status
For $x = 1 To UBound($s_swportlist) - 1
if stringinstr($s_swportlist[$x],$answer) then
;something here if you want
else
continueloop
endif
If StringInStr($s_swportlist[$x],"Pass") Then
$v_sw_down = ($v_sw_down + 1)
else
$v_sw_up = ($v_sw_up + 1)
EndIf
Next
ToolTip("Passes: "  & $v_sw_down & " Fails: " & $v_sw_up & ".",0,0)
 _ArrayDisplay($s_swportlist, "Switch Ports")
 EndIf
EndFunc

This will be the hardest thing here im pretty sure since it would have to create the array out of the unidentified dates since I will just be telling it where to start and end not whats in between! Thanks again for everyone's help and if anyone is bored enough to give this a shot feel free! :ILA2:

Link to comment
Share on other sites

The easiest way would be to use regular expressions to reorder the date to yyyymmdd

Then you can you normal expressions to evaluate it.

eg

$sThen="<09142012><10:25:43> Pass"

$sThen=StringRegExpReplace($sThen,"<(..)(..)(....)><.*>.*","$3$1$2")
$sNow=@YEAR&@MON&@mday
If $sThen<=$sNow Then
MsgBox(0,$sThen&" <= "&$sNow,"Yesterday is gone")
Else
MsgBox(0,$sThen&" <= "&$sNow,"Quantem causailty is broken the universe will now end, goodbye.")
EndIf
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...