Page 1 of 6

XYAHKLiveFilter - livefilter the filelist

Posted: 28 Sep 2014 12:41
by bdeshi
Live-filters the file list, as you type into a textbox.
An alternative (and predecessor) to XY's built-in Live-Filter Box.

>> DOWNLOADS and USAGE INSTRUCTION <<

Happy filtering! :D

======================

ask for improvements, send bugfixes. All help is welcome!

Re: XYAHKLiveFilter - livefilter the filelist

Posted: 28 Sep 2014 12:59
by highend
Wouldn't it be better to remove the quotation marks inside the box and just add them to the ::filter line?

E.g.:

Code: Select all

XYAHKLiveFilter = ::filter "%XYAHKLiveFilter%"
and ofc the lines

Code: Select all

Gui, Add, Edit, R1 vXYAHKFilter gUpdateFilter hWndGUIEdithWnd
and

Code: Select all

SendInput, {Left}
must be changed as well.

and to use regexp's:
Maybe check for one special character at the beginning and if it is detected, wait until it is typed in again and then send the script
":" would be a good choice because it can't be part of a file- or foldername and is has no special meaning in a regexp.

E.g the following is typed:
:(start|end):

: -> special char detected, don't send the content of the input box right now
(start|end) -> the pattern was typed
: -> end char detected, now send the script...

Re: XYAHKLiveFilter - livefilter the filelist

Posted: 28 Sep 2014 13:15
by bdeshi
Thanks, but the quotes are there to impress upon users the fact that the strings "should be properly escaped according to XYscripting rules when necessary".
[edit] Besides, quotes aren't always necessary and may also be swapped for singlequotes, so always adding them in ahk is a no-no.

And about regexp checking, my idea was check for special char (> or |> ...) and wait for user to press ENTER...
Fortunately other types of filters seem to play nice with this livefiltering... :)

Re: XYAHKLiveFilter - livefilter the filelist

Posted: 28 Sep 2014 16:40
by binocular222
Super Great :appl:
Small thing: Enter should close the box too, not just Escape

Re: XYAHKLiveFilter - livefilter the filelist

Posted: 28 Sep 2014 17:04
by bdeshi
Thanks!
:D
And thanks for XYplorerMessenger!

...I'd mentally reserved ENTER for submitting regexp filters (noted in the post above yours)

Re: XYAHKLiveFilter - livefilter the filelist

Posted: 30 Sep 2014 21:33
by bdeshi
Updated.
Changes:
> OnExit correction. AHK is tolerant of exit methods other than ESCAPE
> a 'debug' status msg would come up when closing filterbox. Not any more.
> Filterbox would activate on mouseover even if parent XY window wasn't active. Fixed. (Or was it a feature?)

Re: XYAHKLiveFilter - livefilter the filelist

Posted: 01 Oct 2014 10:55
by autocart
Nice Idea and nice concept regarding the live input box!

In order for it to work for me though, I have to call it in a way like:

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;};
Otherwise it does not find the file.

Re: XYAHKLiveFilter - livefilter the filelist

Posted: 01 Oct 2014 11:05
by bdeshi
Thanks!

Re path: is it because <xyscripts> expands to a path with spaces?
I'll check when back at my desk, and if so, then update the script to account for that.
(now the xyscript always quotes ahk script path)

Re: XYAHKLiveFilter - livefilter the filelist

Posted: 01 Oct 2014 12:21
by autocart
SammaySarkar wrote:Thanks!

Re path: is it because <xyscripts> expands to a path with spaces?
I assume yes.
Your new code:

Code: Select all

run """<xyscripts>\XYAHKLiveFilter.exe"" <hwnd> ^`",0;};
works well too.

Re: XYAHKLiveFilter - livefilter the filelist

Posted: 01 Oct 2014 13:11
by Enternal
Darn it. More GREAT scripts that I have to add to my installation. :biggrin:

Re: XYAHKLiveFilter - livefilter the filelist

Posted: 01 Oct 2014 13:31
by bdeshi
Glad to be a burden to your storage! :D

Re: XYAHKLiveFilter - livefilter the filelist

Posted: 02 Oct 2014 13:58
by nerdweed
Sammay,

Nice script. I think bottom left will be a better place for the box. Mini Tree would leave atleast some space around that area.

Though the best place will be to use a very small area of the address bar - Not sure if AHK has any means to identify the box and place it there, otherwise it will be difficult to compute due to different layouts

Re: XYAHKLiveFilter - livefilter the filelist

Posted: 02 Oct 2014 17:06
by binocular222
Here is my own version
+ Reuse current VF as default text in AHK filterbox
+ Escape/Capslock cancel the VF. Enter when AHK box is active will dismiss the app
+ Just run the app, no need to set Permanent Variable

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, &COPYDATA, , 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
}

Re: XYAHKLiveFilter - livefilter the filelist

Posted: 02 Oct 2014 18:37
by bdeshi
nerdweed wrote:Sammay,
Nice script.
thank you!
Not sure if AHK has any means to identify the box and place it there
yes, it's quite easy with AHK. But...
it will be difficult to compute due to different layouts
... this is the problem.
(though there are workarounds, at a little possible inconvenience of users)

Re: XYAHKLiveFilter - livefilter the filelist

Posted: 02 Oct 2014 23:02
by autocart
SammaySarkar wrote:
it will be difficult to compute due to different layouts
... this is the problem.
(though there are workarounds, at a little possible inconvenience of users)
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?