Advertisement
StavenCross

Untitled

Sep 29th, 2017
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  main:
  2. {
  3.    Gosub,init
  4.    url:="https://dealertrack-production.my.salesforce.com/00O0e000004iT67"
  5.    WB.Navigate(url)
  6.    loop
  7.       If !WB.busy
  8.          break
  9. Text := "Please login to salesforce, once logged in you may click OK and contine. DO NOT CLICK OK WITHOUT LOGGING IN!"
  10. MessageBoxCheck(Text, "Login to Salesforce to continue", 0x30, "")
  11. UrlDownloadToFile,https://dealertrack-production.my.salesforce.com/00O0e000004iT67, %A_Desktop%\MPRDownload.txt
  12. MsgBox, Thanks! We have captured your MPRs for the month!
  13. Gui,Destroy
  14.  
  15. FileRead,expression,%A_Desktop%\MPRDownload.txt
  16. FileDelete, %A_Desktop%\MPRDownload.txt
  17. pos := 0
  18.  
  19. 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)) {
  20.     ;RegExMatch(res,">.^?<",res2,pos+1)
  21. FileAppend,%res%,%A_desktop%\MPRDownload.txt
  22.  
  23. }
  24.  
  25. MsgBox,First Cleanup Passthrough Completed
  26. FileRead,cleanedOutput,%A_Desktop%\MPRDownload.txt
  27. FileDelete, %A_Desktop%\MPRDownload.txt
  28. pos:=0
  29. while(pos := RegExMatch(cleanedOutput,">.*?<", res, pos + 1)) {  
  30. FileAppend,%res%,%A_desktop%\MPRDownload.txt
  31. }
  32. MsgBox,Second Cleanup passthrough Completed
  33.  
  34. FileRead,checkMe,%A_Desktop%\MPRDownload.txt
  35. StringReplace,checkMe2,checkMe,<><><>,|,All
  36. StringReplace,checkMe3,checkMe2,<><><><>,|,All
  37. StringReplace,checkMe4,checkMe3,>,,All
  38. StringReplace,checkMe5,checkMe4,<,,All
  39. FileDelete %A_Desktop%\MPRDownload.txt
  40. FileAppend,%checkMe5%,%A_desktop%\MPRdownload.txt
  41. MsgBox,StringReplaces have been completed
  42. ;Working example of regex & replace to clean up our MPR ID numbers
  43.  
  44. FileRead,Haystack,%A_desktop%\MPRDownload.txt
  45. Needle = adafordfd
  46. StringGetPos, pos, Haystack, %Needle%
  47. Offset := StrLen(Needle)+2
  48. MsgBox, %offset%
  49.     MsgBox, The string was found at position %pos%.
  50.     Final:=subStr(Haystack,pos + Offset,15)
  51. MsgBox,%final%
  52.  
  53.    return
  54. }
  55.  
  56.  
  57.  
  58. init:
  59. {
  60.    ;// housekeeping routines
  61.    ;// set the tear down procedure
  62.    OnExit,terminate
  63.    
  64.    ;// Create a gui
  65.    Gui, +LastFound +Resize +OwnDialogs
  66.    
  67.    ;// create an instance of Internet Explorer_Server
  68.    ;// store the iwebbrowser2 interface pointer as *WB* & the hwnd as *ATLWinHWND*
  69.    Gui, Add, ActiveX, w510 h600 x0 y0 vWB hwndATLWinHWND, Shell.Explorer
  70.    
  71.    ;// disable annoying script errors from the page
  72.    WB.silent := true
  73.    
  74.    ;// necesary to accept enter and accelorator keys
  75.    ;http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.ole.interop.ioleinplaceactiveobject(VS.80).aspx
  76.    IOleInPlaceActiveObject_Interface:="{00000117-0000-0000-C000-000000000046}"
  77.    
  78.    ;// necesary to accept enter and accelorator keys
  79.    ;// get the in place interface pointer
  80.    pipa := ComObjQuery(WB, IOleInPlaceActiveObject_Interface)
  81.    
  82.    ;// necesary to accept enter and accelorator keys
  83.    ;// capture key messages
  84.    OnMessage(WM_KEYDOWN:=0x0100, "WM_KEYDOWN")
  85.    OnMessage(WM_KEYUP:=0x0101, "WM_KEYDOWN")
  86.    
  87.    ;//Display the GUI
  88.    gui,show, w510 h600 ,Gui Browser
  89.    
  90.    ;// return and allow the program
  91.    return
  92. }
  93.  
  94. ;// capture the gui resize event
  95. GuiSize:
  96. {
  97.    ;// if there is a resize event lets resize the browser
  98.    WinMove, % "ahk_id " . ATLWinHWND, , 0,0, A_GuiWidth, A_GuiHeight
  99.    return
  100. }
  101.  
  102. GuiClose:
  103. terminate:
  104. {
  105.    ;// housekeeping
  106.    ;// destroy the gui
  107.    Gui, Destroy
  108.    ;// release the in place interface pointer
  109.    ObjRelease(pipa)
  110.    ExitApp
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement