Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- main:
- {
- Gosub,init
- url:="https://dealertrack-production.my.salesforce.com/00O0e000004iT67"
- WB.Navigate(url)
- loop
- If !WB.busy
- break
- Text := "Please login to salesforce, once logged in you may click OK and contine. DO NOT CLICK OK WITHOUT LOGGING IN!"
- MessageBoxCheck(Text, "Login to Salesforce to continue", 0x30, "")
- UrlDownloadToFile,https://dealertrack-production.my.salesforce.com/00O0e000004iT67, %A_Desktop%\MPRDownload.txt
- MsgBox, Thanks! We have captured your MPRs for the month!
- Gui,Destroy
- FileRead,expression,%A_Desktop%\MPRDownload.txt
- FileDelete, %A_Desktop%\MPRDownload.txt
- pos := 0
- While(pos := RegExMatch(expression, "<tr class=""even"" valign=""top""><td ><a href=""\/[0-9a-zA-Z]+"">(.*?)<\/a><\/td><td >(.*?)<\/td><\/tr>\s", res,pos+1)) {
- ;RegExMatch(res,">.^?<",res2,pos+1)
- FileAppend,%res%,%A_desktop%\MPRDownload.txt
- }
- MsgBox,First Cleanup Passthrough Completed
- FileRead,cleanedOutput,%A_Desktop%\MPRDownload.txt
- FileDelete, %A_Desktop%\MPRDownload.txt
- pos:=0
- while(pos := RegExMatch(cleanedOutput,">.*?<", res, pos + 1)) {
- FileAppend,%res%,%A_desktop%\MPRDownload.txt
- }
- MsgBox,Second Cleanup passthrough Completed
- FileRead,checkMe,%A_Desktop%\MPRDownload.txt
- StringReplace,checkMe2,checkMe,<><><>,|,All
- StringReplace,checkMe3,checkMe2,<><><><>,|,All
- StringReplace,checkMe4,checkMe3,>,,All
- StringReplace,checkMe5,checkMe4,<,,All
- FileDelete %A_Desktop%\MPRDownload.txt
- FileAppend,%checkMe5%,%A_desktop%\MPRdownload.txt
- MsgBox,StringReplaces have been completed
- ;Working example of regex & replace to clean up our MPR ID numbers
- FileRead,Haystack,%A_desktop%\MPRDownload.txt
- Needle = adafordfd
- StringGetPos, pos, Haystack, %Needle%
- Offset := StrLen(Needle)+2
- MsgBox, %offset%
- MsgBox, The string was found at position %pos%.
- Final:=subStr(Haystack,pos + Offset,15)
- MsgBox,%final%
- return
- }
- init:
- {
- ;// housekeeping routines
- ;// set the tear down procedure
- OnExit,terminate
- ;// Create a gui
- Gui, +LastFound +Resize +OwnDialogs
- ;// create an instance of Internet Explorer_Server
- ;// store the iwebbrowser2 interface pointer as *WB* & the hwnd as *ATLWinHWND*
- Gui, Add, ActiveX, w510 h600 x0 y0 vWB hwndATLWinHWND, Shell.Explorer
- ;// disable annoying script errors from the page
- WB.silent := true
- ;// necesary to accept enter and accelorator keys
- ;http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.ole.interop.ioleinplaceactiveobject(VS.80).aspx
- IOleInPlaceActiveObject_Interface:="{00000117-0000-0000-C000-000000000046}"
- ;// necesary to accept enter and accelorator keys
- ;// get the in place interface pointer
- pipa := ComObjQuery(WB, IOleInPlaceActiveObject_Interface)
- ;// necesary to accept enter and accelorator keys
- ;// capture key messages
- OnMessage(WM_KEYDOWN:=0x0100, "WM_KEYDOWN")
- OnMessage(WM_KEYUP:=0x0101, "WM_KEYDOWN")
- ;//Display the GUI
- gui,show, w510 h600 ,Gui Browser
- ;// return and allow the program
- return
- }
- ;// capture the gui resize event
- GuiSize:
- {
- ;// if there is a resize event lets resize the browser
- WinMove, % "ahk_id " . ATLWinHWND, , 0,0, A_GuiWidth, A_GuiHeight
- return
- }
- GuiClose:
- terminate:
- {
- ;// housekeeping
- ;// destroy the gui
- Gui, Destroy
- ;// release the in place interface pointer
- ObjRelease(pipa)
- ExitApp
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement