XYAHKLiveFilter - livefilter the filelist

Discuss and share scripts and script files...
bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

XYAHKLiveFilter - livefilter the filelist

Post 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!
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

highend
Posts: 13313
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: XYAHKLiveFilter - livefilter the filelist

Post 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...
One of my scripts helped you out? Please donate via Paypal

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: XYAHKLiveFilter - livefilter the filelist

Post 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... :)
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

binocular222
Posts: 1416
Joined: 04 Nov 2008 05:35
Location: Hanoi, Vietnam

Re: XYAHKLiveFilter - livefilter the filelist

Post by binocular222 »

Super Great :appl:
Small thing: Enter should close the box too, not just Escape
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: XYAHKLiveFilter - livefilter the filelist

Post by bdeshi »

Thanks!
:D
And thanks for XYplorerMessenger!

...I'd mentally reserved ENTER for submitting regexp filters (noted in the post above yours)
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: XYAHKLiveFilter - livefilter the filelist

Post 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?)
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

autocart
Posts: 1248
Joined: 26 Sep 2013 15:22

Re: XYAHKLiveFilter - livefilter the filelist

Post 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.
Last edited by autocart on 01 Oct 2014 12:22, edited 1 time in total.

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: XYAHKLiveFilter - livefilter the filelist

Post 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)
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

autocart
Posts: 1248
Joined: 26 Sep 2013 15:22

Re: XYAHKLiveFilter - livefilter the filelist

Post 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.

Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

Re: XYAHKLiveFilter - livefilter the filelist

Post by Enternal »

Darn it. More GREAT scripts that I have to add to my installation. :biggrin:

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: XYAHKLiveFilter - livefilter the filelist

Post by bdeshi »

Glad to be a burden to your storage! :D
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

nerdweed
Posts: 648
Joined: 25 Feb 2012 07:47

Re: XYAHKLiveFilter - livefilter the filelist

Post 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

binocular222
Posts: 1416
Joined: 04 Nov 2008 05:35
Location: Hanoi, Vietnam

Re: XYAHKLiveFilter - livefilter the filelist

Post 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
}
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: XYAHKLiveFilter - livefilter the filelist

Post 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)
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

autocart
Posts: 1248
Joined: 26 Sep 2013 15:22

Re: XYAHKLiveFilter - livefilter the filelist

Post 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?

Post Reply