- Offizieller Beitrag
Hi,
wenn ihr guinness "SciTE Jump" benutzt, stört euch vielleicht auch, dass das Fenster als eigenständige Anwendung erscheint und nicht an SciTE andockt.
Ich habe jetzt eine kleine Anwendung geschrieben, die überwacht ob SciTE mit/ohne "SciTE Jump" läuft und entsprechend die Fenster nebeneinander anordnet.
"SciTE Jump" kann links oder rechts neben SciTE angeordnet werden, die gewünschte Fensterbreite ist voreinstellbar, ebenso kann gewählt werden, dass "SciTE Jump" automatisch bei Start von SciTE mitgestartet wird.
Geregelt wird das praktischerweise über Einträge in "SciTEUser.properties"
#~ Settings für "SciTE Jump"
#~ Automatisch mit SciTE starten 0/1 (ohne Angabe: 0)
scite.jump.autostart=1
#~ Breite des "SciTE Jump" Fensters (ohne Angabe: 360)
scite.jump.width=
#~ Position des "SciTE Jump" Fensters (left/right, ohne Angabe: right)
scite.jump.pos=
Das Skript kompilieren und über Windows-Autostart mit ausführen.
Viel Spaß damit.
ArrangeJump.au3
;-- TIME_STAMP 2017-07-29 14:42:50 v 0.1
#cs Properties Values
scite.jump.autostart= no value == 0 (Default) /or 1
scite.jump.width= no value == 360 (Default) /or your value
scite.jump.pos= no value == right (Default) /or left
#ce
Opt("TrayIconHide", 1)
Global $SciteDefaultHome = StringRegExpReplace(RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoIt3Script\DefaultIcon', ''), '(.+)(Icons.+$)', '$1SciTE')
Global $iTBLeft, $iTBTop, $iTBRight, $iTBBottom, $aTB = _GetTaskbarPosition()
Global $iTBWidth = 0, $iTBHeight = 0, $iLeft = 0, $iTop = 0
$iTBLeft = $aTB[0]
$iTBTop = $aTB[1]
$iTBRight = $aTB[2]
$iTBBottom = $aTB[3]
If $iTBLeft = 0 And $iTBTop = 0 Then
If $iTBRight < $iTBBottom Then
$iTBWidth = $iTBRight
$iLeft = $iTBWidth
Else
$iTBHeight = $iTBBottom
$iTop = $iTBHeight
EndIf
ElseIf $iTBTop <> 0 Then
$iTBHeight = $iTBBottom - $iTBTop
Else
$iTBWidth = $iTBRight - $iTBLeft
EndIf
Global $iWidth = @DesktopWidth - $iTBWidth, $iHeight = @DesktopHeight - $iTBHeight
Global $hWndSciTE, $aJump, $hWndJump, $bSciTERuns = False, $bJumpRuns = False, $bArranged = False
Global $iSciTEState = 0 ; 0=closed/ 1=currently started/ 2=running
While True
; Fenster Handle SciTE
$hWndSciTE = WinGetHandle('[CLASS:SciTEWindow]')
If @error Then $hWndSciTE = 0
$bSciTERuns = IsHWnd($hWndSciTE) ? True : False
; Bedingung für Autostart Jump
If $iSciTEState = 1 And $bSciTERuns Then $iSciTEState = 2 ; SciTE läuft
If $iSciTEState = 0 And $bSciTERuns Then $iSciTEState = 1 ; SciTE wurde soeben gestartet
If Not $bSciTERuns Then $iSciTEState = 0 ; SciTE ist geschlossen
If (_GetProperty('scite.jump.autostart', 0) = '1' ? True : False) _
And $iSciTEState = 1 Then _
ShellExecute($SciteDefaultHome & '\SciTE Jump\SciTE Jump.exe', '', $SciteDefaultHome)
; Fenster Handle Jump
$aJump = _GetWindowsByProcess('SciTE Jump.exe')
If Not @error Then
For $i = 1 To $aJump[0][0]
If $aJump[$i][0] = 'SciTE Jump' Then
$hWndJump = $aJump[$i][1]
ExitLoop
EndIf
Next
Else
$hWndJump = 0
EndIf
$bJumpRuns = IsHWnd($hWndJump) ? True : False
; Fenster anordnen
If (Not $bArranged) And $bSciTERuns And $bJumpRuns Then ; beides offen - noch nicht angeordnet
_MoveWindows(2) ; Fenster anordnen
$bArranged = True ; Variable für angeordnet setzen
ElseIf $bArranged And $bSciTERuns And (Not $bJumpRuns) Then ; Jump wurde geschlossen, $bArranged auf False
_MoveWindows(1) ; SciTE wieder auf FullScreen setzen
$bArranged = False ; Variable für nicht angeordnet setzen
EndIf
Sleep(500)
WEnd
Func _MoveWindows($iFlag)
Local $iWidthJump = _GetProperty('scite.jump.width', 360)
Local $sPosJump = _GetProperty('scite.jump.pos', 'right')
Switch $iFlag
Case 1
; SciTE wieder auf Fullscreen
WinMove($hWndSciTE, '', $iLeft, $iTop, $iWidth, $iHeight)
Case 2
; Jump auf Breite aus Proprties setzen und neben SciTE an Position aus Proprties setzen
If $sPosJump = 'left' Then
WinMove($hWndJump, '', $iLeft, $iTop, $iWidthJump, $iHeight)
WinMove($hWndSciTE, '', $iLeft+$iWidthJump, $iTop, $iWidth-$iWidthJump, $iHeight)
Else
WinMove($hWndSciTE, '', $iLeft, $iTop, $iWidth-$iWidthJump, $iHeight)
WinMove($hWndJump, '', $iLeft+$iWidth-$iWidthJump, $iTop, $iWidthJump, $iHeight)
EndIf
EndSwitch
EndFunc ;==>_MoveWindows
Func _GetTaskbarPosition()
Local $tRect = DllStructCreate("long;long;long;long"), $hWnd, $ret
$ret = DllCall("user32.dll", 'long', "FindWindow", 'str', "Shell_traywnd", 'str', "")
$hWnd = $ret[0]
DllCall("User32.dll", "int", "GetWindowRect", "hwnd", $hWnd, "ptr", DllStructGetPtr($tRect))
Local $aRet[4] = [DllStructGetData($tRect, 1),DllStructGetData($tRect, 2), _
DllStructGetData($tRect, 3),DllStructGetData($tRect, 4)]
Return $aRet
EndFunc ;==>_GetTaskbarPosition
Func _GetProperty($sProperty, $sDefault='')
Local $sPathAU3Prop = StringTrimRight(@AutoItExe, 11) & "SciTE\properties\au3.properties" ; C:\Program Files (x86)\AutoIt3\SciTE\properties\au3.properties
Local $sPathUserProp = @LocalAppDataDir & "\AutoIt v3\SciTE\SciTEUser.properties" ; C:\Users\[USER]\AppData\Local\AutoIt v3\SciTE\SciTEUser.properties
Local $sRead = '', $sValueReturn = $sDefault, $aMatch
Local $sPattern = $sProperty & "=([^\r\n]+)"
If FileExists($sPathUserProp) Then $sRead = FileRead($sPathUserProp)
$aMatch = StringRegExp($sRead, $sPattern, 1)
If @error Then
If FileExists($sPathAU3Prop) Then $sRead = FileRead($sPathAU3Prop)
$aMatch = StringRegExp($sRead, $sPattern, 1)
If Not @error Then $sValueReturn = $aMatch[0]
Else
$sValueReturn = $aMatch[0]
EndIf
Return $sValueReturn
EndFunc ;==>_GetProperty
Func _GetWindowsByProcess($vProcess) ; Name or PID
Local $aWnd = WinList(), $aRet[1][2], $aProc
If Not ProcessExists($vProcess) Then Return SetError(2,0,$aRet)
If Not IsNumber($vProcess) Then
$aProc = ProcessList($vProcess)
If Not @error Then
If $aProc[0][0] > 0 Then $vProcess = $aProc[1][1]
EndIf
EndIf
For $i = 1 To $aWnd[0][0]
If WinGetProcess($aWnd[$i][0]) = $vProcess Then
If BitAND(WinGetState($aWnd[$i][1]), 2) Then
$aRet[0][0] += 1
ReDim $aRet[$aRet[0][0] + 1][2]
$aRet[$aRet[0][0]][0] = $aWnd[$i][0]
$aRet[$aRet[0][0]][1] = $aWnd[$i][1]
EndIf
EndIf
Next
If $aRet[0][0] = 0 Then Return SetError(1,0,$aRet)
Return $aRet
EndFunc ;==>_GetWindowsByProcess
Alles anzeigen