Hi,
USAGE COMPLETELY AT ANYBODY'S OWN RISK!!
In order to --> dbl-click on a .xy-find file so that it will load a saved ini-search <-- with the same name in XYplorer, do the following:
Download and save the xy-find.zip (see below) and extract the xy-find.exe to a PATH.
In Tools/List Management/Portable File Associations... connect .xy-find files to xy-find.exe like this:
Code: Select all
xy-find>"PATH...\xy-find.exe"Now, if you dbl-click on the .xy-find file it will load the saved ini-search in XYplorer.
In order to save a search and automatically create the corresponding .xy-find file, you can make a user button and edit the "on left click:" field like this:
Code: Select all
run "PATH...\xy-find.exe" savesearch "PATH2"In the downloadable zip I also packed a simple icon for use with the button.
Here is the ahk-code for the xy-find.exe:
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
global XYRETURN
SetTitleMatchMode, 2
IfWinNotExist XYplorer ahk_class ThunderRT6FormDC
ExitApp
if %0% = 0
ExitApp
cmdp = %1%
if (cmdp = "savesearch")
{
savetopath = %2%
savetopath := RTrim(savetopath, "\""")
;~ MsgBox %2%
if (not (InStr(FileExist(savetopath), "D")))
savetopath := GetVarFromXYplorer("<xydata>") . "\FindTemplates"
SaveSearch(savetopath)
;~ MsgBox % savetopath
}
SplitPath, cmdp, , , fileextension, filenameNOextension
if (FileExist(cmdp) && fileextension = "xy-find")
if (FileExist(GetVarFromXYplorer("<xydata>") . "\FindTemplates\" . filenameNOextension . ".ini"))
LoadSearch(filenameNOextension)
ExitApp
LoadSearch(searchtemplateFilename)
{
searchtemplatename := ""
hex := ""
delim := ""
Loop, Parse, searchtemplateFilename, "`%"
{
if (delim = "`%" and StrLen(A_LoopField) > 1)
{
hex := "0x" . SubStr(A_LoopField, 1, 2)
if hex is xdigit
hex := Chr(hex) . Substr(A_LoopField, 3)
else
hex := delim . A_LoopField
}
else
hex := delim . A_LoopField
searchtemplatename := searchtemplatename . hex
delim := "`%"
}
MessagetoXYplorer := "::loadsearch " . searchtemplatename . ", rle"
FunctionMessagetoXYplorer(MessagetoXYplorer)
}
SaveSearch(savetopath)
{
xyFindTemplatesPath := GetVarFromXYplorer("<xydata>") . "\FindTemplates"
fileList =
Loop % xyFindTemplatesPath . "\*"
fileList = %fileList%%A_LoopFileName%`n
WinActivate, ahk_class ThunderRT6FormDC
WinMenuSelectItem, ahk_class ThunderRT6FormDC, , Edit, Search Templates...
WinWaitActive Search Templates ahk_class ThunderRT6FormDC
SetControlDelay -1
Control, Check, , ThunderRT6CheckBox2, Search Templates ahk_class ThunderRT6FormDC
;~ BlockInput On
ControlClick, ThunderRT6CommandButton3, Search Templates ahk_class ThunderRT6FormDC
;~ BlockInput Off
WinWait, Save Settings to Search Template ahk_class ThunderRT6FormDC
WinGetTitle, title
WinSetTitle % title . " - XY-FIND"
WinWaitClose
;~ BlockInput On
ControlClick, ThunderRT6CommandButton4, Search Templates ahk_class ThunderRT6FormDC
;~ BlockInput Off
WinWaitClose, Search Templates ahk_class ThunderRT6FormDC
newFile =
Loop % xyFindTemplatesPath . "\*"
if (not InStr(fileList, A_LoopFileName))
{
newFile := A_LoopFileName
break
}
if newFile
{
StringTrimRight, newFile, newFile, 4 ;removes ".ini"
file := FileOpen(savetopath . "\" . newFile . ".xy-find", "w")
if file
{
file.Close()
return savetopath . "\" . newFile . ".xy-find"
}
}
}
;***************************************************************************************
;** code from others (or based on) **
;***************************************************************************************
;heavily based on
;http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=9233&p=89555&hilit=messenger#p89555
FunctionMessagetoXYplorer(MessagetoXYplorer) ;Send message to XYplorer
{
SetTitleMatchMode, 2
HWND := WinExist("XYplorer ahk_class ThunderRT6FormDC")
Size := StrLen(MessagetoXYplorer)
If !(A_IsUnicode)
{
VarSetCapacity(Data, Size * 2, 0)
StrPut(MessagetoXYplorer, &Data, Size, "UTF-16")
}
Else
Data := MessagetoXYplorer
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 %HWND%
}
GetVarFromXYplorer(varName) ;Send message to XYplorer
{
global XYRETURN
SenderHWND := A_ScriptHwnd + 0 ;Return this script's hidden hwdn id. +0 to convert from Hex to Dec
MessagetoXYplorer := "::CopyData " SenderHWND ", """ varName """, 2" ;resolved to sth like this: ::CopyData 7409230, "<curitem>", 2
SetTitleMatchMode, 2
HWND := WinExist("XYplorer ahk_class ThunderRT6FormDC")
Size := StrLen(MessagetoXYplorer)
If !(A_IsUnicode)
{
VarSetCapacity(Data, Size * 2, 0)
StrPut(MessagetoXYplorer, &Data, Size, "UTF-16")
}
Else
Data := MessagetoXYplorer
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")
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
SendMessage, 0x4a, 0, ©DATA, , ahk_id %HWND% ;SendMessage waits for the target window to process the message, up until the timeout period expires.
OnMessage(0x4a, "")
return XYRETURN
}
Function_Receive_WM_COPYDATA(wParam, lParam)
{
global XYRETURN
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/2 = String length
StringLeft, Datareceived, CopyOfData, cbData
XYRETURN := Datareceived
}The exe "xy-find_load_results.exe" will load any search results that were saved with the search, instead of actually running the search, but it can be rerun anew manually.
(The only line in code that was changed, is:
MessagetoXYplorer := "::loadsearch " . searchtemplatename . ", rle"
It was changed to:
MessagetoXYplorer := "::loadsearch " . searchtemplatename . ", rlec")
The exe named only "xy-find.exe" will load and run the saved search with its settings anew right away and not load any saved results.
XYplorer Beta Club