An alternative (and predecessor) to XY's built-in Live-Filter Box.
>> DOWNLOADS and USAGE INSTRUCTION <<
Happy filtering!

======================
ask for improvements, send bugfixes. All help is welcome!
Code: Select all
XYAHKLiveFilter = ::filter "%XYAHKLiveFilter%"
Code: Select all
Gui, Add, Edit, R1 vXYAHKFilter gUpdateFilter hWndGUIEdithWnd
Code: Select all
SendInput, {Left}
Code: Select all
if($p_XYAHKLiveFilter_A!=1)||($p_XYAHKLiveFilter_B!=<hwnd>){$p_XYAHKLiveFilter_A=1;$p_XYAHKLiveFilter_B=<hwnd>;run '"' . <xyscripts> . '\XYAHKLiveFilter.exe' . '" ' . <hwnd> . ' ^`',0;};
I assume yes.SammaySarkar wrote:Thanks!
Re path: is it because <xyscripts> expands to a path with spaces?
Code: Select all
run """<xyscripts>\XYAHKLiveFilter.exe"" <hwnd> ^`",0;};
Code: Select all
#SingleInstance force
#NoEnv
#notrayicon
SetControlDelay, -1
Settitlematchmode, 2
Ifwinnotactive, XYplorer ahk_class ThunderRT6FormDC
Exitapp
XYhWnd := Winactive("A")
;Get current Visual Filter
SenderHWND := A_ScriptHwnd + 0 ;Return this script's hidden hwdn id. +0 to convert from Hex to Dec
MessagetoXYplorer := "::CopyData " SenderHWND ", get('VisualFilter'), 2" ;resolved to sth like this: ::CopyData 7409230, get('VisualFilter'),2
Global Datareceived
OnMessage(0x4a, "Function_Receive_WM_COPYDATA") ; 0x4a is WM_COPYDATA. This onhold and wait for the WM_Copydata from XYplorer then execute Function_Receive_WM_COPYDATA(wParam, lParam) below
MsgToXY(MessagetoXYplorer)
;create GUI, hotkeys
Main:
Gui, +HwndGUIhWnd +OwnDialogs -Resize -Border -Caption +AlwaysOnTop
Gui, Margin, 0, 0 ; TODO remove background around editbox margin
Gui, Font, s12, Segoe UI ; should be DPI aware
Gui, Add, Edit, R1 vXYAHKFilter gUpdateFilter hWndGUIEdithWnd W200, %Datareceived%
DllCall("SetParent","UInt", GUIhWnd, "UInt", XYhWnd) ;child of XY
Gui, Show, X1 Y1, AHKLiveFilterForXYPlorer
OnMessage(0x200, "FocusGUI") ;activate GUI on mouse-over (and ifWinActive XY)
Return
;=== EndOf Auto-Exec Section =====================================================
;triggered when editbox content changed
UpdateFilter:
GuiControlGet, XYAHKLiveFilter, , %GUIEdithWnd%
MsgToXY("::filter " XYAHKLiveFilter)
Return
#If winactive("AHKLiveFilterForXYPlorer ahk_class AutoHotkeyGUI")
Enter:: Exitapp
#If winactive("ahk_id" . XYhWnd) OR winactive("AHKLiveFilterForXYPlorer ahk_class AutoHotkeyGUI")
Escape::
CapsLock::
MsgToXY("::filter")
WinActivate, ahk_id %XYhWnd%
Exitapp
#If
;activate the GUI (editbox)
FocusGUI() {
global XYhWnd
IfWinActive, ahk_id %XYhWnd%
{
Gui, +LastFound ;only one GUI in this thread
WinActivate
}
Return
}
GuiClose:
Exitapp
;=== MsgToXY() ===================================================================
;send `arg_Msg` to hwnd %XYhWnd% (global) via WM_COPYDATA
MsgToXY(arg_Msg) {
; function lifted from binocular222's XYplorerMessenger (thanks! :) )
global XYhWnd
Size := StrLen(arg_Msg)
If !(A_IsUnicode) {
VarSetCapacity(Data, Size * 2, 0)
StrPut(arg_Msg, &Data, Size, "UTF-16")
} Else {
Data := arg_Msg
}
VarSetCapacity(COPYDATA, A_PtrSize * 3, 0)
NumPut(4194305, COPYDATA, 0, "Ptr")
NumPut(Size * 2, COPYDATA, A_PtrSize, "UInt")
NumPut(&Data, COPYDATA, A_PtrSize * 2, "Ptr")
SendMessage, 0x4A, 0, ©DATA, , ahk_id %XYhWnd%
Return
}
;=== EndOf MsgToXY() =============================================================
Function_Receive_WM_COPYDATA(wParam, lParam)
{
StringAddress := NumGet(lParam + 2*A_PtrSize) ;lParam+8 is the address of CopyDataStruct's lpData member.
CopyOfData := StrGet(StringAddress) ;May also specify CP0 (default) or UTF-8 or UTF-16: StrGet(StringAddress, NumGet(lParam+A_PtrSize), "UTF-16")
cbData := NumGet(lParam+A_PtrSize)/2 ;cbData = String length
StringLeft, Datareceived, CopyOfData, cbData
}
thank you!nerdweed wrote:Sammay,
Nice script.
yes, it's quite easy with AHK. But...Not sure if AHK has any means to identify the box and place it there
... this is the problem.it will be difficult to compute due to different layouts
Would you not simply have to see if the address bar is turned on and in case it is not then find a different place?SammaySarkar wrote:... this is the problem.it will be difficult to compute due to different layouts
(though there are workarounds, at a little possible inconvenience of users)