December 1, 2005 - WinTask - Common Declarations
' ' Common - Common declarations and functions '
' ' General tables used during CaptureHTMLTable() and any other place needed ' Dim tabcell$(5000) Dim tabcell2$(100) Dim tabcell3$(100) Dim tabcell4$(100) Dim tabcell5$(100) Dim WaitForCountTab$(100) dim CLFortune100DUNs$(1000) dim CLFortune100Name$(1000) dim CLFortune100Addr$(1000) dim CLFortune100PhysAddr$(1000) ' ' Logging wrapper functions ' Function LogLog(text$) Pause 1 secs
StartBrowser("IE","http://zapleads."+site$+"zapdata.com/zadm0n/log.jsp?msg=["+initials$+"+"+Time$()+"]:+"+text$+"&level=severe") UseWindow("IEXPLORE.EXE|IEFrame|http://zapleads."+site$+"zapdata.com/zadm0n/log.jsp",1) CloseBrowser() 'EndIf Pause 1 secs EndFunction
Function LogError(text$) Comment("***** Error : "+text$+" *****") EndFunction
Function LogComment(text$) Comment(text$) MsgFrame("Next : "+text$,1,0,0) EndFunction
Function LogWarning(text$) Comment("..... "+text$+ " ?????") EndFunction
Function LogNote(text$) Comment("..... "+text$) EndFunction
' ' Snap-and-Compare function ' ' Select all the text from a web page ' Strip out the release-specific text at the bottom ' Store it in a file ' Compare the file to a baseline version of the same file (if one exists) ' If the two files don't match, then declare an error, and leave the newly-created file in the result folder ' If the two files match, delete the newly-created file from the result folder ' If there is no baseline, note that fact and leave the newly-created file in the resut folder
Function Snap(file$) Pause 3 secs hWnd=External("user32","GetForegroundWindow") UseWindowHandle(hWnd) 'Click into the main client area ClickMouse(Left,Down,200,100) ClickMouse(Left,Up,200,100)
'Select all text SendKeys("") pause 3 secs a$=GetClipBoard$()
' If Instr(a$,"imarket") <> 0 then ' MsgBox("===== WHILE SNAPPING "+file$+" WE ENCOUNTERED imarket! =====") ' Endif ' If Instr(a$,"a leading") <> 0 then ' MsgBox("===== WHILE SNAPPING "+file$+" WE ENCOUNTERED a leading! =====") ' Endif
' If the page has the Release Number-specific text at the bottom ' strip it off b=InStr(a$,"RELEASE NUM:") if b = 0 then b=len(a$) else b=b-1 endif a=len(a$) test$=Left$(a$,b)
'If the file exists in the result folder, delete it if exist(respath$+file$) then kill(respath$+file$) endif
'Compare to base if it exists if exist(exppath$+file$) then read(exppath$+file$,base$) pause 1 secs if base$ = test$ then LogNote(file$+" is the same") else LogWarning(file$+" is different!") Write(respath$+file$,test$) endif else LogNote(file$+" has no baseline. Leaving results.") Write(respath$+file$,test$) endif endfunction
' ' Snap-and-Compare function for Summary files ' ' Same as regular Snap except ' Strip out the User Name and Date portions at the top
Function SnapSummary(file$) Pause 3 secs hWnd=External("user32","GetForegroundWindow") UseWindowHandle(hWnd) 'Click into the main client area ClickMouse(Left,Down,200,100) ClickMouse(Left,Up,200,100)
'Select all text SendKeys("") pause 3 secs a$=GetClipBoard$()
b=InStr(a$,"Count:") test$=Right$(a$,((Len(a$) - b)+1))
'If the file exists in the result folder, delete it if exist(respath$+file$) then kill(respath$+file$) endif
'Compare to base if it exists if exist(exppath$+file$) then read(exppath$+file$,base$) pause 1 secs if base$ = test$ then LogNote(file$+" is the same") else LogError(file$+" is different!") Write(respath$+file$,test$) endif else LogNote(file$+" has no baseline. Leaving results.") Write(respath$+file$,test$) endif endfunction
' ' Different Snap for Help files. ' ' area$=CONTENTS -> snap the contents panel ' area$=INDEX -> snap the index panel ' area$=other -> snap the help page itself ' Function SnapHelp(file$,area$) Pause 3 secs hWnd=External("user32","GetForegroundWindow") UseWindowHandle(hWnd) Select Case UCase$(area$) Case "CONTENTS" ClickMouse(Left,Down,100,130) ClickMouse(Left,Up,100,130) SendKeys("") pause 3 secs test$=GetClipBoard$() Case "INDEX" ClickMouse(Left,Down,160,190) ClickMouse(Left,Up,160,190) SendKeys("") pause 3 secs SendKeys("") pause 3 secs test$=GetClipBoard$() Case Else ClickMouse(Left,Down,500,100) ClickMouse(Left,Up,500,100) SendKeys("") pause 3 secs test$=GetClipBoard$() endSelect
'If the file exists in the result folder, delete it if exist(respath$+file$) then kill(respath$+file$) endif
'Compare to base if it exists if exist(exppath$+file$) then read(exppath$+file$,base$) pause 1 secs if base$ = test$ then LogNote(file$+" is the same") else LogError(file$+" is different!") Write(respath$+file$,test$) endif else LogNote(file$+" has no baseline. Leaving results.") Write(respath$+file$,test$) endif endfunction
' ' Snap-and-Compare function for PL frame ' ' Same as regular Snap except ' Strip out the User Name and Date portions at the top Function SnapPL(file$) Pause 3 secs hWnd=External("user32","GetForegroundWindow") UseWindowHandle(hWnd) 'Click into the main client area ClickMouse(Left,Down,200,200) ClickMouse(Left,Up,200,200)
'Select all text SendKeys("") pause 3 secs a$=GetClipBoard$()
' If Instr(a$,"imarket") <> 0 then ' MsgBox("===== WHILE SNAPPING "+file$+" WE ENCOUNTERED imarket! =====") ' Endif ' If Instr(a$,"a leading") <> 0 then ' MsgBox("===== WHILE SNAPPING "+file$+" WE ENCOUNTERED a leading! =====") ' Endif
' If the page has the Release Number-specific text at the bottom ' strip it off b=InStr(a$,"RELEASE NUM:") if b = 0 then b=len(a$) else b=b-1 endif a=len(a$) test$=Left$(a$,b)
'If the file exists in the result folder, delete it if exist(respath$+file$) then kill(respath$+file$) endif
'Compare to base if it exists if exist(exppath$+file$) then read(exppath$+file$,base$) pause 1 secs if base$ = test$ then LogNote(file$+" is the same") else LogError(file$+" is different!") Write(respath$+file$,test$) endif else LogNote(file$+" has no baseline. Leaving results.") Write(respath$+file$,test$) endif endfunction
' GetStatic$() function - Get the static text within a popup error message dialog ' ' Strategy - We get the Handle to the icon, then get the handle to its sibling window ' In this case, the sibling to the icon is the Static text ' Then, using the handle we can get the WinTask window name and capture the text ' ' Function Prototype for the GetWindow Win32 API call (from Win32API.TXT) - ' Declare Function GetWindow Lib "user32" Alias "GetWindow" (ByVal hwnd As Long, ByVal wCmd As Long) As Long ' ' GetWindow() Constants ' Const GW_HWNDFIRST = 0 ' Const GW_HWNDLAST = 1 ' Const GW_HWNDNEXT = 2 ' Const GW_HWNDPREV = 3 ' Const GW_OWNER = 4 ' Const GW_CHILD = 5 ' Const GW_MAX = 5 ' Function GetStatic$() UseWindow("IEXPLORE.EXE|#32770|Microsoft Internet Explorer",1) hwnd=GetWindowHandle("IEXPLORE.EXE|Static|Microsoft Internet Explorer|1",1) ' Get the handle of the Icon mywnd=External("user32","GetWindow", hwnd, 2) ' Get the handle of the Static text (2 = GW_HWNDNEXT) myname$=GetWindowName$(mywnd) ' Using the handle, get the Window Name of the Static text GetStatic$=Capture$(myname$,1,1) ' Now we can Capture the text of the Static text endfunction
' WaitForCount() function - Safely waits until the count is complete before proceeding
Function WaitForCount(WhichTable$) Local ret #IgnoreErrors=1 ret = -1 while ret < 0 ret = CaptureTableHTML("TABLE[CONTENT='"+WhichTable$+"']", "R1C1:R1C1", WaitForCountTab$()) pause 1 secs wend #IgnoreErrors=0 pause 3 secs EndFunction
' IsSecure() function - check if the current page is secure (https)
Function IsSecure() UseWindow("IEXPLORE.EXE|Edit||1",1) SendKeys(">") If Left$(GetClipboard$(),5) = "https" then IsSecure = 1 else IsSecure = 0 EndIf EndFunction
|