protected override void onTimerTick(object source, ElapsedEventArgs e)
        {
            long now = GazeLib.getTimestamp();

            foreach (IntPtr window in this.visibleWindows.ToList())
            {
                if (window != this.currentlyActiveWindow &&
                    this.windowGazeTimestamps.ContainsKey(window))
                {
                    string processName = WinLib.getProcessName(window);
                    if (!this.recentlyActiveWindows.Contains(window))
                    {
                        long timeInactiveMs = now - this.windowGazeTimestamps[window];
                        if (timeInactiveMs > config.windowInactiveThresholdMs)
                        {
                            startAnimation(window, processName);
                        }
                    }
                    else
                    {
                        log.debug("Not hiding window {0} because it's in recently queue", processName);
                    }
                }
            }
        }
 private void onGazeEvent(object sender, GazeEventArgs e)
 {
     this.gazeCount++;
     if (config.drawGazePositionRectangles)
     {
         GazeLib.drawRectangle((int)e.x, (int)e.y);
     }
     if (this.gazeCount % config.runOnEveryXGazeDispatch == 0)
     {
         long stamp = GazeLib.getTimestamp();
         this.windowGazeTimestamps[this.currentlyActiveWindow] = stamp;
         Point  point                = new Point((int)e.x, (int)e.y);
         IntPtr windowAtGaze         = WinLib.WindowFromPoint(point);
         IntPtr topLevelWindowAtGaze = WinLib.getTopLevelWindow(windowAtGaze);
         if (isTargetWindow(topLevelWindowAtGaze))
         {
             if (topLevelWindowAtGaze != this.currentlyActiveWindow)
             {
                 forwardGazeIfGazedLongEnough(topLevelWindowAtGaze, stamp);
             }
             else
             {
                 onSameWindowGaze(topLevelWindowAtGaze, stamp);
             }
         }
     }
 }
Exemple #3
0
        /// <summary>
        /// 읽어온 메크로를 인스턴스화.
        /// </summary>
        public void LoadMacro()
        {
            mList = new List <CMacro>();

            int    total;
            int    count1;
            string head;
            string tail;
            string file;
            CMacro cm;

            string[] section = Resources.Section.Split(',');    // COUNT,REGISTKEY,TITLE,INPUTKEY
            string[] key     = Resources.Key.Split(',');        // TOTALCOUNT,KEY,COUNT,REGIST,TITLE,INPUT
            file = Application.StartupPath + Resources.File;

            Console.WriteLine(file);

            total = WinLib.GetPrivateProfileInteger(section[0], key[0], file);

            for (int index1 = 1; index1 <= total; index1++)
            {
                cm        = new CMacro(WinLib.GetPrivateProfileString(section[2], key[4] + index1, file));
                cm.regist = SetMacroKey(WinLib.GetPrivateProfileString(section[1], key[3] + index1, file));

                count1 = WinLib.GetPrivateProfileInteger(section[0], key[1] + index1 + key[2], file);

                for (int index2 = 1; index2 <= count1; index2++)
                {
                    cm.keyList.Add(SetMacroKey(WinLib.GetPrivateProfileString(section[3], key[1] + index1 + key[5] + index2, file)));
                }

                AddMacro(cm);
            }
        }
Exemple #4
0
        public void StartMacro(CMacro cm)
        {
            RegistAllUnregister();

            int[] mArr = new int[] { 16, 17, 18 };
            foreach (RegistKey key in cm.keyList)
            {
                //키 다운
                for (int i = 1; i <= 3; i++)
                {
                    if ((key.modify & 1 << i) == 1)
                    {
                        WinLib.keybd_event((byte)mArr[i - 1], 0, 0, 0);
                    }
                }
                WinLib.keybd_event((byte)key.key, 0, 0x00, 0);

                //키 업
                WinLib.keybd_event((byte)key.key, 0, 0x02, 0);
                for (int i = 1; i <= 3; i++)
                {
                    if ((key.modify & 1 << i) == 1)
                    {
                        WinLib.keybd_event((byte)mArr[i - 1], 0, 1, 0);
                    }
                }
            }

            RegistAllregister();
        }
Exemple #5
0
 /// <summary>
 /// 리스트의 담겨있는 모든 매크로를 비활성화 시킴.
 /// </summary>
 public void RegistAllUnregister()
 {
     foreach (int index in activeList)
     {
         WinLib.UnregisterHotKey((int)(WinLib.form.Handle), index);
     }
 }
        private string createWindowKey(IntPtr window)
        {
            string processName = WinLib.getProcess(window).ProcessName;
            string windowTitle = WinLib.getWindowTitle(window);

            return(processName + ":::" + windowTitle);
        }
        private bool isTargetWindow(IntPtr window)
        {
            string processName = WinLib.getProcessName(window);
            string windowTitle = WinLib.getWindowTitle(window);

            return(!windowTitle.Contains("Program Manager") &&
                   !(processName == "explorer" && windowTitle == "" && !Config.Instance.enableForTaskBar));
        }
 private void logRecentlyQueue() // niu => remove later
 {
     if (this.recentlyActiveWindows.Count == 2)
     {
         IntPtr handle1 = this.recentlyActiveWindows.ToArray()[0];
         IntPtr handle2 = this.recentlyActiveWindows.ToArray()[1];
         log.warn(WinLib.getProcessName(handle1) + " - " + WinLib.getProcessName(handle2));
     }
 }
Exemple #9
0
        /// <summary>
        /// 리스트의 담겨있는 모든 매크로를 활성화 시킴.
        /// </summary>
        public void RegistAllregister()
        {
            RegistKey regst;

            foreach (int index in activeList)
            {
                regst = GetRegist(index);
                WinLib.RegisterHotKey((int)(WinLib.form.Handle), index, regst.modify, (int)regst.key);
            }
        }
Exemple #10
0
 public static void Main(string[] args)
 {
     try
     {
         EyeflowConsoleApp.execute();
     } catch (Exception e)
     {
         log.error("Error occurred: {0}", e.ToString());
         WinLib.setTransparency255ForAllWindows();
     }
 }
 protected void showWindow(IntPtr window)
 {
     if (isTargetWindow(window))
     {
         if (!config.simulationMode)
         {
             this.visibleWindows.Add(window);
             WinLib.setTransparency(window, 255);
         }
         log.info("SHOW:::" + createWindowKey(window));
     }
 }
 protected override void onSameWindowGaze(IntPtr window, long currentTimestamp)
 {
     if (!config.simulationMode && config.windowToForegroundOnGazeAfterMs >= 0)
     {
         long timeActiveMs = currentTimestamp - this.timeActivated;
         if (timeActiveMs > config.windowToForegroundOnGazeAfterMs)
         {
             log.debug("window has been active for {0}ms => bringing to foreground");
             WinLib.SetForegroundWindow(this.currentlyActiveWindow);
         }
     }
 }
 private void onFadeOutTimer(object source, ElapsedEventArgs e)
 {
     this.currentTransparency -= config.fadeOutAnimationTransparencyInterval;
     if (this.currentTransparency < config.fadeOutAnimationMinTransparency)
     {
         this.currentTransparency = config.fadeOutAnimationMinTransparency;
     }
     WinLib.setTransparency(this.window, (byte)this.currentTransparency);
     if (this.currentTransparency == config.fadeOutAnimationMinTransparency)
     {
         this.stop();
     }
 }
 private static void exit()
 {
     WinLib.setTransparency255ForAllWindows();
     runner.stop();
     dispatcher.stop();
 }
Exemple #15
0
 private void init()
 {
     kopt.ToggleVisible();
     WinLib.SetDockPanel(pnl_board);
 }
 private static void handleConsole()
 {
     consoleHandler = new WinLib.HandlerRoutine(ConsoleCtrlCheck);
     WinLib.SetConsoleCtrlHandler(consoleHandler, true);
 }
 public override void stop()
 {
     this.globalTimer.Stop();
     onStop();
     WinLib.setTransparency255ForAllWindows();
 }
Exemple #18
0
 private void init()
 {
     main.ToggleVisible();
     WinLib.SetDockPanel(pnl_option);
 }