void EventRaiser(WindowsEvents windowEvent, IntPtr window, IntPtr extendedData,
                         ref int result)
        {
            try
            {
                _defaultHookEventsRaiser.EventRaiser(windowEvent, window, extendedData, ref result);


                HookEventsRaiser hookEventsRaiser;

                if (!_hookedWindows.TryGetValue(window, out hookEventsRaiser))
                {
                    return;
                }

                hookEventsRaiser.EventRaiser(windowEvent, window, extendedData, ref result);

                if (windowEvent == WindowsEvents.Closed)
                {
                    _hookedWindows.Remove(window);
                }
            }
            catch
            {
                //ErrorManager.ProccessError(ex);
            }
        }
Beispiel #2
0
 private void Hook(
     WindowsEvents winEvent,
     uint eventType,
     IntPtr hwnd,
     int idObject,
     int idChild,
     uint dwEventThread,
     uint dwmsEventTime)
 {
     Trace.WriteLine($"-> {winEvent} : {eventType} : idObject={idObject}: idChild={idChild}");
 }
Beispiel #3
0
        public void getEventsfromLast5Minutes_ValidEvents_ExpectedEventList()
        {
            var windowsEvents = new WindowsEvents(@"ROOT\CIMV2", new ConnectionOptions()
            {
                Impersonation    = ImpersonationLevel.Impersonate,
                EnablePrivileges = true,
                Authentication   = AuthenticationLevel.Packet
            });

            var eventlogViewer = new EventLogViewer(windowsEvents);
            var eventlogs      = eventlogViewer.getEventsfromLast5Minutes();

            Assert.That(eventlogs.Count, Is.GreaterThan(0));
        }
        private void TimerEvent_Tick(object sender, EventArgs e)
        {
            if (_remainingTime.Ticks > 0)
            {
                _remainingTime = _remainingTime.Subtract(Constants.ONE_SECOND);
            }
            else
            {
                _timerEvent.Stop();

                WindowsEvents.DoWindowEvent((WindowsEventType)cmbEventType.SelectedItem);
            }

            RefreshUI();
        }
Beispiel #5
0
        private void run()
        {
            #region Quick sample how to call a another CS file method
            // Make the to lines and press ctrl+k+c to out comment the code
            // and ctrl+k+u to make is back again
            //HalloWorld hw = new HalloWorld();
            //hw.Say();

            #endregion

            WindowsEvents w = new WindowsEvents();
            w.setEvent();

            Console.WriteLine();
            Console.Write("Test done - Press any key to exit....");
            Console.ReadLine(); // Pause the console to user press a key
        }
Beispiel #6
0
        internal AyeBlinkinTray()
        {
            trayIcon = new NotifyIcon()
            {
                ContextMenuStrip = MakeContextMenuStrip(),
                Icon             = Icons.Program,
                Visible          = true,
                Text             = AyeBlinkin.Name
            };
            trayIcon.MouseUp        += LeftClickOpenMenu;
            Settings.Model.uiContext = SynchronizationContext.Current;

            settingsForm = new SettingsForm();
            Settings.Model.PropertyChanged += buildPatternOptions;
            Settings.Model.SerialComs       = WindowsEvents.GetUsbDevicePorts();
            Settings.Model.Adapters         = DeviceEnumerator.GetAdapters();
            WasapiSoundCapture.Stop();
#if DEBUG
            OpenSettingsForm(null, null);
#endif
        }
 public static extern IntPtr SetWinEventHook(WindowsEvents eventMin, WindowsEvents eventMax, IntPtr hmodWinEventProc, WinEventDelegate lpfnWinEventProc, int idProcess, int idThread, WindowsEvents dwFlags);
        internal void EventRaiser(WindowsEvents windowEvent, IntPtr window, IntPtr extendedData,
                                  ref int result)
        {
            try
            {
                switch (windowEvent)
                {
                case WindowsEvents.Activating:
                    RaiseEvent(WindowActivating, window, EventArgs.Empty);

                    break;

                case WindowsEvents.DeActivating:
                    var willBeActivated = extendedData;
                    RaiseEvent(WindowDeactivating, window, new WindowDeactivatingEventArgs(willBeActivated));

                    break;

                case WindowsEvents.Closed:
                    RaiseEvent(WindowClosed, window, EventArgs.Empty);

                    break;

                case WindowsEvents.SizeMoveBegins:
                    RaiseEvent(WindowSizeMoveBegins, window, EventArgs.Empty);

                    break;

                case WindowsEvents.SizeMoveEnds:
                    RaiseEvent(WindowSizeMoveEnds, window, EventArgs.Empty);

                    break;

                case WindowsEvents.ManualUpdate:
                    RaiseEvent(ManualUpdate, window, EventArgs.Empty);
                    break;

                case WindowsEvents.LocationChanging:
                    short newX = NativeMethods.LoWord(extendedData);
                    short newY = NativeMethods.HiWord(extendedData);

                    RaiseEvent(WindowLocationChanging, window,
                               new NewValueEventArgs <Point>(new Point(newX, newY)));

                    break;

                case WindowsEvents.SizeChanging:
                    short newWidth  = NativeMethods.LoWord(extendedData);
                    short newHeight = NativeMethods.HiWord(extendedData);

                    var args = new WindowSizeChangingEventArgs
                    {
                        NewValue = new Size(newWidth, newHeight)
                    };

                    RaiseEvent(WindowSizeChanging, window, args);

                    result = args.Result;

                    break;

                case WindowsEvents.Maximized:
                    RaiseEvent(WindowMaximized, window, EventArgs.Empty);

                    break;

                case WindowsEvents.IconChanging:
                    Icon newIcon = extendedData != IntPtr.Zero ? Icon.FromHandle(extendedData) : null;
                    RaiseEvent(WindowIconChanging, window, new NewValueEventArgs <Icon>(newIcon));

                    break;

                case WindowsEvents.TitleChanging:
                    string newTitle = Marshal.PtrToStringAuto(extendedData);
                    RaiseEvent(WindowTitleChanging, window, new NewValueEventArgs <String>(newTitle));

                    break;

                case WindowsEvents.VisibleChanging:
                    RaiseEvent(WindowVisibleChanging, window,
                               new NewValueEventArgs <bool>(extendedData.ToInt32() != 0));

                    break;

                case WindowsEvents.EnabledChanging:
                    RaiseEvent(WindowEnableChanging, window,
                               new NewValueEventArgs <bool>(extendedData.ToInt32() != 0));
                    break;
                }
            }
            catch (Exception ex)
            {
                //ErrorManager.ProccessError(ex);
            }
        }