Disable Windows 8 edge gestures/hot corners for multi-touch applications while running in full screen
Asked Answered
V

4

13

I have a full screen AS3 game maby with Adobe AIR that runs in Windows 7. In this game it may not be easy to exit (think about kiosk mode, only exit by pressing esc and enter a password).

Now I want this game to run in Windows 8. The game is working like expected but the anoying things are these edge gestures/hot corners (left, top, right, bottom) and the shortcuts.

I've read articles but none helped me. People talk about registery edits, but I dont get this working + the user needs to restart his/hers computer.

I want to open my game, turn off gestures/hot corners and when the game closes the gestures/hot corners need to come back available again.

I have seen some applications doing the same what I want to accomplish.

I found this so I am able to detect the gestures. But how to ignore they're actions?

I also read ASUS Smart Gestures but this is for the touch-pad.

And I have tried Classic Shell but I need to disable the edge gestures/hot corners without such programs, just on-the-fly.

I also found this but I don't know how to implement this.

HRESULT SetTouchDisableProperty(HWND hwnd, BOOL fDisableTouch)
{
    IPropertyStore* pPropStore;
    HRESULT hrReturnValue = SHGetPropertyStoreForWindow(hwnd, IID_PPV_ARGS(&pPropStore));
    if (SUCCEEDED(hrReturnValue))
    {
        PROPVARIANT var;
        var.vt = VT_BOOL;
        var.boolVal = fDisableTouch ? VARIANT_TRUE : VARIANT_FALSE;
        hrReturnValue = pPropStore->SetValue(PKEY_EdgeGesture_DisableTouchWhenFullscreen, var);
        pPropStore->Release();
    }
    return hrReturnValue;
}

Does anyone know how I can do this? Or point me into the right direction?

I have tried some in C# and C++, but I aint a skilled C#/C++ developer. Also the game is made in AS3 so it will be hard to implement this in C#/C++.

I work on the Lenovo aio (All in one) with Windows 8.

Variorum answered 20/11, 2012 at 10:47 Comment(9)
not exactly an answer but is this allowed under the Windows 8 UI rules? or is this being made for use outside of the Store?Spiller
As far as I know this is allowed for fullscreen/non store apps. As the MSDN document says "This property has no effect on Windows Store apps.".Visa
My app will not be available in the shop. This is a game that currently runs on windows 7. Only difference in windows 8 are these anoying edgesVariorum
Maybe call the function with the Window Handle and a boolean value? ULONG result; result = SetTouchDisableProperty(GetForegroundWindow(), true); or similar? Not sure haven't been doing desktop apps.Margherita
Are you asking how to implement SetTouchDisableProperty in C#? ie. with a DllImport call to SHGetPropertyStoreForWindow and COM calls to SetValue and Release.Batson
Well I know that the piece of code is C++. But how and where to implement I don't know. Also I don't know what template to choose for these operations. I want to run this app in the background of my Game (game is made in AS3)Variorum
No chance of just using windows 7 on your kiosks?Pontianak
No, I can't expect users to use windows 7 mode to run my game.Variorum
How did you solve it? with a batch?Gaucherie
A
4

I'm trying to do the same thing. The C++ below disables Win8 Gestures on every running application/window. As JonoRR mentioned, the next step would be calling it only on the HWND you would like to target. If the targeted application is closed, then re-opened, the gestures will return.

#include "stdafx.h"
#include <windows.h>
#include <iostream>
#include <propsys.h>
#include <propkey.h>

using namespace std;

HWND windowHandle;

HRESULT SetTouchDisableProperty(HWND hwnd, BOOL fDisableTouch)
{
    IPropertyStore* pPropStore;
    HRESULT hrReturnValue = SHGetPropertyStoreForWindow(hwnd, IID_PPV_ARGS(&pPropStore));
    if (SUCCEEDED(hrReturnValue))
    {
        PROPVARIANT var;
        var.vt = VT_BOOL;
        var.boolVal = fDisableTouch ? VARIANT_TRUE : VARIANT_FALSE;
        hrReturnValue = pPropStore->SetValue(PKEY_EdgeGesture_DisableTouchWhenFullscreen, var);
        pPropStore->Release();
    }
    return hrReturnValue;
}

BOOL CALLBACK MyEnumProc(HWND hWnd, LPARAM lParam)
{
    TCHAR title[500];
    ZeroMemory(title, sizeof(title));    

    GetWindowText(hWnd, title, sizeof(title)/sizeof(title[0]));
    SetTouchDisableProperty(hWnd,true);

    _tprintf(_T("Value is %s\n"), title);

    return TRUE;
}

int _tmain(int argc, _TCHAR* argv[])
{   
    EnumWindows(MyEnumProc, 0);
    return 0;
}
Appendicectomy answered 9/2, 2013 at 0:48 Comment(0)
R
7

I am making a kiosk application for windows 8 using C#, I succesfully disabled the swipe gestures by killing the explorer process when the program starts up. I don't know how it's done in C++ but in C# it's like this.

var explorers = Process.GetProcessesByName("explorer");
            foreach (var explorer in explorers) {
                explorer.Kill();
            }

On the closing event of my program I just start the process again.

Process.Start("explorer.exe");

Before this works you might have to edit your register to prevent explorer from restarting after you kill it.

In regedit go to

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon

Set the AutoRestartShell to 0.

Rowley answered 21/3, 2013 at 9:13 Comment(1)
You sir I my hero. I've used this approach to create a successful chrome kiosk app. Thank youCourlan
P
6

(as long as your running off AIR - which it sounds like) You can use AIR 2.0's NativeProcess to execute it.

From there I can think of two solutions:

  1. If there are command line options in Classic Shell, call it from within your AS3 and toggle the gestures on/off through it.

  2. Write a C++ application that toggles the gestures on/off manually.

If you can get that example working in C++, add a bit to the C++ to handle a on/off command line argument and call the C++ exe on initialization and exit of your AS3 application to toggle.

I don't have C++ installed here (at work), but it looks like that C++ function just requires the window handle of your application (hWnd). This tutorial should get you compiled and running, but the window handle you see there will be for the C++ application's window.

Accessing the flash window's handle will be slightly more difficult:

Either way you'll need to use the Process name or ID to identify it as your AS3 process.

This solution also depends on your ability to install things other than the AIR app on the client PC. (ie .NET runtimes, C++ runtimes, Classic Shell installer)

Pontianak answered 29/11, 2012 at 2:30 Comment(2)
I'd be glad to help with the C++/.NET/windows handle stuff, but not until later on tonight (3.30pm here) - you wouldn't believe how much custom, hacky solutions like this we had to work in when I was working with AS3 and kiosks.Pontianak
Thanks for this helpfull answer. Yes my game runs with Adobe Air. CLassic Shell program you mean? If so I can't expect users to have it installed. I tried to create the C++ application and I downloaded the Windows Hello World Sample but this example doesn't work proper in Windows 8. If I paste my above piece of code in this Hello World Sample I see that IPropertyStore doesn't exists. I have found IPropertyStorage but this (Interface?) does not contain pPropStore->SetValue I have never worked with C++, which looks realy hard to me.Variorum
A
4

I'm trying to do the same thing. The C++ below disables Win8 Gestures on every running application/window. As JonoRR mentioned, the next step would be calling it only on the HWND you would like to target. If the targeted application is closed, then re-opened, the gestures will return.

#include "stdafx.h"
#include <windows.h>
#include <iostream>
#include <propsys.h>
#include <propkey.h>

using namespace std;

HWND windowHandle;

HRESULT SetTouchDisableProperty(HWND hwnd, BOOL fDisableTouch)
{
    IPropertyStore* pPropStore;
    HRESULT hrReturnValue = SHGetPropertyStoreForWindow(hwnd, IID_PPV_ARGS(&pPropStore));
    if (SUCCEEDED(hrReturnValue))
    {
        PROPVARIANT var;
        var.vt = VT_BOOL;
        var.boolVal = fDisableTouch ? VARIANT_TRUE : VARIANT_FALSE;
        hrReturnValue = pPropStore->SetValue(PKEY_EdgeGesture_DisableTouchWhenFullscreen, var);
        pPropStore->Release();
    }
    return hrReturnValue;
}

BOOL CALLBACK MyEnumProc(HWND hWnd, LPARAM lParam)
{
    TCHAR title[500];
    ZeroMemory(title, sizeof(title));    

    GetWindowText(hWnd, title, sizeof(title)/sizeof(title[0]));
    SetTouchDisableProperty(hWnd,true);

    _tprintf(_T("Value is %s\n"), title);

    return TRUE;
}

int _tmain(int argc, _TCHAR* argv[])
{   
    EnumWindows(MyEnumProc, 0);
    return 0;
}
Appendicectomy answered 9/2, 2013 at 0:48 Comment(0)
C
1

The answer below is based on Dovogja's brilliant answer, but it uses a batch file to do it. This way you just have to launch with a launch.bat

Windows charms bar is operated by explorer.exe. So if your app can run without it then you can hack around it by first disabling the autorestart of explorer.exe via (run as administrator):

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "AutoRestartShell" /t REG_DWORD /d 0

Then the lines below represent my launch.bat - which works in the end as expected:

;; kill explorer (this disables all windows functionalities
taskkill /f /im explorer.exe

;; start your kiosk app - should block the batch execution (so explorer.exe doesn't get executed at the end)
"\path\to\your\app.exe"

;; after you close both the app window and the opened chrome window relaunch explorer.exe to give back the functionality to windows
explorer.exe

I use the approach outlined above to let a keyboardless kiosk app run. Because with a keyboard you can still close the app with alt+f4.

Courlan answered 26/8, 2014 at 7:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.