watch XY for tab count change event [title changed]
Posted: 23 Jan 2014 10:02
would like to have an option to have the number of tabs in the title bar
for ahk-scripting reasons
for ahk-scripting reasons
Forum for XYplorer Users and Developers
https://www.xyplorer.com/xyfc/
I would do it like that:binocular222 wrote:To watch XY's titlebar, you need Settimer, right?
You can Settimer then SendMessage every xx milisecond to querry number of Tab is as effective as Settimer then watch titlebar
hey , thx for the help and thought provoking remarks well meant are always goodbinocular222 wrote:So you use WinWaitClose.
ok, I will not hijack your thread anymore.
Don, can you add number of tabs var for titlebar template?
+1Even better would be a completely scriptable part of the titlebar, i.e. with a "return" command like in custom columns.
1. Yesautocart wrote:However, in order to always keep the titlebar current, the result of the script would probably have to be checked continously...![]()
On the other hand I am confident that Don is able to find a good solution.
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Persistent
global XY_eval_and_returnvalue_XYRETURN
;***************************************************************************************
;** heavily based on:
;** http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=9233&hilit=messenger
;***************************************************************************************
XY_eval_and_returnvalue(stringToEval) ;Send message to XYplorer
{
global XY_eval_and_returnvalue_XYRETURN
SenderHWND := A_ScriptHwnd + 0 ;Return this script's hidden hwdn id. +0 to convert from Hex to Dec
MessagetoXYplorer := "::CopyData " SenderHWND ", " stringToEval ", 0" ;resolved to sth like this: ::CopyData 7409230, <curitem>, 0 _OR like this: ::CopyData 7409230, tab('get','count'), 0
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 XY_eval_and_returnvalue_XYRETURN
}
Function_Receive_WM_COPYDATA(wParam, lParam)
{
global XY_eval_and_returnvalue_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
XY_eval_and_returnvalue_XYRETURN := Datareceived
}
XY_tabCount := XY_eval_and_returnvalue("tab('get','count')")
SetTimer, Label1, 150
Exit
Label1:
XY_tabCountNew := XY_eval_and_returnvalue("tab('get','count')")
If (XY_tabCount != XY_tabCountNew)
{
XY_tabCount := XY_tabCountNew
XY_eval_and_returnvalue("tab('lock', 1)") ; <-- The ACTIV(AT)E(D) TAB after "add/delete tab" will always be automatically LOCKED
/* ||
vv Below from here: The ACTIV(AT)E(D) TAB after "add/delete tab" will always be automatically RENAMED (according to below user-programmed rules)
*/
XY_tabPath := XY_eval_and_returnvalue("tab('get', 'path')")
newTabName := SubStr(XY_tabPath,1,2)
If(SubStr(XY_tabPath,1,17) == "path_to_specific_folder")
{
newTabName := newTabName . "B:"
If(InStr(XY_tabPath, "\", , 0) > 17)
{
newTabName := newTabName . SubStr(XY_tabPath,19,2) . ":"
}
}
else If(SubStr(XY_tabPath,1,47) == "path_to_other_specific_folder")
{
newTabName := newTabName . "A:"
}
else If(SubStr(XY_tabPath,1,38) == "path_to_3rd_specific_folder")
{
newTabName := newTabName . "A:Doku:"
}
else If(SubStr(XY_tabPath,1,10) == "path_to_4th_specific_folder")
{
newTabName := newTabName . "A:"
}
else If(SubStr(XY_tabPath,1,10) == "path_to_5th_specific_folder")
{
newTabName := newTabName . "XY:"
}
subcategories := "generic_folder1|generic_folder2|generic_folder3|generic_folderN"
If(InStr(subcategories, SubStr(XY_tabPath, 1 + InStr(XY_tabPath, "\", , 0))))
{
index_renamedTab := XY_eval_and_returnvalue("tab('rename', '" . newTabName . "' . getpathcomponent(tab('get', 'path'), 'parent') . ':' . getpathcomponent(tab('get', 'path'), 'component', -1))")
}
else
{
index_renamedTab := XY_eval_and_returnvalue("tab('rename', '" . newTabName . "' . getpathcomponent(tab('get', 'path'), 'component', -1))")
}
}
return