Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;--------------------------------------------------------------------------------------------------------------------------------------------------------
- ;--------------------------------------------------------------------------------------------------------------------------------------------------------
- ;
- ; AHK V2 VERSION
- ;
- ;--------------------------------------------------------------------------------------------------------------------------------------------------------
- ;--------------------------------------------------------------------------------------------------------------------------------------------------------
- ~^w::
- /*
- Title := WinGetTitle(WinTitle, WinText, ExcludeTitle, ExcludeText)
- WinTitle Type: String A window title or other criteria identifying the target window. See WinTitle.
- 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.
- ExcludeTitle Type: String Windows whose titles include this value will not be considered.
- ExcludeText Type: String Windows whose text include this value will not be considered.
- ________________________________________
- | WinTitle | Matching Behaviour |
- |---------------|------------------------|
- | A | The Active Window |
- | ahk_class | Window Class |
- | ahk_id | Unique ID/HWND |
- | ahk_pid | Process ID |
- | ahk_exe | Process Name/Path |
- | ahk_group | Window Group |
- | | Multiple Criteria |
- | (All empty) | Last Found Window |
- ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
- */
- this_Title := WinGetTitle("A") ;WinGetActiveTitle, this_Title
- /*
- ProcessName := WinGetProcessName(WinTitle, WinText, ExcludeTitle, ExcludeText)
- WinTitle Type: String A window title or other criteria identifying the target window. See WinTitle.
- 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.
- ExcludeTitle Type: String Windows whose titles include this value will not be considered.
- ExcludeText Type: String Windows whose text include this value will not be considered.
- */
- this_pName := WinGetProcessName(this_Title) ;WinGet, this_pName, ProcessName, %this_Title%
- switch (this_pName)
- {
- case "dwgviewr.exe":
- {
- if (this_Title != "Autodesk DWG TrueView 2019 - [Start]")
- Send "!flc"
- else PostMessage 0x112, 0xF060,,, this_Title ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
- return
- }
- case "ReCap.exe":
- {
- PostMessage 0x112, 0xF060,,, this_Title ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
- sleep 120
- Click "201 168"
- return
- }
- case "excel.exe", "WINWORD.EXE", "PDFXEdit.exe", "GPDFDirect.exe", "GaaihoDoc.exe":
- {
- switch this_Title {
- case "Excel", "Word", "PDF-XChange Editor", "Nuance PDF Create Assistant", "PDF Converter Enterprise 8.2":
- PostMessage 0x112, 0xF060,,, this_Title ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
- }
- return
- }
- case "OUTLOOK.exe":
- {
- if (this_Title = "Inbox - jake.nixon@levingston.com - Outlook") {
- Result := MsgBox("Close Outlook?",, 4)
- if (Result = "Yes")
- PostMessage 0x112, 0xF060,,, this_Title ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
- }
- else PostMessage 0x112, 0xF060,,, this_Title ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
- return
- }
- }
- return
- ^j::
- getTitle: ;+++++++++++++++++++++++++++++++
- WinGetTitle, myFile, ahk_PID %myPID%
- StringTrimRight, myFile, myFile, 10
- StringTrimRight, myTitle, myFile, 4
- WinMenuSelectItem, ahk_PID %myPID%, , File, Open
- WinWaitActive, Open
- ControlGetText, myPath , ToolbarWindow322, Open
- myPath := substr(myPath, 10)
- WinClose, Open
- return ;------------------------------
- ;PDF Converter Title Format
- ;01395-017-1-01-01-E411 (Sht. 1 of 9).pdf - "PDF Converter Enterprise 8.2"
- /*
- ^!r::
- Reload
- Sleep 1000 ; If successful, the reload will close this instance during the Sleep, so the line below will never be reached.
- Result := MsgBox("The script could not be reloaded. Would you like to open it for editing?",, 4)
- if Result = "Yes"
- Edit
- return
- ^!t::
- FocusedHwnd := ControlGetFocus("A")
- FocusedClassNN := ControlGetClassNN(FocusedHwnd)
- MsgBox 'Control with focus = {Hwnd: ' FocusedHwnd ', ClassNN: "' FocusedClassNN '"}'
- MsgBox "The active window's class is " WinGetClass("A")
- for n, ctrl in WinGetControls("A")
- {
- Result := MsgBox("Control #" n " is '" ctrl "'. Continue?",, 4)
- if (Result = "No")
- break
- }
- */
- /*
- =========================================
- Miscellaneous Functions
- =========================================
- >>>>>>>>>>> Standard Message Box <<<<<<<<<<<
- MsgBox, The active window is "%this_Title%".
- >>>>>>>>>>> Append Text File <<<<<<<<<<<
- Proto: FileAppend , Text, Filename, Encoding
- Examp: FileAppend, `n%this_Title%, TitleOutput.txt
- >>>>>>>>>>> Get Mouse Position <<<<<<<<<<<
- MouseGetPos xpos, ypos
- MsgBox "The cursor is at X" xpos " Y" ypos
- */
- ;--------------------------------------------------------------------------------------------------------------------------------------------------------
- ;--------------------------------------------------------------------------------------------------------------------------------------------------------
- ;
- ; AHK V1 VERSION
- ;
- ;--------------------------------------------------------------------------------------------------------------------------------------------------------
- ;--------------------------------------------------------------------------------------------------------------------------------------------------------
- /*
- ~^w::
- ;^w::
- WinGetActiveTitle, this_Title
- WinGet, this_pName, ProcessName, %this_Title%
- exeName := this_pName
- switch exeName
- {
- case "dwgviewer.exe":
- if (this_Title != "Autodesk DWG TrueView 2019 - [Start]") Send, !flc
- else PostMessage, 0x112, 0xF060,,, %this_Title%, ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
- case "excel.exe", "WINWORD.EXE", "PDFXEdit.exe":
- switch this_Title {
- case "Excel", "Word", "PDF-XChange Editor":
- PostMessage, 0x112, 0xF060,,, %this_Title%, ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
- default: return
- }
- case "OUTLOOK.exe":
- if (this_Title != "Inbox - jake.nixon@levingston.com - Outlook") PostMessage, 0x112, 0xF060,,, %this_Title%, ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
- }
- return
- ;MsgBox, pName %this_pName% Exe %exeName%
- ; Close program if all documents are closed
- if (this_pName = "dwgviewr.exe" || this_pName = "excel.exe" || this_pName = "WINWORD.EXE" || this_pName = "PDFXEdit.exe") {
- if (this_Title = "Excel" || this_Title = "Word" || this_Title = "PDF-XChange Editor" || this_Title = "Autodesk DWG TrueView 2019 - [Start]") {
- PostMessage, 0x112, 0xF060,,, %this_Title%, ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
- }
- }
- case "excel.exe":
- if (this_Title = "Excel") PostMessage, 0x112, 0xF060,,, %this_Title%, ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
- else break
- case "WINWORD.EXE":
- if (this_Title = "Word") PostMessage, 0x112, 0xF060,,, %this_Title%, ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
- else break
- case "PDFXEdit.exe":
- if (this_Title = "PDF-XChange Editor") PostMessage, 0x112, 0xF060,,, %this_Title%, ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
- else break
- }
- Don't close outlook
- if (this_pName = "OUTLOOK.EXE") {
- if (this_Title != "Inbox - jake.nixon@levingston.com - Outlook") {
- PostMessage, 0x112, 0xF060,,, %this_Title%, ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
- }
- }
- ~^f::
- WinGetActiveTitle, this_Title
- WinGet, this_pName, ProcessName, %this_Title%
- if (this_Title = "Autodesk DWG TrueView 2019 - [Start]") {
- MsgBox, 1st If Condition True
- }
- if (this_Title != "Autodesk DWG TrueView 2019 - [Start]") {
- MsgBox, 2nd If Condition True
- }
- MsgBox, Exe: "%this_pName%" Title: "%this_Title%"
- else if (this_pName = "dwgviewr.exe" || this_pName = "excel.exe" || this_pName = "WINWORD.EXE" || this_pName = "PDFXEdit.exe") {
- if (this_Title = "Excel" || "Word" || this_Title = "PDF-XChange Editor" || this_Title = "Autodesk DWG TrueView 2019 - [Start]") {
- PostMessage, 0x112, 0xF060,,, %this_Title%, ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
- }
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement