aboutsummaryrefslogtreecommitdiffstats
path: root/morse.js
diff options
context:
space:
mode:
authoranekos2010-02-09 20:35:38 +0000
committeranekos2010-02-09 20:35:38 +0000
commite507f92380d9a6917827309c0b8f409a6092250e (patch)
treec4c2ffa246c485c8982dc2f8bc6ab8c7337b569b /morse.js
parentc085477091db5e1abadf6f59588312b5491a80ce (diff)
downloadvimperator-plugins-e507f92380d9a6917827309c0b8f409a6092250e.tar.bz2
Win以外でもエラーはでないように。
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@36663 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'morse.js')
-rwxr-xr-xmorse.js24
1 files changed, 15 insertions, 9 deletions
diff --git a/morse.js b/morse.js
index 909601b..cd29126 100755
--- a/morse.js
+++ b/morse.js
@@ -201,19 +201,25 @@ let INFO =
'\u30F3': '.-.-.',
};
- Components.utils.import("resource://gre/modules/ctypes.jsm");
- let user32 = ctypes.open('user32.dll');
- let keybd_event =
- user32.declare(
- 'keybd_event',
- ctypes.stdcall_abi,
- ctypes.void_t,
- ctypes.uint8_t, ctypes.uint8_t, ctypes.int32_t, ctypes.int32_t
- );
let [short, long, interval] = [100, 400, 200];
function u (string)
unescape(encodeURIComponent(string));
+ let keybd_event =
+ (function () {
+ try {
+ Components.utils.import("resource://gre/modules/ctypes.jsm");
+ let user32 = ctypes.open('user32.dll');
+ return user32.declare(
+ 'keybd_event',
+ ctypes.stdcall_abi,
+ ctypes.void_t,
+ ctypes.uint8_t, ctypes.uint8_t, ctypes.int32_t, ctypes.int32_t
+ );
+ } catch (e) {
+ return function () "DO NOTHING";
+ }
+ })();
function Morse (short, long, interval) {
function bing (ch, next) {