StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
eugenes  
#1 Posted : Wednesday, April 19, 2023 2:09:38 PM(UTC)
eugenes

Rank: Member

Reputation:

Groups: Approved
Joined: 12/2/2019(UTC)
Posts: 20

Thanks: 2 times
Hi

Could anyone please create a script which enables/disables the touch screen with a hotkey?

Thanks
Rob  
#2 Posted : Thursday, April 20, 2023 12:11:37 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,359
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
https://learn.microsoft..../drivers/devtest/pnputil

I would recommend you look into the PnPUtil command line app. It has the ability to disable and enable devices.

So you just have to get the correct command lines worked out, then you can call it from S+
eugenes  
#3 Posted : Thursday, April 20, 2023 4:01:53 AM(UTC)
eugenes

Rank: Member

Reputation:

Groups: Approved
Joined: 12/2/2019(UTC)
Posts: 20

Thanks: 2 times
So, these commands work for me

pnputil /disable-device "HID\ELAN9009&COL01\5&8EBB0E5&0&0000"
pnputil /enable-device "HID\ELAN9009&COL01\5&8EBB0E5&0&0000"

How do I call them from S+?

And how to check the device status to find out which command to run (disable or enable)?
Rob  
#4 Posted : Thursday, April 20, 2023 7:58:54 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,359
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
So this should work, however to enable or disable a device requires elevated privileges (which makes sense), so you will get a UAC prompt.
Code:
// Check the status of the device
var p = new System.Diagnostics.Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "C:\\Windows\\System32\\pnputil.exe";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.Arguments = '/enum-devices /instanceid "HID\\ELAN9009&COL01\\5&8EBB0E5&0&0000"';
p.Start();
var output = p.StandardOutput.ReadToEnd();
p.WaitForExit();

var deviceEnabled = output.includes('Status:                     Started');

// Toggles enable/disable device
// Has to be run as admin, though (UAC promt)
p.StartInfo.RedirectStandardOutput = false;
p.StartInfo.UseShellExecute = true;
p.StartInfo.Verb = "runas";
p.StartInfo.FileName = "C:\\Windows\\System32\\cmd.exe";
p.StartInfo.Arguments = `/C pnputil.exe /${deviceEnabled ? 'disable' : 'enable'}-device /instanceid "HID\\ELAN9009&COL01\\5&8EBB0E5&0&0000"`;
p.Start();
eugenes  
#5 Posted : Thursday, April 20, 2023 9:46:22 AM(UTC)
eugenes

Rank: Member

Reputation:

Groups: Approved
Joined: 12/2/2019(UTC)
Posts: 20

Thanks: 2 times
Had to fix something and then it worked. Thank you!
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.