Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
押したキーを表示するNILScript
// ==UserScript==
// @name displayInputKeys
// @namespace http://efcl.info/
// @description 押したキーを表示するだけ
// @author azu
// @homepage http://efcl.info/
// @twitter https://twitter.com/azu_re
// ==/UserScript==
Main.createNotifyIcon();
/*ウィンドウの枠はisPopupWindow:true,hasBorder:false,hasTickFrame:false,で消せます*/
var win=require('Window').Window.create({
isPopupWindow:true,hasTickFrame:false,hasBorder:false,hasDlgFrame:false,
//toolWindow:true,
topmost:true,
transparent:true,
transparentColor:0xFF01FF,
alpha:196,
width:0,height:0,
children:{ie:{type:require('ATL').Trident,top:0,left:0,right:0,bottom:0}},
});
win.resize(800,120,true).moveToCenter();
win.ie.update('<body style="margin:0;background-color:#000000;overflow:hidden;text-align:center; font-size:112px;vertical-align:text-top;color:#ffffff;">入力キー</body>');
win.show();
with(require('Keyboard')){
var modify = {
Ctrl: false,
Shift: false,
Alt : false,
};
Keyboard.observe('down',function(e){
// displayKey.text = ' / Name: '+obj.key.name;
var ckey = e.key.name;
var res = [];
if(ckey == "Shift") modify.Shift = true;
if(ckey == "Ctrl") modify.Ctrl = true;
if(ckey == "Alt") modify.Alt = true;
for(var t in modify){
if(modify[t]) res.push(t);
}
if(ckey !== "Ctrl" && ckey !== "Shift" && ckey !== "Alt"){
var displaytext = (res.length>0) ? res.join("+") +"-"+ ckey : ckey;
win.ie.update('<body><div style="background-color:#000000;overflow:hidden;text-align:center; font-size:112px;color:#ffffff;position:absolute;top:50%;left:50%;overflow:auto;width:800px;margin-top:-60px;margin-left:-400px;">'+displaytext+'</div></body>');
}else{
win.ie.update('<body style="margin:0;background-color:#000000;overflow:hidden;text-align:center; font-size:112px;vertical-align:text-top;color:#ffffff;"></body>');
}
}),
Keyboard.observe('up',function(e){
var ckey = e.key.name;
if(ckey == "Shift" || ckey == "Ctrl" || ckey == "Alt"){
modify = {
Ctrl: false,
Shift: false,
Alt : false,
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.