Created
November 23, 2010 23:42
-
-
Save cherenkov/712790 to your computer and use it in GitHub Desktop.
Nilscript - 今日の日付を入力するショートカットキーを登録する。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
todaystamp.ng - @cherenkov | |
今日の日付を入力するショートカットキーを登録するNilscript。 | |
Ctrl+Dで実行。 | |
2010年1月15日の場合は20100115となる。 | |
*/ | |
Main.observe("exit",function()println("main thread is correctly terminating")); | |
/* | |
コンソールウィンドウがコンテキストメニューを表示しているときなどに出力しようとすると、 | |
コンテキストメニューが消えて表示を更新できるようになるまで処理がブロックされてしまうので、 | |
割り当て動作中から動作確認などのためにprintln()を呼び出したい場合は、 | |
このように非同期化しておくのが望ましい。 | |
*/ | |
println=function(s)(Thread.create(function()Main.stdout.writeLine(s))); | |
//終了操作のためのタスクトレイアイコン | |
Main.createNotifyIcon(); | |
//安定性向上のため推奨 | |
Main.process.priority=Process.priority.high; | |
//ここから | |
//output ex => "20100911" | |
function strDate() { | |
function z(num) { | |
return (num < 10) ? "0" + num : num; | |
} | |
let d = new Date(); | |
let year = d.getFullYear(); | |
let month = z(d.getMonth() + 1); | |
let date = z(d.getDate()); | |
return "" + year + month + date; | |
} | |
require('Hotstrokes').Hotstrokes.use( | |
'IME' | |
).map({ | |
"Ctrl+D": function() { | |
this.IMETurnOff().cancel().reset().send([strDate()]); | |
} | |
}).register(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment