What's new

Disable the touch screen to use the pen

Francis Beland

New Member
Hello,

One of the thing I really like about the SP3 is the pen integration that is really well done. There is almost no lag and it's very precise. Unfortunately, even with the palm rejection, I had some problems when putting my hand before approaching the pen.

So I decided I needed a quick way to disable the touch screen when I was using Onenote with the pen. I did a little search and here is the way I did it.

To disable the touch screen, you need to go in Device Manager and disable the HID-compliant touch screen under Human Interface Devices. The pen and keyboard will still be usable. Since I wanted the process to be shorter, I decided to write a Powershell script tu automate both tasks of disabling and enable the touch screen.

Powershell
First of all, if you want to run a script in ps1 format (which is Powershell script file extension), you need to change the way Powershell run script by using the set-execution policy. To do it, open Powershell in admin mode (Right-Click Powershell and click run as administrator) and type the following code (only once):

Code:
Set-ExecutionPolicy RemoteSigned

To disable and enable devices in the device manager in Powershell, you need to download the Device Management PowerShell Cmdlets module available here: https://gallery.technet.microsoft.com/scriptcenter/Device-Management-7fad2388 . Once downloaded, unzip it to any folder but take note of the exact path since you'll need it in the script.

Once done, you can start the Script. The script is quite simple:
Code:
$devicemgmtmodule = "c:\path\DeviceManagement.psd1"
import-module $devicemgmtmodule
get-device | where-object -property name -eq "HID-compliant touch screen" | disable-device

The "path" is the path of the file you unzipped earlier.

To create the enable device script, use the same code but at the end, put enable-device.

**EDIT** Windows Language modification
Please note that if you're using Windows in another language, you will have to change the "HID-compliant touch screen" in the script with what it's called in your language. Please send me a PM your language specific device name and I will add it here.

English: "HID-compliant touch screen"
Français: "Écran tactile HID"


UAC
As you probably know, UAC is the little popup you receive when you try to do something that require elevated privileges. Disabling and Enabling devices are things that need elevated privileges to do. If you disabled UAC, please disregard this part but I wanted to keep it.

When you run a Powershell script, it won't ask you to elevate into admin mode but it only gives you an error. You need to elevate your privileges inside the Powershell script. I found this script there : http://blogs.msdn.com/b/virtual_pc_guy/archive/2010/09/23/a-self-elevating-powershell-script.aspx
You just need to copy the code and paste it at the start of your script to get the UAC popup when running it.

From now on, you can right-click on the ps1 script and click "Run with Powershell". However, if you double-click on a ps1 file, it open Notepad to edit it. Since I wanted a fastest way to open it, I created a batch file to call Powershell and run the ps1 script.

Batch File

Here is the code of my batch file which is quite simple:
Code:
powershell.exe -file C:\path\Disable_TouchScreen.ps1
I then save it as a .bat file.

Pin it to start menu
When you right-click a bat file, you don't have the option of "Pin it to start". To make it available in the MetroUI menu, you need to copy the shortcuts of both batch files (disable.bat and enable.bat) to the following path: C:\Users\user\AppData\Roaming\Microsoft\Windows\Start Menu

You can now open you MetroUI, Swipe down the the Apps by name and you will see both shortcuts. You can now right-click on them and select "Pin to Start".

Please note that when the touch screen is disabled, the pen, the keyboard (including touchpad) and the Home button on the tablet are still active and can be used. I hope it can help some people if they have the same problem.
 
Last edited:

Bill Slaunwhite

New Member
Thank you for the script, I will definitely try it out. I get clients to sign documents on my SP3 frequently and sometimes the palm rejection doesn't always work and they back off saying "oh, did I do something wrong?". They haven't of course, so if I can remove that moment front the signing process then it becomes more comfortable. Thanks! I will let you know how it goes!
 
OP
F

Francis Beland

New Member
Thanks for the comment. I'm sure your clients will be happier to sign on your tablet with the touch screen disabled. When I go in a meeting, disabling the touch screen is the first thing I do.
 

ydejes

New Member
Hello. I followed your directions and got stuck at the UAC and batch file. If the powershell code was to create a script .ps1, it did not, resulting in not being able to create the batch file. I would like help to proceed. I think this script is wonderful!

Please and Thank you :)
 
OP
F

Francis Beland

New Member
No the script won't create the batch file. You need to do it manually. First, open Powershell ISE in Windows and go get the UAC elevation script from the link above. Copy everything to "# Run your code that needs to be elevated here" (So don't copy the 2 last lines). Paste it in the upper pane in Powershell ISE. At the end of it, paste the following code:

Code:
$devicemgmtmodule = "c:\path\DeviceManagement.psd1"
import-module $devicemgmtmodule
get-device | where-object -property name -eq "HID-compliant touch screen" | disable-device

In the first line, path is where the DeviceManagement.psd1 file you downloaded earlier is saved.

In ISE, save the script in PS1 format. You then need to create the batch file that will call the Powershell Script. I hope everything is clear. If not, don't hesitate to reply.
 

rquellet

Member
Hello,

One of the thing I really like about the SP3 is the pen integration that is really well done. There is almost no lag and it's very precise. Unfortunately, even with the palm rejection, I had some problems when putting my hand before approaching the pen.

So I decided I needed a quick way to disable the touch screen when I was using Onenote with the pen. I did a little search and here is the way I did it.

To disable the touch screen, you need to go in Device Manager and disable the HID-compliant touch screen under Human Interface Devices. The pen and keyboard will still be usable. Since I wanted the process to be shorter, I decided to write a Powershell script tu automate both tasks of disabling and enable the touch screen.

Powershell
First of all, if you want to run a script in ps1 format (which is Powershell script file extension), you need to change the way Powershell run script by using the set-execution policy. To do it, open Powershell in admin mode (Right-Click Powershell and click run as administrator) and type the following code (only once):

Code:
Set-ExecutionPolicy RemoteSigned

To disable and enable devices in the device manager in Powershell, you need to download the Device Management PowerShell Cmdlets module available here: https://gallery.technet.microsoft.com/scriptcenter/Device-Management-7fad2388 . Once downloaded, unzip it to any folder but take note of the exact path since you'll need it in the script.

Once done, you can start the Script. The script is quite simple:
Code:
$devicemgmtmodule = "c:\path\DeviceManagement.psd1"
import-module $devicemgmtmodule
get-device | where-object -property name -eq "HID-compliant touch screen" | disable-device

The "path" is the path of the file you unzipped earlier.

To create the enable device script, use the same code but at the end, put enable-device.

UAC
As you probably know, UAC is the little popup you receive when you try to do something that require elevated privileges. Disabling and Enabling devices are things that need elevated privileges to do. If you disabled UAC, please disregard this part but I wanted to keep it.

When you run a Powershell script, it won't ask you to elevate into admin mode but it only gives you an error. You need to elevate your privileges inside the Powershell script. I found this script there : http://blogs.msdn.com/b/virtual_pc_guy/archive/2010/09/23/a-self-elevating-powershell-script.aspx
You just need to copy the code and paste it at the start of your script to get the UAC popup when running it.

From now on, you can right-click on the ps1 script and click "Run with Powershell". However, if you double-click on a ps1 file, it open Notepad to edit it. Since I wanted a fastest way to open it, I created a batch file to call Powershell and run the ps1 script.

Batch File

Here is the code of my batch file which is quite simple:
Code:
powershell.exe -file C:\path\Disable_TouchScreen.ps1
I then save it as a .bat file.

Pin it to start menu
When you right-click a bat file, you don't have the option of "Pin it to start". To make it available in the MetroUI menu, you need to copy the shortcuts of both batch files (disable.bat and enable.bat) to the following path: C:\Users\user\AppData\Roaming\Microsoft\Windows\Start Menu

You can now open you MetroUI, Swipe down the the Apps by name and you will see both shortcuts. You can now right-click on them and select "Pin to Start".

Please note that when the touch screen is disabled, the pen, the keyboard (including touchpad) and the Home button on the tablet are still active and can be used. I hope it can help some people if they have the same problem.

Thanks for posting this. I will give it a try.

I wish Microsoft would issue a fix for the palm rejection problems so we don't have to hack around the problem.
 

rquellet

Member
Do you think it would be possible to execute this script when I press the button onto the top of the pen? That would make it really convenient!
 

vxm

Active Member
Hello @Francis Beland
I've tried making this script on my machine, since I frequently get random brush strokes in Corel Painter when laying my hand on screen. I've followed your guide and I'm receiving an error in PowerShell:
UKVDsDh.png

I'm green when it comes to scripting ( written few lines of script in ubuntu few years back when I needed touch on graphics tablet disabled for pretty much same reason, but it was copy pasting commands, so not much knowledge on my part). I'm not quite sure what to do from here. My script looks like that:
d5KBnCR.png


I'm almost certain it's something trivial, but can't be sure.

Cheers!
 
OP
F

Francis Beland

New Member
Hello @Francis Beland
I've tried making this script on my machine, since I frequently get random brush strokes in Corel Painter when laying my hand on screen. I've followed your guide and I'm receiving an error in PowerShell:
UKVDsDh.png

I'm green when it comes to scripting ( written few lines of script in ubuntu few years back when I needed touch on graphics tablet disabled for pretty much same reason, but it was copy pasting commands, so not much knowledge on my part). I'm not quite sure what to do from here. My script looks like that:
d5KBnCR.png


I'm almost certain it's something trivial, but can't be sure.

Cheers!

Hi @vxm

I'm sorry I just saw your message on the topic. I hope you found your solution but if not, I did check for the error and I think you have to "unblock" the zip file you've downloaded before extracting it to the folder. Please see the following link: http://blogs.msdn.com/b/brada/archi...ported-exception-from-hresult-0x80131515.aspx

I did not have to do it but I'm confident it will solve your problem.
 

vxm

Active Member
Hey @Francis Beland
I solved it quite some time ago, while I do not remember exactly how, it was about those additional commands not working- I found walkthrough on how to properly use Cmdlets and used solution from there, then it went without problems. As I wrote- I probably did something wrong in first place and didn't see it as I've very limited knowledge on Powershell and commands.

I'm using your script succesfully for some time now, it's priceless with software with bad hand rejection :)
 
Top