Exemple #1
0
        public Service(){
            //obtain the executable name which runs this service ...
            ServiceExecutable = new Executable(Process.GetCurrentProcess().MainModule.FileName);
            
            //set default running mode ...
            Mode = ServiceMode.NormalMode;

            //init. window event hook ...
            InitHook();
        }
Exemple #2
0
        public void Update()
        {
            try
            {
                bool asd = keys_AltTab;

                //event message loop ...
                User32.MSG _eventMessage = new User32.MSG();
                while (User32.PeekMessage(ref _eventMessage, IntPtr.Zero, 0, 0, User32.PM_REMOVE))
                {
                    User32.TranslateMessage(ref _eventMessage);
                    User32.DispatchMessage(ref _eventMessage);
                }

                //set current curosr pos ...
                User32.GetCursorPos(out _cursorPos);

                //get current window with focus ...
                CurrentWindowHandle = User32.GetForegroundWindow();
                if (CurrentWindowHandle == IntPtr.Zero) return;

                if (keys_AltTab) _altTabWindowHandle = CurrentWindowHandle;

                Process process = GetProcessByHandle(CurrentWindowHandle);
                if (process == null) return;

                ProcessModule pModule = process.MainModule;
                if (pModule == null) return;

                //set current exe ...
                CurrentExecutable = new Executable(pModule.FileName);
            }catch { }
        }