Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;--------------------------------------------------------------------------------------------------------------------------------------------------------
  2. ;--------------------------------------------------------------------------------------------------------------------------------------------------------
  3. ;
  4. ;                                                                   AHK V2 VERSION
  5. ;
  6. ;--------------------------------------------------------------------------------------------------------------------------------------------------------
  7. ;--------------------------------------------------------------------------------------------------------------------------------------------------------
  8.  
  9. ~^w::
  10.  
  11.     /*
  12.     Title := WinGetTitle(WinTitle, WinText, ExcludeTitle, ExcludeText)
  13.     WinTitle       Type: String A window title or other criteria identifying the target window. See WinTitle.
  14.     WinText        Type: String If present, this parameter must be a substring from a single text element of the target window (as revealed by the included Window Spy utility). Hidden text elements are detected if DetectHiddenText is ON.
  15.     ExcludeTitle     Type: String   Windows whose titles include this value will not be considered.
  16.     ExcludeText  Type: String   Windows whose text include this value will not be considered.
  17.     ________________________________________                                                                          
  18.     |   WinTitle    |   Matching Behaviour   |                                                                          
  19.     |---------------|------------------------|                                                                          
  20.     |   A           |   The Active Window    |                                                                          
  21.     |   ahk_class   |   Window Class         |                                                                          
  22.     |   ahk_id      |   Unique ID/HWND       |                                                                          
  23.     |   ahk_pid     |   Process ID           |                                                                          
  24.     |   ahk_exe     |   Process Name/Path    |                                                                          
  25.     |   ahk_group   |   Window Group         |                                                                          
  26.     |               |   Multiple Criteria    |                                                                          
  27.     |   (All empty) |   Last Found Window    |                                                                          
  28.     ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯                                                                            
  29.     */
  30.    
  31.     this_Title := WinGetTitle("A")      ;WinGetActiveTitle, this_Title
  32.    
  33.     /*
  34.     ProcessName := WinGetProcessName(WinTitle, WinText, ExcludeTitle, ExcludeText)
  35.     WinTitle       Type: String A window title or other criteria identifying the target window. See WinTitle.
  36.     WinText        Type: String If present, this parameter must be a substring from a single text element of the target window (as revealed by the included Window Spy utility). Hidden text elements are detected if DetectHiddenText is ON.
  37.     ExcludeTitle     Type: String   Windows whose titles include this value will not be considered.
  38.     ExcludeText  Type: String   Windows whose text include this value will not be considered.
  39.     */
  40.    
  41.     this_pName := WinGetProcessName(this_Title)      ;WinGet, this_pName, ProcessName, %this_Title%
  42.    
  43.     switch (this_pName)
  44.     {
  45.         case "dwgviewr.exe":
  46.         {
  47.             if (this_Title != "Autodesk DWG TrueView 2019 - [Start]")
  48.                 Send "!flc"
  49.             else PostMessage 0x112, 0xF060,,, this_Title  ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
  50.             return
  51.         }
  52.        
  53.         case "ReCap.exe":
  54.         {
  55.             PostMessage 0x112, 0xF060,,, this_Title  ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
  56.             sleep 120
  57.             Click "201 168"
  58.             return
  59.         }
  60.        
  61.         case "excel.exe", "WINWORD.EXE", "PDFXEdit.exe", "GPDFDirect.exe", "GaaihoDoc.exe":
  62.         {
  63.             switch this_Title {
  64.                 case "Excel", "Word", "PDF-XChange Editor", "Nuance PDF Create Assistant", "PDF Converter Enterprise 8.2":
  65.                     PostMessage 0x112, 0xF060,,, this_Title  ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
  66.             }
  67.             return
  68.         }
  69.        
  70.         case "OUTLOOK.exe":
  71.         {
  72.             if (this_Title = "Inbox - jake.nixon@levingston.com - Outlook") {
  73.                 Result := MsgBox("Close Outlook?",, 4)
  74.                 if (Result = "Yes")
  75.                     PostMessage 0x112, 0xF060,,, this_Title  ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
  76.             }
  77.             else PostMessage 0x112, 0xF060,,, this_Title  ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
  78.             return
  79.         }
  80.     }
  81. return
  82.  
  83.  
  84. ^j::
  85.  
  86. getTitle: ;+++++++++++++++++++++++++++++++
  87. WinGetTitle, myFile, ahk_PID %myPID%
  88. StringTrimRight, myFile, myFile, 10
  89. StringTrimRight, myTitle, myFile, 4
  90. WinMenuSelectItem, ahk_PID %myPID%, , File, Open
  91. WinWaitActive, Open
  92. ControlGetText, myPath , ToolbarWindow322, Open
  93. myPath := substr(myPath, 10)
  94. WinClose, Open
  95. return ;------------------------------
  96.  
  97. ;PDF Converter Title Format
  98. ;01395-017-1-01-01-E411 (Sht. 1 of 9).pdf - "PDF Converter Enterprise 8.2"
  99.  
  100.  
  101. /*
  102. ^!r::
  103. Reload
  104. Sleep 1000 ; If successful, the reload will close this instance during the Sleep, so the line below will never be reached.
  105. Result := MsgBox("The script could not be reloaded. Would you like to open it for editing?",, 4)
  106. if Result = "Yes"
  107.     Edit
  108. return
  109.  
  110. ^!t::
  111. FocusedHwnd := ControlGetFocus("A")
  112. FocusedClassNN := ControlGetClassNN(FocusedHwnd)
  113. MsgBox 'Control with focus = {Hwnd: ' FocusedHwnd ', ClassNN: "' FocusedClassNN '"}'
  114. MsgBox "The active window's class is " WinGetClass("A")
  115. for n, ctrl in WinGetControls("A")
  116. {
  117.     Result := MsgBox("Control #" n " is '" ctrl "'. Continue?",, 4)
  118.     if (Result = "No")
  119.         break
  120. }
  121. */
  122.  
  123. /*
  124. =========================================
  125.           Miscellaneous Functions        
  126. =========================================
  127.  
  128. >>>>>>>>>>>  Standard Message Box  <<<<<<<<<<<
  129. MsgBox, The active window is "%this_Title%".
  130.  
  131.  
  132. >>>>>>>>>>>  Append Text File  <<<<<<<<<<<
  133. Proto:  FileAppend , Text, Filename, Encoding
  134. Examp:  FileAppend, `n%this_Title%, TitleOutput.txt
  135.  
  136. >>>>>>>>>>>  Get Mouse Position  <<<<<<<<<<<
  137. MouseGetPos xpos, ypos
  138. MsgBox "The cursor is at X" xpos " Y" ypos
  139.  
  140.  */
  141.  
  142.  
  143.  
  144.  
  145. ;--------------------------------------------------------------------------------------------------------------------------------------------------------
  146. ;--------------------------------------------------------------------------------------------------------------------------------------------------------
  147. ;
  148. ;                                                                   AHK V1 VERSION
  149. ;
  150. ;--------------------------------------------------------------------------------------------------------------------------------------------------------
  151. ;--------------------------------------------------------------------------------------------------------------------------------------------------------
  152.  
  153.         /*
  154.  
  155. ~^w::
  156. ;^w::
  157. WinGetActiveTitle, this_Title
  158. WinGet, this_pName, ProcessName, %this_Title%
  159. exeName := this_pName
  160.  
  161. switch exeName
  162. {
  163.     case "dwgviewer.exe":
  164.         if (this_Title != "Autodesk DWG TrueView 2019 - [Start]") Send, !flc
  165.         else PostMessage, 0x112, 0xF060,,, %this_Title%,  ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
  166.        
  167.     case "excel.exe", "WINWORD.EXE", "PDFXEdit.exe":
  168.         switch this_Title {
  169.             case "Excel", "Word", "PDF-XChange Editor":
  170.                 PostMessage, 0x112, 0xF060,,, %this_Title%,  ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
  171.             default: return
  172.         }
  173.     case "OUTLOOK.exe":
  174.         if (this_Title != "Inbox - jake.nixon@levingston.com - Outlook") PostMessage, 0x112, 0xF060,,, %this_Title%,  ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
  175. }
  176. return
  177. ;MsgBox, pName %this_pName% Exe %exeName%
  178.  
  179. ; Close program if all documents are closed
  180.  
  181. if (this_pName = "dwgviewr.exe" || this_pName = "excel.exe" || this_pName = "WINWORD.EXE" || this_pName = "PDFXEdit.exe") {
  182.     if (this_Title = "Excel" || this_Title = "Word" || this_Title = "PDF-XChange Editor" || this_Title = "Autodesk DWG TrueView 2019 - [Start]") {
  183.         PostMessage, 0x112, 0xF060,,, %this_Title%,  ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
  184.     }
  185. }
  186.  
  187.     case "excel.exe":
  188.         if (this_Title = "Excel") PostMessage, 0x112, 0xF060,,, %this_Title%,  ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
  189.         else break
  190.     case "WINWORD.EXE":
  191.         if (this_Title = "Word") PostMessage, 0x112, 0xF060,,, %this_Title%,  ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
  192.         else break
  193.     case "PDFXEdit.exe":
  194.         if (this_Title = "PDF-XChange Editor") PostMessage, 0x112, 0xF060,,, %this_Title%,  ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
  195.         else break
  196. }
  197.  
  198.  Don't close outlook
  199.  if (this_pName = "OUTLOOK.EXE") {
  200.     if (this_Title != "Inbox - jake.nixon@levingston.com - Outlook") {
  201.         PostMessage, 0x112, 0xF060,,, %this_Title%,  ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
  202.     }
  203.  
  204. }
  205.  
  206. ~^f::
  207. WinGetActiveTitle, this_Title
  208. WinGet, this_pName, ProcessName, %this_Title%
  209. if (this_Title = "Autodesk DWG TrueView 2019 - [Start]") {
  210.     MsgBox, 1st If Condition True
  211. }
  212. if (this_Title != "Autodesk DWG TrueView 2019 - [Start]") {
  213.     MsgBox, 2nd If Condition True
  214. }
  215. MsgBox, Exe: "%this_pName%" Title: "%this_Title%"
  216.  
  217.  
  218. else if (this_pName = "dwgviewr.exe" || this_pName = "excel.exe" || this_pName = "WINWORD.EXE" || this_pName = "PDFXEdit.exe") {
  219.     if (this_Title = "Excel" || "Word" || this_Title = "PDF-XChange Editor" || this_Title = "Autodesk DWG TrueView 2019 - [Start]") {
  220.         PostMessage, 0x112, 0xF060,,, %this_Title%,  ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
  221.     }
  222. }
  223.  
  224.         */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement