Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Window name changed
#1
I would like a toolbar attached to Windows Explorer. This toolbar should appear when I go to certain folders and disappear when I go to other folders.
I tried to set a trigger "Window - Name changed" "C:\Windows". In this case the toolbar does correctly appear when I go to that folder; the problem is that it does not disappear when I go to a different folder, for example "C:\".
#2
Function ToolbarHook_CloseWhenWindowNameChanges
Code:
Copy      Help
;/
function# hwnd message wParam lParam

;This function can be use with any QM toolbar as a toolbar hook function.
;Closes the toolbar when its owner window name changes.
;Just add this first line in toolbar text (1 space character at the beginning):
;;/hook ToolbarHook_CloseWhenWindowNameChanges


sel message
,case WM_INITDIALOG
,str* s1._new; SetProp(hwnd "ownerText" s1)
,s1.getwintext(GetToolbarOwner(hwnd))
,SetTimer hwnd 1 500 0
,
,case WM_TIMER
,sel wParam
,,case 1
,,s1=+GetProp(hwnd "ownerText")
,,str s2.getwintext(GetToolbarOwner(hwnd))
,,if s2!=*s1
,,,KillTimer hwnd wParam
,,,clo hwnd
,
,case WM_DESTROY
,RemoveProp(hwnd "ownerText")

example (replace the ; with a space character)
Toolbar Toolbar76
Trigger !n"WINDOWS" "CabinetWClass" "" "" "" 0x2     Help - how to add the trigger to the macro
Code:
Copy      Help
;/hook ToolbarHook_CloseWhenWindowNameChanges
button1 :out 1
#3
Wonderful, as usual.
#4
I would like, if possible, an improvement in this function.
My toolbar should be visible as long as I am in a certain folder, including its subfolders.
At present, if I go in a different subfolder, the toolbar disappears, perhaps because the function sees that windows name has changed.
#5
Function folder_window_address_change_trigger
Trigger $a 140 0 "" "ToolbarWindow32" 1001 "Address: *" "CabinetWClass" "" 0 "" "" "" "" 0x20     Help - how to add the trigger to the macro
Code:
Copy      Help
;\
function hwnd idObject idChild

;Opens and closes QM toolbars when you open a folder window or navigate to another folder in a folder window.
;Runs when the address bar name changes. The name is the folder path; it is not displayed as raw path.
;Tested on Windows 7 and 10. Will not work on XP.
;Need to edit this function: change/add/remove the code that opens (mac) and closes (clo) toolbars.
;For non-English Windows edition users:
;;;If does not work, need to replace the word "Address" in this function and in its trigger.
;;;To discover it, capture the address bar with the "Find accessible object" dialog and you'll see it in the Name field.
str addressBarName="Address"

#region don't edit this
wait 10 WV hwnd; err ret ;;detects the name change when closing the window
str s.getwintext(hwnd); s.remove(0 addressBarName.len+2)
int w=GetAncestor(hwnd 2) ;;hwnd is the address bar control, and now we need the folder window
#endregion

;Edit the following code.
;This code works only if you need 1 such toolbar. Can be modified to support multiple toolbars, but it is not so simple.

out s ;;remove this when this macro works

lpstr macro="WINDOWS FOLDER TOOLBAR"
int tb=win(macro "QM_toolbar")
if matchw(s "C:\Windows*" 1)
,if(tb=0) mac macro w
else
,if(tb!=0) clo tb


Forum Jump:


Users browsing this thread: 1 Guest(s)