SHChangeNotify not refreshing icon for Virtual Keyboard after registry toggle - winapi

I've got a registry key that gets set to show the Virtual Keyboard for Windows 10 1703 Creators Update.
You can run it yourself if you throw this in a .reg file after manually disabling it to perform the same test I'm trying out:
show_vkb.reg
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\TabletTip\1.7]
"TipbandDesiredVisibility"=dword:00000001
I'm basically trying to toggle this on for the user:
So that involves two end-goals:
Updating the registry key and refreshing whatever references it
Refreshing the taskbar so the Virtual Keyboard icon appears, as shown below:
I was led to understand that using SHChangeNotify should refresh the explorer shell. I've verified that it's refreshing part of the taskbar, specifically the App icons, but it's not refreshing the virtual peripherals shown on the taskbar.
#include <Windows.h>
#include <ShlObj.h>
int main()
{
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
return 0;
}
I'm not sure what I'm missing/doing wrong here. I've tried a couple different parameter combos with the different MACRO values listed for SHChangeNotify, but no progress.

Related

Win32: Reloading theme after theme-related registry changes?

There's a couple theming related registry keys that I'm editing through a personal tool:
HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize\AppsUseLightTheme (to change light/dark mode preference)
HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent\AccentPalette (to change taskbar color)
I'd really like to update the theme appearance on the fly, but the problem is these changes don't take effect until after restart. The "Theme Settings" in the native System Settings edits the same registry keys, but also manages to update the color of the taskbar etc on the fly.
To understand how the native System Settings is reloading the theme, I've tried monitoring the outgoing window messages in Spy++ and inspecting the API calls in WinDbg. It broadcasts WM_DWMCOLORIZATIONCOLORCHANGED and WM_SETTINGCHANGE (with "ImmersiveColorSet"). But attempting to do the same doesn't seem to have any effect whatsoever:
fn reload_theme() -> Result<()> {
unsafe {
// Send message to all top-level windows.
let broadcast_handle = HWND(0xffff);
SendNotifyMessageW(
broadcast_handle,
WM_DWMCOLORIZATIONCOLORCHANGED,
WPARAM(3812725153), // Arbitrary value
LPARAM(1), // Arbitrary value
);
SendNotifyMessageW(
broadcast_handle,
WM_SETTINGCHANGE,
WPARAM(0),
LPARAM(w!("ImmersiveColorSet").as_ptr() as isize), // Equivalent to L"ImmersiveColorSet" in c++
);
Ok(())
}
}
One other discovery so far is that always updating the key HKCU\SOFTWARE\Microsoft\Windows\DWM\AccentColor causes a reload. There are still elements here and there that don't update though.
How can you "reload" the Windows theme without restarting after theme-related registry changes?

Synaptics custom gestures for Windows using registry

I am a huge fan of mouse gestures and the ones introduced in Windows 10 are great.
However, I used to be able to use three-finger swipe right/left as back and forth gestures in my browser in Windows 8.1 and now the same gesture is used for task switching. I can install the old drivers, but then I will loose the three-finger swipe up gesture to show all windows open.
I use a Synaptics ClickPad which can detect up to four fingers.
Is is possible to change the registry to enable to following gestures:
Three finger left/right: Back/forth in browser
Four finger left/right: Switch between Virtual Desktops
For instance, switching between Virtual Desktops is using the key combination CTRL + WINKEY + RIGHT/LEFT ARROW. How do I apply this combination to the registry?
DISCLAIMER: This answer doesn't cover current versions of the driver but the general direction of tweaking the gestures for them.
To customize swipe behavior, you should dig in registry.
Action settings are stored in HKLM\SOFTWARE\Synaptics\SynTPPlugins\SynTP\, each key's name is ID. There are some unused keys, which can be used for custom key combinations, I've edited default arrow keys (IDs 23-26) templates for this.
To change behavior of action, you should change KeySequence value (which consist of behavior of key pressing and the keys itself). Here's the list for actions you've asked:
Browser back - 0x00000a6
Browser forward - 0x000000a7
Switch to left desktop - 0x30115b25 (ctrl+win+arrow left)
Switch to right desktop - 0x30115b27 (ctrl+win+arrow right)
After you've made changes to these "plugins", you need to assign their IDs to user settings, which are stored in HKEY_**CURRENT_USER**\SOFTWARE\Synaptics\SynTP\*name-and-connection-type-of-device*\, there are separate keys for 3- and 4-finger gestures. ActionID1,3,5,7 are matching swipe up, right, down and left, Action11 for tap, so you should assign ID (in decimal form) of customized plugins for ActionIDs 3 and 7 (note: my touch pad can't recognize 4-finger swipe, so I don't have these ActionIDs available).
To use new settings you should stop all SynTP*.exe processes and start service named SynTPEnhService. Powershell one-liner for that:
Stop-Service "SyntpEnhService"; kill -name SynTPEnh; kill -name SynTPHelper; Start-Service "SynTPEnhService"
I created a reg file starting from chupasaurus answer.
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\SOFTWARE\Synaptics\SynTP\*edit here*\3FingerGestures]
"ActionID1"=dword:00000017
"ActionID3"=dword:00000019
"ActionID5"=dword:00000018
"ActionID7"=dword:0000001A
[HKEY_LOCAL_MACHINE\SOFTWARE\Synaptics\SynTPPlugIns\SynTP\23]
"KeySequence"=dword:000000a6
[HKEY_LOCAL_MACHINE\SOFTWARE\Synaptics\SynTPPlugIns\SynTP\24]
"KeySequence"=dword:000000a7
[HKEY_LOCAL_MACHINE\SOFTWARE\Synaptics\SynTPPlugIns\SynTP\25]
"KeySequence"=dword:3A115b25
[HKEY_LOCAL_MACHINE\SOFTWARE\Synaptics\SynTPPlugIns\SynTP\26]
"KeySequence"=dword:3A115b27
It works for me, just find out the proper name of your folder HKEY_CURRENT_USER\SOFTWARE\Synaptics\SynTP*this-one*.
Mine is a 5 years old laptop, its not fluid, and sometimes it opens the windows menu for no reason. I cannot ask more but other solutions are welcome.
The original answer didn't work on my Windows 10 HP Spectre but azote's answer led me to the solution.
I modified actionid's 3 and 7 under Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Synaptics\SynTP\Win10\3FingerGestures
Then restarted with the powershell command from chupasaurus (below) and voila! Works like a charm and the 3 finger up and down swipes still work too.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Synaptics\SynTP\Win10\3FingerGestures]
"ActionID3"=dword:00000018
"ActionID7"=dword:00000017
[HKEY_LOCAL_MACHINE\SOFTWARE\Synaptics\SynTPPlugIns\SynTP\23]
"KeySequence"=dword:000000a6
[HKEY_LOCAL_MACHINE\SOFTWARE\Synaptics\SynTPPlugIns\SynTP\24]
"KeySequence"=dword:000000a7
Run PowerShell as Admin:
Stop-Service "SyntpEnhService"; kill -name SynTPEnh; kill -name SynTPHelper; Start-Service "SynTPEnhService"
Confirming this actually worked on Windows 10 HP Spectre with Synaptics driver v19.3.11.41.
For the *editme* flag I had to use the "TouchPadSMB2cTM3257" option (TouchPadPS2TM3257 was also installed but did not work)
My contribution (just setting navigate back and forth):
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\SOFTWARE\Synaptics\SynTP\*editme*\3FingerGestures]
"ActionID3"=dword:00000018
"ActionID7"=dword:00000017
[HKEY_LOCAL_MACHINE\SOFTWARE\Synaptics\SynTPPlugIns\SynTP\23]
"KeySequence"=dword:000000a6
[HKEY_LOCAL_MACHINE\SOFTWARE\Synaptics\SynTPPlugIns\SynTP\24]
"KeySequence"=dword:000000a7
Do set the "current user" part in the correct user hive :-)
How to map changing browser-tabs to 3-finger swipe left and right
This isn't so much an answer for the first question (as I feel that's been sufficiently answered), but some information for future reference and others who may want to do the same thing:
ChromeOS has a feature I like of using 3-finger swipe to change between tabs. I spent a few days googling around before I realized all the information I needed was in the comments here.
I didn't change the behavior of 3-swipe up or down, so I only editted ActionID3 and 7. In HKEY_LOCAL_MACHINE\SOFTWARE\Synaptics\SynTPPlugIns\SynTP\25 I changed KeySequence to 20001122 (2-key combo of ctrl+Page Down), and similarly HKEY_LOCAL_MACHINE\SOFTWARE\Synaptics\SynTPPlugIns\SynTP\26\KeySequence to 20001121 (ctrl+PageUp). I was going to use ctrl+tab and ctrl+shift+tab, but none of the pre-existing macros used the tab key so I was unsure what its keysequence-value would be.
With these edits, I then changed ActionID3 to 19 (25 in hex) [i.e. swipe-right = ctrl+Page Down] and ActionID7 to 1A (26 in hex) [i.e. swipe-left = ctrl+Page Up] under the registry entry [HKEY_CURRENT_USER\SOFTWARE\Synaptics\SynTP\ <Your trackpad> \3FingerGestures]
Hopefully someone else finds this useful!
This reg key allowed my lenovo t50 touchpad 3 finger back/forward work again on windows 10:
Windows Registry Editor Version 5.00
[-HKEY_LOCAL_MACHINE\SOFTWARE\Synaptics\SynTP\Win10]
Note: this will also disable the 3 finger up/down gesture.
Reboot after applying regkey.... this works on explorer, chrome, etc
The 4-finger horizontal scrolling settings are in a key not mentioned in any of the other answers (at least for my ThinkPad T460s running Windows 10).
I had the exactly the same query and this is the reg file that solved the problem for me:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Synaptics\SynTP\Win10\3FingerGestures]
"ActionID3"=dword:00000018
"ActionID7"=dword:00000017
[HKEY_LOCAL_MACHINE\SOFTWARE\Synaptics\SynTPPlugIns\SynTP\23]
"KeySequence"=dword:000000a6
[HKEY_LOCAL_MACHINE\SOFTWARE\Synaptics\SynTPPlugIns\SynTP\24]
"KeySequence"=dword:000000a7
[HKEY_LOCAL_MACHINE\SOFTWARE\Synaptics\SynTPEnh\ZoneConfig\Win10\4FHorizontal Scrolling]
"NegativeCustomZoneID"=dword:00000087
"PositiveCustomZoneID"=dword:00000088
And as chupasaurus's answer, run this in PowerShell (admin):
Stop-Service "SyntpEnhService"; kill -name SynTPEnh; kill -name SynTPHelper; Start-Service "SynTPEnhService"
Not at the registry level. I have tried everything. This has to be implemented at the driver level.
The problem is most of the synaptics track pads are do not follow Microsoft's "precision track pad specifications." Hence Microsoft is blocking synaptics ability to enable this feature on their track pads.

Setting the Debug version of the Direct3D runtime won't stick

When I open the DirectX control panel and open the Direct3D 9 tab and set "Use Debug Version of Direct3D 9" and hit "OK" or "Apply," there are no errors. If I open the control panel again, it is back to "Use Retail Version of Direct3D 9." When I try to debug my application, I don't get any output from Direct3D.
When I last did this a few months ago, everything worked correctly and I got debug output.
Running the control panel as Administrator doesn't seem to make a difference and the registry key mentioned here http://www.gamedev.net/topic/514529-cant-use-debug-version-of-direct3d/ is set to one.
What else can I try?
Same thing happened to me. It looks like that TrustedInstaller took ownership of some registry keys (including HKLM/SOFTWARE/Microsoft/Direct3D which dxcpl modifies).
Found a solution here. You just have to change ownership of that regkey.
I've seen this happen and sort of collected best practices to try and get this thing working online - you can try it
1.) There's a separate control panel for x86 and x64 applications in DirectX, There is the DirectX Control Panel which comes with the sdk and there you can set to use the d3d debug runtime and the verbosity level. There is also an option for shader debugging and memory check.
2.) Link against d3dx9d.lib instead of d3dx9.lib
3.) Try adding #pragma comment(lib, "d3dx9d")
4.) Use #define D3D_DEBUG_INFO, but use that before including the d3d9 headers.
5.) Check the Use Debug Version of Direct3D 9 in the properties window like so
http://i.stack.imgur.com/WoZAH.png
6.) Use a tool like DebugView
Sources:
http://www.gamedev.net/topic/514529-cant-use-debug-version-of-direct3d/
https://gamedev.stackexchange.com/questions/24541/cant-get-debug-spew-for-direct3d9
for me the solution was this:
"Looking at the permissions on the key can you not hit the "advanced" button? then click the "owner" tab put a check in the bottom box, then highlight the administrators group, then check "take ownership"."
via: http://www.tomshardware.co.uk/forum/238556-45-cannot-modify-delete-change-permissions-registry
after doing this i was able to give my user full access to HKLM/SOFTWARE/Microsoft/Direct3D and then the ctrlpanel kept its settings.

Firefox browser disable safe mode

I am using Windows 7 and I've been playing with the Firefox browser for a while.
I want to create a kiosk app using it, I installed a plugin for that, but the problem is that when I start the Firefox app, if I press Shift, it enters safe mode.
I read some guides on Google that tell me to edit chrome/browser.jar but I have no such file in my Firefox folder.
I need some help for disabling the feature that lets me enter safe mode by pressing Shift.
You cannot really disable safe mode by editing text files, the handling of the Shift key is inside compiled code. You can however disable the dialog that pops up by removing this code from components/nsBrowserGlue.js:
// check if we're in safe mode
if (Services.appinfo.inSafeMode) {
Services.ww.openWindow(null, "chrome://browser/content/safeMode.xul",
"_blank", "chrome,centerscreen,modal,resizable=no", null);
}
You can also leave extensions enabled in safe mode. For that you will have to also edit modules/XPIProvider.jsm and remove all occurrences of code like:
if (Services.appinfo.inSafeMode)
return false;
Both files can be found inside the onmi.ja archive in the Firefox directory.
That said, the proper solution to this problem would be running your own application on top of XULRunner which would allow you to design your own user interface for kiosk mode. Sadly, Open Kiosk (which is probably what you are using) is ancient and predates XULRunner.
I managed to disable Firefox session restore and safe mode tweaking these two preferences:
browser.sessionstore.resume_from_crash => false
toolkit.startup.max_resumed_crashes => -1

How do I disable the 'Debug / Close Application' dialog on Windows Vista?

When an application crashes on Windows and a debugger such as Visual Studio is installed the following modal dialog appears:
[Title: Microsoft Windows]
X has stopped working
A problem caused the program to stop
working correctly. Windows will close
the program and notify you if a
solution is available.
[Debug][Close Application]
Is there a way to disable this dialog? That is, have the program just crash and burn silently?
My scenario is that I would like to run several automated tests, some of which will crash due to bugs in the application under test. I don't want these dialogs stalling the automation run.
Searching around I think I've located the solution for disabling this on Windows XP, which is nuking this reg key:
HKLM\Software\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger
However, that did not work on Windows Vista.
To force Windows Error Reporting (WER) to take a crash dump and close the app, instead of prompting you to debug the program, you can set these registry entries:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting]
"ForceQueue"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\Consent]
"DefaultConsent"=dword:00000001
After this is set, when your apps crash, you should see *.hdmp and *.mdmp files in:
%ALLUSERSPROFILE%\Microsoft\Windows\WER\
See here:
http://msdn.microsoft.com/en-us/library/bb513638.aspx
regedit
DWORD HKLM or HKCU\Software\Microsoft\Windows\Windows Error Reporting\DontShowUI = "1"
will make WER silently report. Then you can set
DWORD HKLM or HKCU\Software\Microsoft\Windows\Windows Error Reporting\Disabled = "1"
to stop it from talking to MS.
I'm not sure if this refers to exactly the same dialog but here is an alternative approach from Raymond Chen:
DWORD dwMode = SetErrorMode(SEM_NOGPFAULTERRORBOX);
SetErrorMode(dwMode | SEM_NOGPFAULTERRORBOX);
I had to disable this for release automation work on Windows 64-bits for Firefox and I did the following:
gpedit.msc
Computer configuration -> Administrative Templates
Windows Components -> Windows Error Reporting
Set "Prevent display of the user interface for critical errors" to Enabled
It is similar what was accomplished for Customer Experience reporting in:
http://www.blogsdna.com/2137/fix-windows-installer-explorer-update-has-stopped-working-in-windows-7.htm
In my context, I only want to suppress the popup for my unit tests and not for the entire system. I've found that a combination of functions are needed in order to suppress these errors, such as catching unhandled exceptions, suppressing run time checks (such as the validity of the stack pointer) and the error mode flags. This is what I've used with some success:
#include <windows.h>
#include <rtcapi.h>
int exception_handler(LPEXCEPTION_POINTERS p)
{
printf("Exception detected during the unit tests!\n");
exit(1);
}
int runtime_check_handler(int errorType, const char *filename, int linenumber, const char *moduleName, const char *format, ...)
{
printf("Error type %d at %s line %d in %s", errorType, filename, linenumber, moduleName);
exit(1);
}
int main()
{
DWORD dwMode = SetErrorMode(SEM_NOGPFAULTERRORBOX);
SetErrorMode(dwMode | SEM_NOGPFAULTERRORBOX);
SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)&exception_handler);
_RTC_SetErrorFunc(&runtime_check_handler);
// Run your tests here
return 0;
}
In WPF application
[DllImport("kernel32.dll", SetLastError = true)]
static extern int SetErrorMode(int wMode);
[DllImport("kernel32.dll")]
static extern FilterDelegate SetUnhandledExceptionFilter(FilterDelegate lpTopLevelExceptionFilter);
public delegate bool FilterDelegate(Exception ex);
public static void DisableChashReport()
{
FilterDelegate fd = delegate(Exception ex)
{
return true;
};
SetUnhandledExceptionFilter(fd);
SetErrorMode(SetErrorMode(0) | 0x0002 );
}
You have to implement an unhandled exception filter which simply quits your application, then set that filter function with SetUnhandledExceptionFilter().
If you're using the secure CRT, you also have to provide your own invalid parameter handler and set this with _set_invalid_parameter_handler().
This blog post has some information too:
http://blog.kalmbachnet.de/?postid=75
During test you can run with a 'debugger' like ADPlus attached which can be configured in many useful ways to collect data (minidumps) on errors and yet prevent the modal dialog problems you state above.
If you want to get some useful information when your app crashes in production you can configure Microsoft Error reporting to get something similar to ADPlus data.
This isn't a direct answer to the question since this is a workaround and the question is about how to disable that feature, but in my case, I'm a user on a server with limited permissions and cannot disable the feature using one of the other answers. So, I needed a workaround. This will likely work for at least some others who end up on this question.
I used autohotkey portable and created a macro that once a minute checks to see if the popup box exists, and if it does, clicks the button to close the program. In my case, that's sufficient, and leaves the feature on for other users. It requires that I start the script when I run the at-risk program, but it works for my needs.
The script is as follows:
sleep_duration = 60000 ; how often to check, in milliseconds.
; 60000 is a full minute
Loop
{
IfWinExist, ahk_class #32770 ; use autohotkey's window spy to confirm that
; ahk_class #32770 is it for you. This seemed to be consistent
; across all errors like this on Windows Server 2008
{
ControlClick, Button2, ahk_class #32770 ; sends the click.
; Button2 is the control name and then the following
; is that window name again
}
Sleep, sleep_duration ; wait for the time set above
}
edit: A quick flag. When other things are up, this seems to attempt to activate controls in the foreground window - it's supposed to send it to the program in the background. If I find a fix, I'll edit this answer to reflect it, but for now, be cautious about using this and trying to do other work on a machine at the same time.
After trying everything else on the internet to get rid of just in time debugger, I found a simple way that actually worked and I hope will help someone else.
Go to Control Panel
Go to Administrative Tools
Go to Services
Look down the list for Machine Debug Manager
Right Click on it and click on Properties
Under the General Tab, look for Start Up Type
Click on Disable.
Click on Apply and OK.
I haven't seen the debugger message since, and my computer is running perfectly.
Instead of changing values in the registry you can completly disable the error reporting on Windows Server 2008 R2, Windows Server 2012 and Windows 8 with: serverWerOptin /disable
https://technet.microsoft.com/en-us/library/hh875648(v=ws.11).aspx

Resources