5

This question is asked alot, but I couldnt find working method / way to do it - except for a third party application.
I am pretty sure, or atleast I am being very hopeful that solution for this problem does exist.

As the title says, I want to disable window 8 gestures just like every third app is doing (SkipMetroSuite, ClassicShellMenu or w/e).

I need it to be built in in my app because I cant install anything on the compter my app is dedicated to but my app itself...

Is there a way to do it in C#?

EDIT:
I personally asked the developer of Classic Shell Menu how his programs works, here is the answer:

The principle is to inject a message hook in the thread of window with class “ApplicationManager_DesktopShellWindow”, then listen for mouse messages sent to windows with class “EdgeUiInputWndClass”, and hide those windows. When my program exists it reshows all windows that it has hidden.

He also mentioned I can find the solution here: Classic Shell src

But there's one problem, the solution is in c++ and I have no Idea how to port it to c# so I would appreciate your help.
The solution is in ClassicStartMenuDLL.cpp which is in ClassicStartMenuDLL Solution.

Ron
  • 3,975
  • 17
  • 80
  • 130
  • Although I think I understand your question, your title is misleading, making this sound like a 'windows usage' question, rather than a programming question (which is probably why it got down-voted) – Stefan Z Camilleri Dec 14 '13 at 13:49
  • You of course cannot do this from just your own app. – Hans Passant Dec 14 '13 at 14:20
  • @HansPassant How come the 3rd party apps can? – Ron Dec 14 '13 at 14:56
  • 2
    Because users don't mind rebooting their machine after they *voluntarily* allowed such an app to mess with their registry. – Hans Passant Dec 14 '13 at 15:17
  • What do you mean by "the computer my app is dedicated to"? Are you looking for kiosk mode? All edge gestures are disabled then. See http://windows.microsoft.com/en-us/windows-8/assigned-access – Kris Vandermotten Dec 20 '13 at 13:06
  • @KrisVandermotten My app is in WPF, I cant use kiosk mode on WPF app or else I would do it long time ago – Ron Dec 20 '13 at 13:25
  • possibly duplicate http://stackoverflow.com/questions/12415886/is-there-a-method-for-disabling-gestures-for-windows8 – Sheng Jiang 蒋晟 Dec 21 '13 at 00:24
  • @ShengJiang蒋晟 I said this question is asked alot so of course you will find "duplicates", but I also said there's no satisfying answer, at least in C# – Ron Dec 21 '13 at 11:14
  • @Ron find which function to use is the hard part. Once you found the function, just search the function name plus C#. Most likely you would find someone else called the function from C#. – Sheng Jiang 蒋晟 Dec 21 '13 at 13:26
  • @Ron if the author allows it, you don't need to port his code to C#, but you merely need to include his dll and call his methods via DllImport – Stefan Z Camilleri Dec 22 '13 at 10:40
  • @StefanZCamilleri Its a bit late because I used 3rd party app until now. I've never called methods via DllImport (which is not system dll, and also I took the calls from the internet) so I dont really know how to do it. Could you link a reference I could learn from or show me yourself? – Ron Jan 20 '14 at 18:45
  • @Ron here you go -> http://msdn.microsoft.com/en-us/library/aa288468(v=vs.71).aspx – Stefan Z Camilleri Jan 20 '14 at 21:39

1 Answers1

5

The first step to what you want to do is to disable Metro mode (the start screen tiles).

You can achieve this via a registry edit, which you can do programmatically.

The entry of interest is the following:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RPEnabled

You need to set this to 0

Next, you want to disable the 'hot corners'. This is also a registry edit which can be done programmatically.

The entry of interest is the following:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ImmersiveShell

Create a new key called EdgeUI, and under thay key create the following DWORD entries:

  • DisableTLcorner
  • DisableTRcorner (Windows 8.1+)
  • DisableCharmsHint

Set both values to 1

Since these are both HKCU settings (i.e. current user), then a simple log-off is all that is required for them to take effect.

Alternatively you can kill the explorer process, though it is not recommended.

If it is not working for you, try to test it with a ready-made registry file first, since you might be doing something wrong -> Disable Charms & Switcher

Stefan Z Camilleri
  • 4,016
  • 1
  • 32
  • 42
  • I had actually blogged about this here -> http://edd.stefancamilleri.com/2011/09/23/restore-start-menu-in-windows-8-developer-preview/ – Stefan Z Camilleri Dec 14 '13 at 13:53
  • It requires Reboot to take effect? – Ron Dec 14 '13 at 13:59
  • Yes, unfortunately so... yet you can enforce a reboot as part of your installation process, which is a normal thing to do. – Stefan Z Camilleri Dec 14 '13 at 14:03
  • How come the 3rd party apps such as the apps I mentioned do not require reboot (I assume they are not using registery) – Ron Dec 14 '13 at 14:55
  • I'm not too sure, yet a quick search for both apps that you mentioned shows that neither of them works very well prior to a reboot. These settings are configuration parameters for the shell, which is already running, so I'd be surprised if it was actually polling for changes. – Stefan Z Camilleri Dec 14 '13 at 15:18
  • Maybe killing the `explorer.exe` and starting it again would already be enough? – Kimmax Dec 16 '13 at 09:55
  • That might be an approach. – Stefan Z Camilleri Dec 16 '13 at 12:32
  • Those are both HKCU settings, can either force a logoff (graceful method) or taskkill explorer (brute method). Most apps use the brute method, but I don't prefer it. – Knuckle-Dragger Dec 17 '13 at 12:37
  • There's no such value called "RPEnabled" or folder in the Explorer folder as u said. About the other ones, I set them to 1 but nothing happened (as Admin said, u dont need to restart/kill the explorer.exe - but I tried it as well and it didnt work) – Ron Dec 19 '13 at 11:30
  • You need to create it, it's a dword – Stefan Z Camilleri Dec 19 '13 at 14:54
  • I have just tried it on my machine, and it works Ron :( Are you getting any error in particular? – Stefan Z Camilleri Dec 21 '13 at 11:09
  • @StefanZCamilleri Not getting an error. I set the RPEnabled, DisableTLcorner and DisableCharmsHint but it do nothing. Didnt skip the start menu & didnt disable the hot corners. I also tried the Registry file you edited in your comment but it didnt work aswell – Ron Dec 21 '13 at 11:12
  • I just added a link to a ready-made registry patch... can you try with that first? Just to make sure these changes work on your machine. – Stefan Z Camilleri Dec 21 '13 at 11:13
  • @StefanZCamilleri I edited my question before you answered, I did try it and it didnt work. – Ron Dec 21 '13 at 11:15
  • @StefanZCamilleri ofcourse I did. before I made any change I also disabled the Classic Menu Shell so they wont collide – Ron Dec 21 '13 at 11:19
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/43664/discussion-between-stefan-z-camilleri-and-ron) – Stefan Z Camilleri Dec 21 '13 at 11:20
  • @StefanZCamilleri I tried the comparison method but I couldnt find the difference that actually makes the difference. maybe it is not using the Registry and thats why I cant find it? – Ron Dec 21 '13 at 13:37
  • Quite possibly... but I'm afraid that other than this I don't know now :( – Stefan Z Camilleri Dec 21 '13 at 13:38
  • @StefanZCamilleri Why guessing? I asked personally the developer of Classic Shell Menu and here's the answer "The principle is to inject a message hook in the thread of window with class “ApplicationManager_DesktopShellWindow”, then listen for mouse messages sent to windows with class “EdgeUiInputWndClass”, and hide those windows. When my program exists it reshows all windows that it has hidden." Ofcourse I have no Idea how to do it – Ron Dec 21 '13 at 17:19
  • Aha... that's more of a hack really, but I guess it'll work. It's tricky, you need to use P/Invoke through user32.dll and use the SetWinEventHook to capture that event -> http://msdn.microsoft.com/en-us/library/windows/desktop/dd373640(v=vs.85).aspx – Stefan Z Camilleri Dec 21 '13 at 17:46