Getting explorer to 'reload' registry changes

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
happyhungarian
Posts: 3
Joined: 05 Nov 2017, 17:54

Getting explorer to 'reload' registry changes

05 Nov 2017, 18:01

Hey everyone, I have searched high and low for this, but none of the solns seemed to help. I'm trying to toggle taskbar grouping by writing to the registry, but I have to resort to restarting explorer to make it work. Is there a solution for this already?

I'm running 64-bit Win 7.
GEV
Posts: 1002
Joined: 25 Feb 2014, 00:50

Re: Getting explorer to 'reload' registry changes

05 Nov 2017, 18:16

Restart explorer:

Code: Select all

list := ""
explorer_path := ""

; Get fullpath of all opened explorer windows:
If WinExist("ahk_class CabinetWClass") ; explorer
{
	; https://autohotkey.com/boards/viewtopic.php?p=28751#p28751
	for window in ComObjCreate("Shell.Application").Windows
	{
		try explorer_path := window.Document.Folder.Self.Path       
		list = %list%%explorer_path%`n
	}
		list := trim(list, "`n")
}
 
; restart the explorer.exe process:
RunWait, %comspec% /c taskkill /f /im explorer.exe ,,hide
Process, WaitClose, explorer.exe
Run, explorer.exe

; open all explorer windows we had open previously:
If (list != "")
{
	Process, wait, explorer.exe
	Loop, parse, list, `n
		Run %A_LoopField%   
}
happyhungarian
Posts: 3
Joined: 05 Nov 2017, 17:54

Re: Getting explorer to 'reload' registry changes

05 Nov 2017, 18:18

GEV wrote:Restart explorer:

Code: Select all

list := ""
explorer_path := ""

; Get fullpath of all opened explorer windows:
If WinExist("ahk_class CabinetWClass") ; explorer
{
	; https://autohotkey.com/boards/viewtopic.php?p=28751#p28751
	for window in ComObjCreate("Shell.Application").Windows
	{
		try explorer_path := window.Document.Folder.Self.Path       
		list = %list%%explorer_path%`n
	}
		list := trim(list, "`n")
}
 
; restart the explorer.exe process:
RunWait, %comspec% /c taskkill /f /im explorer.exe ,,hide
Process, WaitClose, explorer.exe
Run, explorer.exe

; open all explorer windows we had open previously:
If (list != "")
{
	Process, wait, explorer.exe
	Loop, parse, list, `n
		Run %A_LoopField%   
}
This is the only way? I was looking for a more elegant solution. Is there a way to change taskbar settings some other way?
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Getting explorer to 'reload' registry changes

06 Nov 2017, 02:28

Some ideas that may or may not work:
- SHChangeNotify.
- Change something else about the taskbar to refresh it.
Get taskbar autohide state? Solved - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=39123
- Apply SystemParametersInfo to something related to the taskbar.
- WinSet Redraw.

What have you tried so far?

Also, if you post your code then people can run it and then test refresh methods.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
happyhungarian
Posts: 3
Joined: 05 Nov 2017, 17:54

Re: Getting explorer to 'reload' registry changes

06 Nov 2017, 23:25

Thank you for the suggestions. None of them worked though, except SytemParametersInfo which I haven't been able to check out. I was hopeful about toggling the lock state of the taskbar, but alas...
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Getting explorer to 'reload' registry changes

07 Nov 2017, 08:15

I checked the taskbar with Microsoft Spy++, while changing the setting manually, it was receiving the message WM_SETTINGCHANGE.

Code: Select all

q:: ;taskbar - toggle always/never combine (tested on Windows 7)
;do it manually: right-click taskbar, Properties, Taskbar tab, Taskbar buttons:
;vState := 0 ;Always combine, hide labels
;vState := 1 ;Combine when taskbar is full
;vState := 2 ;Never combine
RegRead, vState, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, TaskbarGlomLevel
vState := !vState * 2
RegWrite, REG_DWORD, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, TaskbarGlomLevel, % vState
;note: WM_SETTINGCHANGE is the same as WM_WININICHANGE
SendMessage, 0x1A,,,, ahk_class Shell_TrayWnd ;WM_SETTINGCHANGE := 0x1A
WinSet, Redraw,, ahk_class Shell_TrayWnd
return

;==================================================

;this is a fallback method, I recommend using the RegWrite/SendMessage/WinSet Redraw method
;w:: ;taskbar - toggle always/never combine (tested on Windows 7)
Run, % "rundll32 shell32.dll,Options_RunDLL 1" ;Taskbar and Start Menu Properties, Taskbar tab
vWinCriteria := "Taskbar and Start Menu Properties ahk_class #32770"
WinWaitActive, % vWinCriteria
SendMessage, 0x147, 0, 0, ComboBox2, % vWinCriteria
vNum := ErrorLevel+1
vNum := vNum=1?3:1
Control, Choose, % vNum, ComboBox2, % vWinCriteria
ControlSend, Button11, {Enter}, % vWinCriteria
return
Btw:
[get/set auto-hide/lock states]
Get taskbar autohide state? Solved - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 81#p179081
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Lamron750 and 243 guests