Advertisement
StavenCross

Main

Sep 29th, 2017
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;Functions
  2.  
  3.  
  4.  
  5. WM_KEYDOWN(wParam, lParam, nMsg, hWnd)
  6. {
  7.    global pipa
  8.    static keys:={9:"tab", 13:"enter", 46:"delete", 38:"up", 40:"down"}
  9.    if keys.HasKey(wParam)
  10.    {
  11.       WinGetClass, ClassName, ahk_id %hWnd%
  12.       if  (ClassName = "Internet Explorer_Server")
  13.       {
  14.       ;// Build MSG Structure
  15.          VarSetCapacity(Msg, 48)
  16.          for i,val in [hWnd, nMsg, wParam, lParam, A_EventInfo, A_GuiX, A_GuiY]
  17.             NumPut(val, Msg, (i-1)*A_PtrSize)
  18.       ;// Call Translate Accelerator Method
  19.          TranslateAccelerator := NumGet(NumGet(1*pipa)+5*A_PtrSize)
  20.          DllCall(TranslateAccelerator, "Ptr",pipa, "Ptr",&Msg)
  21.          return, 0
  22.       }
  23.    }
  24. }
  25.  
  26. MessageBoxCheck(Text, Title := "", Options := 0, RegVal := "", Owner := 0) {
  27.     If (DllCall("GetVersion") & 0xFF < 6) {
  28.         hModule := DllCall("GetModuleHandle", "Str", "shlwapi.dll", "Ptr")
  29.         SHMessageBoxCheck := DllCall("GetProcAddress", "Ptr", hModule, "UInt", (A_IsUnicode) ? 191 : 185, "Ptr")
  30.     } Else {
  31.         SHMessageBoxCheck := "Shlwapi\SHMessageBoxCheck"
  32.     }
  33.    
  34.     Ret := DllCall(SHMessageBoxCheck
  35.         , "Ptr" , Owner ? Owner : DllCall("GetDesktopWindow", "Ptr")
  36.         , "Str" , Text
  37.         , "Str" , Title
  38.         , "UInt", Options
  39.         , "int" , 0
  40.         , "Str" , (RegVal != "") ? RegVal : A_ScriptFullPath)
  41.  
  42.     Return {0: "Suppressed", 1: "OK", 2: "Cancel", 3: "Abort", 4: "Retry", 5: "Ignore", 6: "Yes", 7: "No", 10: "Try Again", 11: "Continue"}[Ret]
  43. }
  44.  
  45. GrabMPRs(checkit)
  46. {
  47.     Main:
  48. Gosub,init
  49.    url:="https://dealertrack-production.my.salesforce.com/00O0e000004iT67"
  50.    WB.Navigate(url)
  51.    loop
  52.       If !WB.busy
  53.          break
  54. Text := "Please login to salesforce, once logged in you may click OK and contine. DO NOT CLICK OK WITHOUT LOGGING IN!"
  55. MessageBoxCheck(Text, "Login to Salesforce to continue", 0x30, "")
  56. UrlDownloadToFile,https://dealertrack-production.my.salesforce.com/00O0e000004iT67, %A_Desktop%\MPRDownload.txt
  57. MsgBox, Thanks! We have captured your MPRs for the month!
  58. Gui,Destroy
  59.  
  60. FileRead,expression,%A_Desktop%\MPRDownload.txt
  61. FileDelete, %A_Desktop%\MPRDownload.txt
  62. pos := 0
  63.  
  64. 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)) {
  65.     ;RegExMatch(res,">.^?<",res2,pos+1)
  66. FileAppend,%res%,%A_desktop%\MPRDownload.txt
  67.  
  68. }
  69.  
  70. MsgBox,First Cleanup Passthrough Completed
  71. FileRead,cleanedOutput,%A_Desktop%\MPRDownload.txt
  72. FileDelete, %A_Desktop%\MPRDownload.txt
  73. pos:=0
  74. while(pos := RegExMatch(cleanedOutput,">.*?<", res, pos + 1)) {  
  75. FileAppend,%res%,%A_desktop%\MPRDownload.txt
  76. }
  77. MsgBox,Second Cleanup passthrough Completed
  78.  
  79. FileRead,checkMe,%A_Desktop%\MPRDownload.txt
  80. StringReplace,checkMe2,checkMe,<><><>,|,All
  81. StringReplace,checkMe3,checkMe2,<><><><>,|,All
  82. StringReplace,checkMe4,checkMe3,>,,All
  83. StringReplace,checkMe5,checkMe4,<,,All
  84. FileDelete %A_Desktop%\MPRDownload.txt
  85. FileAppend,%checkMe5%,%A_desktop%\MPRdownload.txt
  86. MsgBox,StringReplaces have been completed
  87. ;Working example of regex & replace to clean up our MPR ID numbers
  88.  
  89. /*FileRead,Haystack,%A_desktop%\MPRDownload.txt
  90. Needle = %checkit%
  91. StringGetPos, pos, Haystack, %Needle%
  92. Offset := StrLen(Needle)+2
  93. MsgBox, %offset%
  94.     MsgBox, The string was found at position %pos%.
  95.     Final:=subStr(Haystack,pos + Offset,15)
  96. MsgBox,%final%
  97. */
  98.    return
  99. }
  100.  
  101.  
  102.  
  103.  
  104. ;**************************************************************************************inital setup**************************************************************************************
  105. #Include %A_ScriptDir%\Internal\Settings.txt                            ;Pull in our values from the text file as vars
  106. #include %A_ScriptDir%\internal\functions.ahk                           ;Pull in our function list
  107. ;Set up our path vars
  108. settingsPath=%A_WorkingDir%\Internal\Settings.txt
  109. AccountListPath=%A_WorkingDir%\Assets\Accounts.txt
  110. emailTemplatePath = %A_WorkingDir%\Assets\MPRTemplate.docx
  111. ;Loop through our accounts list & add accounts to listbox var
  112. Loop,Read,%AccountListPath%
  113.     ListVar .= (A_Index == 1 ? "" : "|") . A_LoopReadLine
  114. /*in the above lines, A_Index is the number of the loop, for instance the first time it runs, the A_index is 1. The ? : symbols are the teriary operator, a shorthand for if else. so this line litterally says:
  115. ListVar = 1=1 if blank then replace with |
  116. So in this case, at the end of each line, add a | so the listBox knows where to delimit the values
  117. */
  118. ;Collect Notes for our FordDirect deck from our Word Document
  119. ;***********
  120. ;TODO
  121. ;This should be a function
  122. ;***********
  123. Clipsave := ClipboardAll                    ; Saves previous Clipboard
  124. Clipboard =                                 ;Empty the Clipboard to prep for template load
  125. oWord := ComObjCreate("Word.Application")   ; create MS Word object
  126. oDoc := oWord.documents.Open(emailTemplatePath) ;Sliently opens our template
  127. oWord.Selection.WholeStory                          ;This is akin to Select All
  128. oWord.Selection.copy                                ;Copy all the text with formatting
  129. emailTemplate = %ClipboardAll%                  ;Load the template into a var to free up our clipboard
  130. oDoc.Close(0)                               ;Unload the MS Word object
  131. oWord.Quit()                                ;Quit MS Word
  132. Clipboard = %ClipSave%                      ;Restore our old Clipboard so the user doesn't know what we did.
  133.  
  134. ;Set up our time based vars
  135. LMoutputDate = %A_YYYY%%A_MM%01         ;Set the output format for the date for "Last Month"
  136. LMoutputDate += -1, days                ;In the previous line we set the day to "01" so we subtracted one to get the previous months' end date
  137. TMoutputDate = %A_YYYY%%A_MM%01         ;we're doing the same thing here for "This Month"
  138. TMoutputDate += -0, days                ;No need to subtract a day
  139. FormatTime, LMmonthEnd, %LMoutputDate%, yyyy-MM-dd          ;Sets var output for the end of month date
  140. FormatTime, LMmonthStart, %LMoutputDate%, yyyy-MM-01        ;Sets var output for beginning of month date, we know that the day will always start with 01.
  141. FormatTime, lastMonthFull, %LMoutputDate%, MMMM             ;Sets var output to grab the text for last month's date
  142. FormatTime, TMmonthEnd, %TMoutputDate%,yyyy-MM-dd       ;Sets var output to end of this month's date
  143. FormatTime, TMmonthStart,%TMoutputDate%, yyyy-MM-01     ;Sets var output to start of this month's date
  144. FormatTime, thisMonthFull,%TMoutputDate%, MMMM              ;Sets var output to grab the text for this month's date
  145.  
  146. ;**************************************************************************************Run errorCheck**************************************************************************************
  147. If(emailTemplate="" )                                   ;Alert if emailTemplate isn't set.
  148. {
  149.     MsgBox, There is no Email Template Loaded! You will not be able to send an email.
  150. }
  151. If(SFName="" )                                          ;Alert if SFname isn't set
  152. {
  153.     MsgBox, You don't have a SalesForce name input, please add it in the settings.
  154. }
  155. If(MPRPath="" )                                         ;Alert if MPRPath isn't set
  156. {
  157.     MsgBox, You don't have a MPR deck selected for your template MPRs, please choose one in the settings
  158. }
  159. Process,Exist,OUTLOOK.EXE                               ;Check if Outlook is running. If it isn't, the app will break. This line sets ErrorLevel to the Task Manager ID of the process, so we'll just check if it's over 0
  160. IF(ErrorLevel < 1)                                      ;If errorlevel is present, we'll alert the user, and open outlook.
  161. {
  162.     MsgBox,Looks like outlook isn't running. This program runs faster when Outlook is already running. Since this program is about making life faster, we'll go ahead and start it up for you! Please leave it running while using this app.
  163.     run outlook.exe
  164. }
  165. ErrorLevel=                                             ;Reset ErrorLevel, we might need it later.
  166. ;**************************************************************************************Set up 1st Gui**************************************************************************************
  167.  
  168. Gui, 1:Add, Button, x2 y825 w120 h50 , Email Only
  169. Gui, 1:Add, Button, x302 y825 w120 h50 Default, Begin MPR Preview
  170. Gui, 1:Add, Button, x550 y825 w120 h50 , Web Page Only
  171. Gui, 1:Add, Button, x492 y50 w100 h50 , Add Account
  172. Gui, 1:Add, Text, x215 y58, You will enter your account id in a `n popup
  173. Gui, 1:Add, Button, x492 y0 w100 h50 , Delete Account
  174. Gui, 1:Add, Button, x492 y100 w100 h50 , Edit Template
  175. Gui, 1:Add, Button, x492 y150 w100 h50, Bulk Account Edit
  176. Gui, 1:Add, Button, x492 y250 w100 h50, Start MPR Loop
  177. Gui, 1:Add, Button, x492 y300 w100 h50, Open MPR Dashboard
  178. Gui, 1:Add, Button, x492 y350 w100 h50, Grab MPRs
  179. Gui, 1:Add, Text, x215 y302, Open an MPR Dashboard to show`nyour MPR stats for the month.
  180. Gui, 1:Add, Text, x215 y5,Select your account from the left`nand click delete to remove it
  181. Gui, 1:Add, Text, x215 y108,Click to edit your email template
  182. Gui, 1:Add, Text, x215 y153, Edit Accounts in bulk. Enter one`nper line
  183. Gui, 1:Add, Text, x215 y258, Clicking this will start your MPR loop
  184. Gui, 1:Add, ListBox, x6 y-1 w200 h836 vAccountSelector , %ListVar%
  185. Gui, 1:Add, Radio, x492 y200 vTemplateMPR, Template MPR
  186. Gui, 1:Add, Radio, vCustomMPR, Custom MPR
  187. Gui, 1:Add, Text, x215 y203, Select Custom if you want to`nspecify a file to attach to the email
  188. Gui, 1:Add, Button, x492 y750 w100 h50, Edit Settings
  189. Gui, 1:Show, w700 h888, MPR Preview Generator
  190. Gui, 2:Add, Button, x60 y440 w100 h50,Close Settings
  191. Gui, 2:Add, Button, x360 y440 w100 h50,Save Settings
  192. Gui, 2:Add, Edit, vSFNameTextBox x250 y10 w200 h30,%SFName%
  193. Gui, 2:Add, Edit, vMPRPathTextBox x250 y90 w200 h30,%MPRPath%
  194. Gui, 2:Add, Text, x10 y10,Enter your name as it appears`nin salesforce
  195. Gui, 2:Add, Text, x10 y90,Enter the path for your MPR Deck`nTemplate
  196. Gui, 2:Add, Button, x240 y150 w100 h50, Browse
  197. Gui, 3: +LastFound +Resize +OwnDialogs
  198. Gui, 3:Add, ActiveX, w510 h600 x0 y0 vWB hwndATLWinHWND, Shell.Explorer
  199. WB.silent := true
  200. IOleInPlaceActiveObject_Interface:="{00000117-0000-0000-C000-000000000046}"
  201. pipa := ComObjQuery(WB, IOleInPlaceActiveObject_Interface)
  202. OnMessage(WM_KEYDOWN:=0x0100, "WM_KEYDOWN")
  203. OnMessage(WM_KEYUP:=0x0101, "WM_KEYDOWN")
  204. GuiControl,,TemplateMPR,1                   ;Let's default the radio button to Template MPR. Even if its not set we'll use that by default, but let's cue in the user
  205. return
  206. GuiClose:                                   ;Click the X button in the top corner to close App
  207. ExitApp
  208.  
  209. ;**************************************************************************************Begin Button/Gui Control**************************************************************************************
  210.  
  211. 2ButtonBrowse:
  212. FileSelectFile,MPRPathBrowser,1                         ;Launch the filebrowser. Can't find a way to pass the path between this and the save button so we'll pass it to the clipboard for now.
  213. ClipSave=%ClipBoard%                                    ;save old clipboard contents
  214. Clipboard=%MPRPathBrowser%                              ;send file browser path to clipboard
  215. ;***********************
  216. ;TODO
  217. ;I had to pass this to the clipboard to get it to go between buttons, find a way around this
  218. ;***********************
  219. return
  220.  
  221. 2ButtonSaveSettings:
  222. Gui, submit, NoHide
  223. newSFName=%SFNameTextBox%`n                             ;Pull the var from the SFname textbox, add a new line at the end
  224. newMPRPath=%ClipBoard%`n                                ;^same but with MPRPath
  225. FileDelete,%settingsPath%                               ;Delete exisiting settings file
  226. FileAppend,SFname=%newSFName%,%settingsPath%            ;put in the new value from the txtBox. prefix it with SFname= so our #include can pick it up
  227. FileAppend,MPRPath=%newMPRPath%,%settingsPath%          ;^same but with MPRPath
  228. Clipboard=%ClipSave%                                    ;Restore clipboard. Why can I pass this through the buttons but not a var?
  229. MsgBox, Settings Saved`,Reloading application to catch new settings     ;alert user
  230. Reload                                                  ;Refresh application so user will see changed settings.
  231. return 
  232.  
  233. 2ButtonCloseSettings:                                   ;Hides the settings gui
  234. Gui, submit,NoHide             
  235. Gui, 2:hide
  236. return
  237.  
  238. ButtonOpenMPRDashboard:
  239. MPRDashboardURL = https://dealertrack-production.my.salesforce.com/01Z0e000000UIsl
  240. run chrome.exe %MPRDashboardURL%
  241. return
  242.  
  243. ButtonGrabMPRs:
  244. Gui,Submit,NoHide
  245. checkit=%AccountSelector%
  246.  
  247. GrabMPRs(checkit)
  248.  
  249.  
  250. ButtonStartMPRLoop:
  251. breakLoop=0                                         ;Set breakLoop to 0, user will use ALT + END to end the loop, that hotkey sets breakloop to 1.
  252. Gui, Submit, NoHide  ; Save the input from the user to each control's associated variable.
  253. ServiceID = %AccountSelector%           ;Collect Service account ID for script from listBox
  254. MsgBox,Starting your MPR Loop from %ServiceID%, When you complete the MPR Preview, press PAGE DOWN on your keyboard to automatically start the next one. Hold ALT and press the END key a couple times on your keyboard to stop the loop.
  255. Loop{                                               ;Start up our loop! First, we'll check if breakLoop is one to see if we should continue
  256.     if(breakLoop = 1)
  257.     {
  258.         break
  259.     }
  260. Gui,Submit,NoHide
  261. ServiceID = %AccountSelector%           ;Collect Service account ID for script from listBox
  262. execSummaryURL=https://apps.dealer.com/analytics/as/%ServiceID%/%ServiceID%-admin/report/executive-summary?endDate=%LMmonthEnd%&startDate=%LMmonthStart%            ;set executive summary for account to last month
  263. admiralURL=http://admiral.dealer.com/#/accounts/%ServiceId%?endDate=%LMmonthEnd%&startDate=%LMmonthStart%                                                   ;set admirial to last month
  264. ClipSave = %Clipboard%
  265.  
  266. if(customMPR=1)                                     ;Check the MPR type!
  267. {
  268.     FileSelectFile,MPRPath,1
  269. }
  270. else
  271. {
  272.     MPRPath=%MPRPath%
  273. }
  274. run outlook.exe /c ipm.note /a "%MPRPath%" /m %ServiceID%&subject=MPR`%20Preview`%20%thisMonthFull%     ;Open email, use account ID as the contact group in the TO field.
  275. Sleep, 2000
  276. Clipboard = %emailTemplate%         ;Load our template back into the clipboard.
  277. Send ^v     ;Paste contents from our notes doc into our email, then we'll restore the old clipboard so no one notices what we did.
  278. Sleep, 500
  279. Send ^{Home}
  280. Sleep, 500  ;add a moment for clipboard to paste before we restore it
  281. Clipboard = %ClipSave% ; Restore Clipboard
  282. run chrome.exe %execSummaryURL% %admiralURL%                                                                                                                    ;Open chrome with 2 active tabs above
  283. KeyWait,PgDn,D                                  ;We're waiting for the user to press down the PAGE DOWN button to continue. Tip: the ",D" stands for DOWN
  284. WinActivate, MPR Preview Generator              ;Activate our window, it's probably minimized right now.
  285. GuiControl, Focus,AccountSelector                       ;Focus on the list box
  286. Send,{Down}                                     ;Send the down arrow key to select the next account
  287. continue                                        ;Iterate our loop!
  288. ;***********************
  289. ;TODO
  290. ;This needs to be a function as well
  291. ;***********************
  292. }
  293.  
  294. return
  295.  
  296. !END::                                                  ;Setup the END key to break our loop above
  297.     breakLoop = 1
  298.     return
  299.  
  300.  
  301. ButtonEditSettings:                                     ;Launch settings gui
  302. Gui, Submit, NoHide
  303. Gui, 2:show, w500 h500,Edit Settings
  304. return
  305.  
  306. ButtonBulkAccountEdit:                                                                      ;Allow users to directly edit their account's text file. We'll move this to a CSV later so we can pull additional account info.
  307. run, %AccountListPath%
  308. Process WaitClose,notepad.exe
  309. MsgBox,Reloading application to get new Account List
  310. Reload
  311. ;***********************
  312. ;TODO
  313. ;Switch to a CSV
  314. ;***********************
  315. return
  316.  
  317. ButtonEditTemplate:                                                                         ;Allow users to edit their Word Doc containing the email template directly.
  318. run %emailTemplatePath%                                                                     ;Open word
  319. Process WaitClose, WINWORD.EXE                                                              ;Watch the word process in the task manager, when it closes, we'll reload the app so the new template is catched.
  320. MsgBox, Reloading application to get new template                                           ;alert user
  321. Reload                                                                             
  322. return
  323.  
  324. ButtonDeleteAccount:                                                                        ;Users will select the account to remove from the ListBox and click here, removing account's string from the text file. <-
  325. Gui, Submit, NoHide  ; Save the input from the user to each control's associated variable.  ;                                       Watch out for those carriage returns `r`n, they were crazy difficult to get rid of.
  326. ListVar=                                                    ;empty ListVar so it doesn't duplicate accounts on rebuild of ListBox.
  327. ServiceID = %AccountSelector%                                   ;Collect Service account ID for script from listBox
  328.  
  329. FileRead, accountList, %accountListPath%        ;Read the account list and load it into memory for manipulation.
  330. StringReplace, accountList,accountList,%serviceID%,,All     ;Replace the ServiceID with empty String
  331. MsgBox, %ServiceID% has been removed from Account List.     ;Notify user of replacement
  332. FileDelete, %AccountListPath%                               ;No easy way in AHK to replace a string, so we have to delete existing file.
  333. FileAppend, %accountList%, %AccountListPath%                ;We append the account list sans deleted string from memory into a new copy of the file, our user doesn't know that just happened.
  334. Loop,Read,%AccountListPath%                                 ;We're looking for those damn blank lines and removing them to keep our list clean, blank lines are found with `r`n.
  335.    If (A_LoopReadLine!="")
  336.       newText.=A_LoopReadLine "`r`n" C
  337.     {
  338.         FileDelete,%AccountListPath%
  339.         FileAppend,%newText%,%AccountListPath%
  340.     }
  341. GuiControl,, AccountSelector, |                                 ;Empty the existing values in ListBox from memory, prep for redraw of box via the below loop.
  342. ListVar2 =                                                  ;Set var to load from loop as empty.
  343. Loop,Read,%accountListPath%             ;Re-read the edited accounts file and load it into memory.
  344.     ListVar2 .= (A_Index == 1 ? "" : "|") . A_LoopReadLine
  345. GuiControl,,AccountSelector,%ListVar2%                          ;Since the ListBox is already added, we use GuiControl to update the box.
  346. return
  347.  
  348. ButtonAddAccount:                                                                           ;Users click this button and an input box will come up, asking them to input new service ID. Later, this will be a second gui with <-
  349. ListVar=                                                                                    ;                                                                                               more boxes saved to a settings file.
  350. GuiControl,, AccountSelector, |         ;Clear ListBox for update
  351. InputBox, addAccountvar,Add Account,Add an account to your list    ;Popup our input box, store input in addAccountvar
  352. FileAppend,`n%addAccountvar% ,%accountListPath%     ;Add the serviceID to end of the txt file, in a new line.
  353. Loop,Read,%accountListPath%                     ;Re-read the account file to prep for ListBox Update.
  354.     ListVar .= (A_Index == 1 ? "" : "|") . A_LoopReadLine
  355. GuiControl,,AccountSelector,%ListVar%                                           ;Update ListBox
  356. return
  357.  
  358. ButtonWebPageOnly:                                                                          ;This will grab ServiceID from the Listbox, and only launch chrome, instead of also launching outlook
  359. Gui, Submit, NoHide  ; Save the input from the user to each control's associated variable.
  360. ServiceID = %AccountSelector%       ;Collect Service account ID for script from listBox
  361. execSummaryURL=https://apps.dealer.com/analytics/as/%ServiceID%/%ServiceID%-admin/report/executive-summary?endDate=%LMmonthEnd%&startDate=%LMmonthStart%            ;set executive summary for account to last month
  362. admiralURL=http://admiral.dealer.com/#/accounts/%ServiceID%?endDate=%LMmonthEnd%&startDate=%LMmonthStart%                                                   ;set admirial to last month
  363. run chrome.exe %execSummaryURL% %admiralURL%    ;Open Chrome with 2 tabs
  364. ;***********************
  365. ;TODO
  366. ;We're repeating this code, this should be a function
  367. ;***********************
  368. return
  369.  
  370. ButtonEmailOnly:
  371. Gui, Submit, NoHide  ; Save the input from the user to each control's associated variable.
  372. ServiceID = %AccountSelector%           ;Collect Service account ID for script from listBox
  373. ClipSave = %Clipboard%          ;Store clipboard in var
  374. if(customMPR=1)
  375. {
  376.     FileSelectFile,MPRPath,1
  377. }
  378. else
  379. {
  380.     MPRPath=%MPRPath%
  381. }
  382.  
  383. run outlook.exe /c ipm.note /a "%MPRPath%" /m %ServiceID%&subject=MPR`%20Preview`%20%thisMonthFull%&body=       ;Open email, use account ID as the contact group in the TO field.
  384. Sleep, 2000
  385. Clipboard = %emailTemplate%         ;Load our template back into the clipboard.
  386. Send ^v     ;Paste contents from our notes doc into our email, then we'll restore the old clipboard so no one notices what we did.
  387. Sleep, 500
  388. Send ^{Home}
  389. Sleep, 500  ;add a moment for clipboard to paste before we restore it
  390. Clipboard = %ClipSave% ; Restore Clipboard
  391. ;***********************
  392. ;TODO
  393. ;We're repeating this code, it should also be a function.
  394. ;***********************
  395. return
  396.  
  397. ButtonBeginMPRPreview:
  398. Gui, Submit, NoHide  ; Save the input from the user to each control's associated variable.
  399. ServiceID = %AccountSelector%           ;Collect Service account ID for script from listBox
  400. execSummaryURL=https://apps.dealer.com/analytics/as/%ServiceID%/%ServiceID%-admin/report/executive-summary?endDate=%LMmonthEnd%&startDate=%LMmonthStart%            ;set executive summary for account to last month
  401. admiralURL=http://admiral.dealer.com/#/accounts/%ServiceId%?endDate=%LMmonthEnd%&startDate=%LMmonthStart%                                                   ;set admirial to last month
  402. ClipSave = %Clipboard%
  403.  
  404. if(customMPR=1)
  405. {
  406.     FileSelectFile,MPRPath,1
  407. }
  408. else
  409. {
  410.     MPRPath=%MPRPath%
  411. }
  412. run outlook.exe /c ipm.note /a "%MPRPath%" /m %ServiceID%&subject=MPR`%20Preview`%20%thisMonthFull%     ;Open email, use account ID as the contact group in the TO field.
  413. Sleep, 1000
  414. Clipboard = %emailTemplate%         ;Load our template back into the clipboard.
  415. Send ^v     ;Paste contents from our notes doc into our email, then we'll restore the old clipboard so no one notices what we did.
  416. Sleep, 1000
  417. Send ^{Home}
  418. Sleep, 1000 ;add a moment for clipboard to paste before we restore it
  419. Clipboard = %ClipSave% ; Restore Clipboard
  420. run chrome.exe %execSummaryURL% %admiralURL%                                                                                                                    ;Open chrome with 2 active tabs above
  421.  
  422. ;***********************
  423. ;TODO
  424. ;This needs to be a function as well
  425. ;***********************
  426. return
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436. ;**************************************************************************************Future Feature List**************************************************************************************
  437. ;Refactor Code to use functions so things look all pretty and the like
  438. ;Our reloads for new settings depend on user closing all process of that type. If they have two notepads open we don't reload the script. Lets grab the actual process ID and reload with that specific one is closed instead
  439. ;In emailOnly & MPR Preview, find another way to get the emailTemplate in there other than pasting it from the clipboard, it feels dirty.
  440. ;Use the AHK mini browser to open a report for the new MPRS and get their IDs. Users will be able to login and it will autodownload and scrape the page.
  441. ;MPR Dashboard in salesforce that users can click on their name in a filter box
  442. ;https://dealertrack-production.my.salesforce.com/00T/e?what_id=5000e00001ETDxY&retURL=%2F5000e00001ETDxY&RecordType=012320000001Ewh&ent=Task&tsk5=test%20call&00N60000001maZs=Call%20-%20Outbound&00N60000002HjXN=Schedule%20Meeting&tsk12=Completed&tsk4=9/29/2017&tsk13=Normal
  443. ;^One click link to log a call, all we need to know is the MPR case's ID.
  444. ;ref:_00D30JqC._5000e1ETDxY:ref
  445. ;00D30 is ORG ID
  446. ;JqC._ = a random string of chars it looks like.
  447. ;5000e1ETDxY = portion of case id
  448. ;^use above ex to auto attach an email to an MPR
  449. ;Use our browser to download the executive summary PDF
  450. ;***********************SUPER FEATURES***********************
  451. ;Using COM, open a browser and login to SF.
  452. ;Using COM, be able to log a call
  453. ;Using COM, be able to open or close a case/MPR
  454. ;Using COM, download a flat file for the user containing their accounts, and the MPRs that exist on those accounts. We can loop through that and save it to a settings file, that way the user can click a button and launch chrome to that MPR
  455. ;
  456. ;***********************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement