コード例 #1
0
 private void timeElapsed(object sender, ElapsedEventArgs e)
 {
     this.Invoke(new Action(() =>
     {
         try
         {
             BasicHook.UnhookWindowsHookEx(hook);
             hook = BasicHook.SetHook(_hookCallback);
         }
         catch
         {
             throw;
         }
     }));
 }
コード例 #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            if (Control.IsKeyLocked(Keys.CapsLock))
            {
                toggleCapsLock();
            }
            var a = "<script>function isIE () {" +
                    "    var myNav = navigator.userAgent.toLowerCase();" +
                    "    return (myNav.indexOf('msie') != -1) ? parseInt(myNav.split('msie')[1]) : false;" +
                    "}</script>";


            webBrowser2.DocumentCompleted += (p, q) =>
            {
                int ieversion = (int)webBrowser2.Document.InvokeScript("isIE");
                if (ieversion < webBrowser2.Version.Major)
                {
                    MessageBox.Show("IE version is incorrect, It should be set to newer version. Current ie:" + ieversion);
                    button2_Click(null, null);
                }
            };
            webBrowser2.DocumentText =
                a + "<div id='ali' style='position:absolute;top:0px;text-align:center;top:40%;width:100%;height:100%;background-color: white;z-index: 1999;'><h1>Quick Translation: Capslock</h1><h2>Developed By AliModaresi</h2><h3>My Translator version 4.0</h3></div>";

            webBrowser1.Url = new Uri("https://translate.google.com/");
            webBrowser1.DocumentCompleted     += WebBrowser1_DocumentCompleted;
            webBrowser1.ScriptErrorsSuppressed = true;



            var t = new System.Timers.Timer();

            t.Elapsed += timeElapsed;
            timeElapsed(null, null);
            t.Interval = 6 * 1000;
            t.Start();
            _hookCallback = new BasicHook.LowLevelKeyboardProc(HookCallback);
            hook          = BasicHook.SetHook(_hookCallback);

            clipboardViewer.Register(this.Handle);
            clipboardViewer.CopyRecevier += s => {
                if (System.DateTime.Now - lastCopyRequestTime < TimeSpan.FromSeconds(2))
                {
                    log(s);
                }
            };
        }
コード例 #3
0
 private void MyTranslator_FormClosing(object sender, FormClosingEventArgs e)
 {
     BasicHook.UnhookWindowsHookEx(hook);
     Environment.Exit(0);
 }