djvj icon

RLUI window detect

djvj | PRO | 04/17/16 05:36:07 AM UTC | 0 ⭐ | 567 👁️ | Never ⏰ | []
text |

4.81 KB

|

None

|

0 👍

/

0 👎

#Include, %A_ScriptDir%\Lib\Classes\Util\MiscUtils.ahk
#Include, %A_ScriptDir%\Lib\Classes\Util\Environment\StringUtils.ahk
#Include, %A_ScriptDir%\Lib\Classes\Util\File\File.ahk
#Include, %A_ScriptDir%\Lib\Classes\Util\File\Process.ahk
#Include, %A_ScriptDir%\Lib\Classes\Util\UI\Control.ahk
#Include, %A_ScriptDir%\Lib\Classes\Util\UI\Window.ahk
#Include, %A_ScriptDir%\Lib\Classes\Util\UI\WindowTitle.ahk
#Include, %A_ScriptDir%\Module Extensions\VA_Extension.ahk
#Include, %A_ScriptDir%\Module Extensions\VA.ahk
Hotkey, Esc, closescript
 DetectHiddenWindows, on
FEPath := "D:\RocketLauncher\RocketLauncherUI\RocketLauncherUI.exe"
FEName := "ahk_exe RocketLauncherUI.exe"
FrontEndProcess := new Process(FEPath)
 ; Storing the FE's x,y,width, & height to restore it on exit if an application changed it going fullscreen
FrontEndProcess.Process("Exist")	; store PID in object
If FrontEndProcess.PID {	; If the FE is running, store the position and size
	RLLog.Info("Main - Detected " . FrontEndProcess.FileName . " is currently running")
	; FrontEndWindow := new Window(new WindowTitle("","","","",FrontEndProcess.PID))	; instantiate Front End window object from PID
	FrontEndWindow := new Window(new WindowTitle("","",FrontEndProcess.FileFullPath))	; instantiate Front End window object from PID
	FrontEndWindow.Get("ID")
	; MsgBox % FrontEndWindow.ID
	FrontEndWindow.WinTitle.PID := ""
	; FrontEndWindow.WinTitle.ID := FrontEndWindow.ID
	FrontEndWindow.GetPos(frontendX, frontendY, frontendW, frontendH)
	RLLog.Info("Main - " . FrontEndProcess.FileName . " coordinates are x" . FrontEndWindow.X . " y" . FrontEndWindow.Y . " w" . FrontEndWindow.W . " h" . FrontEndWindow.H)
} Else
	RLLog.Info("Main - " . FrontEndProcess.FileName . " is not currently running")
 titlename := FrontEndWindow.GetTitle(0)
classname := FrontEndWindow.GetClass(0)
tpid := "ahk_pid " . FrontEndWindow.PID
; class := "ahk_class " . class
; tid := "ahk_id " . WinID
; WinGet, WinID, ID, %tpid%
; WinGet, WinPID, PID, %tpid%
; WinGetClass, class, %tpid%
; WinGetTitle, title, %tpid%
; WinGetPos, X, Y, Width, Height, %tpid%
WinGet, WinID, ID, RocketLauncherUI
WinGet, WinPID, PID, RocketLauncherUI
WinGetClass, class, RocketLauncherUI
WinGetTitle, title, RocketLauncherUI
WinGetPos, X, Y, Width, Height, RocketLauncherUI
TestWindow := new Window(new WindowTitle("RocketLauncherUI"))
TestWindow.Get("ID")
TestWindow.Get("PID")
TestWindow.GetPos(frontendX, frontendY, frontendW, frontendH)
testtitlename := TestWindow.GetTitle(0)
testclassname := TestWindow.GetClass(0)
MsgBox % "OLD:`nX: " . X . "`nY: " . Y . "`nW: " . Width . "`nH: " . Height . "`nWinPID: " . WinPID . "`nWinID: " . WinID . "`nTitle: " . title . "`nClass: " . class . "`n`nNEW`nX: " . FrontEndWindow.X . "`nY: " . FrontEndWindow.Y . "`nW: " . FrontEndWindow.W . "`nH: " . FrontEndWindow.H . "`nFrontEndProcess.PID: " . FrontEndProcess.PID . "`nFrontEndWindow.ID: " . FrontEndWindow.ID . "`nFrontEndWindow.Title: " . titlename . "`nFrontEndWindow.Class: " . classname . "`n`nTEST`nX: " . TestWindow.X . "`nY: " . TestWindow.Y . "`nW: " . TestWindow.W . "`nH: " . TestWindow.H . "`nFrontEndProcess.PID: " . TestWindow.PID . "`nFrontEndWindow.ID: " . TestWindow.ID . "`nFrontEndWindow.Title: " . testtitlename . "`nFrontEndWindow.Class: " . testclassname
ExitApp
 ScriptError(txt,a="") {
	msgbox % txt
}
 GetFullName( fn ) {
; http://msdn.microsoft.com/en-us/library/Aa364963
	; Static buf, i		; removed i from static because it was always using HS's root folder as the working dir which threw off all relative paths
	Static buf
	; If !i
		i := VarSetCapacity(buf, 512)
	DllCall("GetFullPathNameA", "str", fn, "uint", 512, "str", buf, "str*", 0)
	Return buf
}
GetOSVersion() {
    VarSetCapacity(v,148), NumPut(148,v)
    DllCall("GetVersionEx", "uint", &v)
    ; Return formatted version string similar to A_AhkVersion.
    ; Assume build number will never be more than 4 characters.
    return    NumGet(v,4) ; major
        . "." NumGet(v,8) ; minor
        . "." SubStr("0000" NumGet(v,12), -3) ; build
}
 closescript:
ExitApp
  ReStartExplorer( WaitSecs = 10 ) {   ; SKAN, CD:07-Dec-2013 LM:14-Dec-2014 | goo.gl/UnS2rl
 ;  Credit: Gracefully Exit Explorer (Programmatically) - Stack Overflow   | goo.gl/tAA9HY
 ;  Thanks to chaz - http://ahkscript.org/boards/viewtopic.php?p=7099#p7099
  If A_OSVersion not in WIN_XP,WIN_VISTA,WIN_7
  Return 0, ErrorLevel := 1
  If ( A_OSVersion = "WIN_XP" ) {  
  WinGet, ShellPID, PID,     ahk_class Progman
  PostMessage, 0x012, 0, 0,, ahk_class Progman        ; WM_QUIT = 0x12
 } Else {
  WinGet, ShellPID, PID,     ahk_class Shell_TrayWnd
  PostMessage, 0x5B4, 0, 0,, ahk_class Shell_TrayWnd  ; WM_USER + 0x1B4
 }    
  Process, WaitClose, %ShellPID%, %WaitSecs%
 IfEqual, ErrorLevel, 0, Run %A_WinDir%\explorer.exe
Return !ErrorLevel
}

Comments