From 51c9676399742311c26230dfca5d18250dfe7a9b Mon Sep 17 00:00:00 2001 From: SammaySarkar Date: Fri, 19 Feb 2016 20:16:06 +0600 Subject: [PATCH] +now anchored to topright of XY window --- XYAHKLiveFilter.ahk | 86 ++++++++++++++++++++++++++++----------------- XYAHKLiveFilter.xys | 2 +- readme.md | 2 +- 3 files changed, 55 insertions(+), 35 deletions(-) diff --git a/XYAHKLiveFilter.ahk b/XYAHKLiveFilter.ahk index 3b179eb..c3e84a9 100644 --- a/XYAHKLiveFilter.ahk +++ b/XYAHKLiveFilter.ahk @@ -1,4 +1,4 @@ -;XYAHKLiveFilter.ahk/v4.1.2/author:SammaySarkar +;XYAHKLiveFilter.ahk/v4.2.0/author:SammaySarkar ;http://xyplorer.com/xyfc/viewtopic.php?t=12588 #SingleInstance, Off ;multiple instances can run for multiple XY instances @@ -33,15 +33,11 @@ OnMessage(0x02, "Destroyer") ;WM_DESTROY ;setup GUI Gui, +HwndGUIhWnd -Border -Caption +OwnDialogs +AlwaysOnTop Gui, Margin, 2, 1 - GoSub, Sysdims ;get some system element dims for positioning + GoSub, Sysdims ;get some system element dims for correct positioning If (SyncPos = 1) ;right-align with AB GoSub, ABdims - Else { ;else place GUI at topleft of XY clientarea - GUIX := 1 - GUIY := 1 - FontName := "Segoe UI" - FontSize := 8 - } + Else ;else right-align with window + GoSub, Windims Gui, Font, s%FontSize%, %FontName% GUI, Add, Checkbox, gCallUpdateFilter hWndGUIPausehWnd 0xc00, P ;pause checkbox Gui, Add, Edit, y1 gCallUpdateFilter hWndGUIEdithWnd R1, "" ;the filterbox @@ -54,12 +50,16 @@ Gui, +HwndGUIhWnd -Border -Caption +OwnDialogs +AlwaysOnTop SendInput, {Right}{Left} ;put cursor between default quotes ;setup position -If (SyncPos = 1) { ;right align filterbox with AB - WinGetPos,,, GUIW,, ahk_id %GUIhWnd% ;get current width - GUIX := ABX + ABW - xborder - GUIW ;get real abwidth - GUIWidth - WinMove, ahk_id %GUIhWnd%,, %GUIX%, %GUIY% ;set new position +WinGetPos,,, GUIW,, ahk_id %GUIhWnd% ;get current width +If (SyncPos = 1){ ;right align filterbox with AB + GUIX := AncX + AncW - xborder - GUIW ;get real abwidth - GUIWidth SetTimer, UpdatePosAB, 100 ;turn on the position synchronizer } +Else { + GUIX := AncW - xborder*2 - GUIW ;get real winwidth - GUIWidth + SetTimer, UpdatePosWin, 100 ;turn on the position synchronizer +} +WinMove, ahk_id %GUIhWnd%,, %GUIX%, %GUIY% ;set new position ;setup hotkeys If (Shortcut) { ;put this first to override any other @@ -74,7 +74,7 @@ Hotkey, IfWinActive, ahk_id %GUIhWnd% Return ;=== END OF AUTO-EXECUTION SECTION ============================================= -;obtain necessary AddressBar attributes, called only if SyncPos=1 +;obtain necessary AddressBar attributes ABdims: ;ensure AB is visible MsgToXy("::copydata " AHKhWnd ",get('#660'),0;setlayout('showaddressbar=1');") @@ -83,37 +83,44 @@ ABdims: ReceivedData := "" ;reset receiveddata ;infer AB position relative to clientarea (thanks, autocart :) ) ControlGet, XYABhWnd, Hwnd,, Edit16, ahk_id %XYhWnd% - ;^Edit16 isn't a static identifier either, fingers crossed ... - ControlGetPos, ABX, ABY, ABW, ABH,, ahk_id %XYABhWnd% - GUIX := ABX + ABW - xborder ;GUIWidth is accounted for after GUI,Show - GUIY := ABY - yborder - CaptionH - MenuH - ABPadding - FontName := GetFont(XYABhWnd) ;get fontname of AB - FontSize := A_LastError ;get fontsize of AB + ControlGetPos, AncX, AncY, AncW, AncH,, ahk_id %XYABhWnd% + GUIX := AncX + AncW - xborder ;GUIWidth is accounted for after GUI,Show + GUIY := AncY - yborder - CaptionH - MenuH - ABPadding + FontName := GetFont(XYABhWnd) ;get fontname of AB + FontSize := A_LastError ;get fontsize of AB Return +;obtain necessary XY Window attributes +Windims: + WinGetPos,,, AncW,, ahk_id %XYhWnd% + GUIX := AncW - xborder*2 ;GUIWidth is accounted for after GUI,Show + GUIY := 1 ;no need for dynamic Y pos + FontName := GetFont(XYhWnd) ;get fontname of win + FontSize := A_LastError ;get fontsize of win +Return +;obtain some system dimension attributes Sysdims: - ;correct positioning takes some system gui elems into account + SysGet, CaptionH, 4 + SysGet, MenuH, 15 SysGet, xborder, 32 SysGet, yborder, 33 - SysGet, CaptionH, 4 - SysGet, MenuH, 15 Return ;update filterbox position to match AB. Called by timer UpdatePosAB: - If WinActive("ahk_id" XYhWnd) { ;update position only while XY is active + If WinActive("ahk_id" XYhWnd) { ;update position only while XY is active ControlGet, ABvis, Visible,,, ahk_id %XYABhWnd% ;get AB visiblity If (ABvis = 0) ;if AB is hidden MsgToXY("::setlayout('showaddressbar=1')") ;unhide AB while running - PABP = %ABX% %ABY% %ABH% %ABW% ;previous AB dims - PABH = %ABH% ;previous AB H - ControlGetPos, ABX, ABY, ABW, ABH,, ahk_id %XYABhWnd% - CABP = %ABX% %ABY% %ABH% %ABW% ;current AB dims - CABH = %ABH% ;current AB H - If (PABP != CABP) { ;AB position changed, sync with new position - GUIX := ABX + ABW - xborder - GUIW - GUIY := ABY - yborder - CaptionH - MenuH - ABPadding - GUIH := ABH + ABPadding - If (PABH <> CABH) { ;AB height change = font change + PAncA = %AncX% %AncY% %AncH% %AncW% ;previous AB dims + PAncB = %AncH% ;previous AB H + ControlGetPos, AncX, AncY, AncW, AncH,, ahk_id %XYABhWnd% + CAncA = %AncX% %AncY% %AncH% %AncW% ;current AB dims + CAncB = %AncH% ;current AB H + If (PAncA != CAncA) { ;AB pos change = sync new pos + GUIX := AncX + AncW - xborder - GUIW + GUIY := AncY - yborder - CaptionH - MenuH - ABPadding + GUIH := AncH + ABPadding + If (PAncB <> CAncB) { ;AB H change = font change FontName := GetFont(XYABhWnd) ;get new fontname FontSize := A_LastError ;get new fontsize Gui, Font, s%FontSize%, %FontName% ;set new font @@ -126,6 +133,19 @@ UpdatePosAB: } } Return +;update filterbox position to match Window. Called by timer +UpdatePosWin: + If WinActive("ahk_id" XYhWnd) { ;update position only while XY is active + PAncA = %AncW% ;previous win W + WinGetPos,,, AncW,, ahk_id %XYhWnd% + CAncA = %AncW% ;current win W + If (PAncA != CAncA) { ;Win W change = sync new pos + GUIX := AncW - xborder*2 - GUIW + GUIY := 1 + WinMove, ahk_id %GUIhWnd%,, %GUIX%, %GUIY% ;set new position + } + } +Return ;triggered by filterbox or Pause chkbox change. CallUpdateFilter: diff --git a/XYAHKLiveFilter.xys b/XYAHKLiveFilter.xys index 3fd19e5..438cb80 100644 --- a/XYAHKLiveFilter.xys +++ b/XYAHKLiveFilter.xys @@ -1,4 +1,4 @@ - //XYAHKLiveFilter.ahk/v4.1.2//author:SammaySarkar + //XYAHKLiveFilter.xys/v4.2.0//author:SammaySarkar //http://xyplorer.com/xyfc/viewtopic.php?&t=12588 perm $p_XYAHKLiveFilter_A, $p_XYAHKLiveFilter_B; diff --git a/readme.md b/readme.md index 39734b8..9475e26 100644 --- a/readme.md +++ b/readme.md @@ -47,7 +47,7 @@ Some options may be modified in the XYscript. It follows [Authotkey's hotkey definition syntax](https://autohotkey.com/docs/Hotkeys.htm). * `$SyncToAB`: if `$SyncToAB` is 1, the filterbox is positioned over right edge the of the addressbar. This also forces the AB to stay visible as long as livefilter is running, and reverts back to last state when the filter is closed.
- If `$SyncToAB` is not 1, then the filterbox is positioned at the _topleft_ of XY, and does not try to modify AB visibility. + If `$SyncToAB` is not 1, then the filterbox is pops up and stays at the _topright_ of XY, and does not try to modify AB visibility. * `$ABPadding`: Adjust this value only if the filterbox doesn't horizontal-align exactly with the addressbar.
The value should be a (small) integer: 0,3,-2 etc.
The filterbox moves up/down this many pixels. Only effective when `$SyncToAB = 1`.