禁用或解除触摸板或鼠标的程序

//RUNAS//
import win.ui;
/*DSG{{*/
mainForm = win.form(text="禁用触摸板";right=757;bottom=503;max=false)
mainForm.add(
buttonJiechu={cls="button";text="解除禁用";left=560;top=120;right=696;bottom=144;z=6};
buttonTrue={cls="button";text="确认禁用";left=400;top=120;right=536;bottom=144;z=4};
buttonshowfile={cls="button";text="显示配置文件";left=624;top=448;right=712;bottom=472;z=10};
comboboxchoose={cls="combobox";left=144;top=88;right=528;bottom=112;edge=1;items={};mode="dropdown";z=2};
richeditresult={cls="richedit";left=48;top=152;right=704;bottom=200;edge=1;multiline=1;readonly=1;z=9};
richedittips={cls="richedit";left=48;top=240;right=704;bottom=440;edge=1;multiline=1;readonly=1;z=8};
static={cls="static";text="触摸板或鼠标禁用/启用";left=192;top=8;right=584;bottom=56;color=255;font=LOGFONT(h=-35);transparent=1;z=1};
static2={cls="static";text="****配置文件生成在与此软件在同级目录,默认打开此软件会隐藏配置文件";left=320;top=480;right=728;bottom=496;transparent=1;z=11};
static3={cls="static";text="请选择要禁用的设备:";left=16;top=88;right=136;bottom=112;transparent=1;z=3};
static4={cls="static";text="开启此程序的情况下,按快捷键解除所有鼠标禁用限制ctrl+9";left=112;top=192;right=640;bottom=248;align="center";center=1;color=255;font=LOGFONT(h=-19;underline=1);transparent=1;z=5};
static5={cls="static";text="Copyright (C) China CiscoLee 2024";left=48;top=480;right=240;bottom=504;transparent=1;z=7}
)
/*}}*/

import console;
import sys.device;
import process.devcon;

//额外方法,增加可修改方法
import fsys.ini;
import fsys;

//配置文件
var ini = fsys.ini("./mydev.ini");
var ClassInfor = ini.read("tab","ClassInfor");
if(null == ClassInfor){
    ini.write("tab","ClassInfor","{4D36E96F-E325-11CE-BFC1-08002BE10318}");
}

//隐藏配置文件
fsys.setAttributes("./mydev.ini",2/*_FILE_ATTRIBUTE_HIDDEN*/)


// 查找所有触摸板设备
var devices = sys.device(ini.read("tab","ClassInfor")/*_GUID_DEVCLASS_MOUSE*/);


//遍历所有设备,并加入选择框
// 遍历找到的触摸板设备
for( index,deviceDesc,hardwareId,T in devices.each( 
    0/*_SPDRP_DEVICEDESC*/, // 添加返回值 deviceDesc
    1/*_SPDRP_HARDWAREID*/ // 添加返回值 hardwareId
    ) ){  
    mainForm.comboboxchoose.add(hardwareId[1]);
    mainForm.richedittips.appendText(index+"号设备描述:"+deviceDesc+'\r\n');
    mainForm.richedittips.appendText(index+"号设备ID:"+hardwareId[1]+'\r\n');
}

//确认禁用按钮
mainForm.buttonTrue.oncommand = function(id,event){
    // 遍历找到的触摸板设备
for( index,deviceDesc,hardwareId,T in devices.each( 
    0/*_SPDRP_DEVICEDESC*/, // 添加返回值 deviceDesc
    1/*_SPDRP_HARDWAREID*/ // 添加返回值 hardwareId
    ) ){  
    //根据选择的选项进行禁用 
    if(mainForm.comboboxchoose.selText==""+hardwareId[1]+""){
        // 禁用触摸板
        process.devcon.disable(hardwareId[1]);
        mainForm.richeditresult.text="您已禁用"+hardwareId[1]+"设备";
    } 
}//for结束

}//确认禁用结束

//按快捷键解除禁用
mainForm.reghotkey( function(id,mod,vk){
// 再次遍历设备以启用触摸板
    for( index,deviceDesc,hardwareId,T in devices.each(0,1) ){  
        process.devcon.enable(hardwareId[1]); // 启用触摸板
        mainForm.richeditresult.text="您已启用所有触摸板及鼠标设备";
    }
},0x2/*_MOD_CONTROL*/,'9'#);

//
mainForm.buttonJiechu.oncommand = function(id,event){
    // 再次遍历设备以启用触摸板
    for( index,deviceDesc,hardwareId,T in devices.each(0,1) ){  
        process.devcon.enable(hardwareId[1]); // 启用触摸板
        mainForm.richeditresult.text="您已启用所有触摸板及鼠标设备";
    }
}

mainForm.buttonshowfile.oncommand = function(id,event){
    fsys.setAttributes("./mydev.ini",0x80/*_FILE_ATTRIBUTE_NORMAL*/);
}

mainForm.show();
return win.loopMessage();

 

posted @ 2024-08-13 21:48  CiscoLee  阅读(40)  评论(0编辑  收藏  举报