コード例 #1
0
ファイル: Form_MousePressed.cs プロジェクト: Meragon/win-bot
 private void button1_Click(object sender, EventArgs e)
 {
     ev = new WinEvent(new MouseEventArgs((System.Windows.Forms.MouseButtons) Enum.Parse(typeof(System.Windows.Forms.MouseButtons), comboBox1.SelectedItem.ToString()), 
         1, (int)numericUpDown1.Value, (int)numericUpDown2.Value, 0), 0, WinEvent.ArgsEventType.Pressed);
     FormClose(null, new EventArgs());
     this.Close(); 
 }
コード例 #2
0
ファイル: Goal.cs プロジェクト: IndieRonin/AutoPrep
 public void BodyEntered(Node body)
 {
     if (body.IsInGroup("Player"))
     {
         //Fire the win event if the area was collided with
         WinEvent wei = new WinEvent();
         wei.FireEvent();
     }
 }
コード例 #3
0
ファイル: WinEvents.cs プロジェクト: YountMan/IntelliSense
 public WinEventArgs(WinEvent eventType, IntPtr hWnd, WinEventObjectId idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
 {
     EventType     = eventType;
     WindowHandle  = hWnd;
     ObjectId      = idObject;
     ChildId       = idChild;
     EventThreadId = dwEventThread;
     EventTimeMs   = dwmsEventTime;
 }
コード例 #4
0
    private void ShowWinScreen(WinEvent wei)
    {
        HideAll();
        winScreen.Show();
        SendUIEvent suiei = new SendUIEvent();

        suiei.showWinScreen = true;
        suiei.FireEvent();
    }
コード例 #5
0
ファイル: WinEvents.cs プロジェクト: red2901/IntelliSense
 public WinEventHook(WinEventDelegate handler, WinEvent eventMin, WinEvent eventMax, string xllPath)
 {
     // Note : could we use another handle than one of an xll ?
     // Thus we could avoid carrying the xll path.
     // The events are still hooked after the xll has been unloaded.
     var xllModuleHandle = Win32Helper.GetModuleHandle(xllPath);
     var excelProcessId = Win32Helper.GetExcelProcessId();
     _procDelegate = handler;
     _hWinEventHook = SetWinEventHook(eventMin, eventMax, xllModuleHandle, handler, excelProcessId, 0, SetWinEventHookFlags.WINEVENT_INCONTEXT);
 }
コード例 #6
0
 // Can be called on any thread, but installed by calling into the main thread, and will only start receiving events then
 public WinEventHook(WinEvent eventMin, WinEvent eventMax, SynchronizationContext syncContextAuto, SynchronizationContext syncContextMain, IntPtr hWndFilterOrZero)
 {
     _syncContextAuto        = syncContextAuto ?? throw new ArgumentNullException(nameof(syncContextAuto));
     _syncContextMain        = syncContextMain ?? throw new ArgumentNullException(nameof(syncContextMain));
     _hWndFilterOrZero       = hWndFilterOrZero;
     _handleWinEventDelegate = HandleWinEvent;
     _eventMin = eventMin;
     _eventMax = eventMax;
     syncContextMain.Post(InstallWinEventHook, null);
 }
コード例 #7
0
ファイル: UIManager.cs プロジェクト: IndieRonin/InfectABounce
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        WinEvent.RegisterListener(ShowWin);
        GameOverEvent.RegisterListener(ShowGameOver);
        menu     = GetNode <VBoxContainer>("Menu");
        win      = GetNode <VBoxContainer>("Win");
        gameOver = GetNode <VBoxContainer>("GameOver");

        ShowMenu();
    }
コード例 #8
0
 internal WinEventEventArgs(WinEventHook hook, WinEvent @event, IntPtr hwnd, WinObject @object, WinChild child, int threadId, uint time)
 {
     this.Hook      = hook;
     this.Event     = @event;
     this.Window    = new Win32Window(hwnd);
     this.WinObject = @object;
     this.WinChild  = child;
     this.ThreadId  = threadId;
     this.Timestamp = time;
 }
コード例 #9
0
        public WinEventHook(WinEventDelegate handler, WinEvent eventMin, WinEvent eventMax, string xllPath)
        {
            // Note : could we use another handle than one of an xll ?
            // Thus we could avoid carrying the xll path.
            // The events are still hooked after the xll has been unloaded.
            var xllModuleHandle = Win32Helper.GetModuleHandle(xllPath);
            var excelProcessId  = Win32Helper.GetExcelProcessId();

            _procDelegate  = handler;
            _hWinEventHook = SetWinEventHook(eventMin, eventMax, xllModuleHandle, handler, excelProcessId, 0, SetWinEventHookFlags.WINEVENT_INCONTEXT);
        }
コード例 #10
0
 // A quick filter that runs on the Excel main thread (or other thread handling the WinEvent)
 bool IsSupportedWinEvent(WinEvent winEvent)
 {
     return(winEvent == WinEvent.EVENT_OBJECT_CREATE ||
            // winEvent == WinEvent.EVENT_OBJECT_DESTROY ||  // Stopped watching for this, because we can't route using the ClassName and don't really need anymore
            winEvent == WinEvent.EVENT_OBJECT_SHOW ||
            winEvent == WinEvent.EVENT_OBJECT_HIDE ||
            winEvent == WinEvent.EVENT_OBJECT_FOCUS ||
            winEvent == WinEvent.EVENT_OBJECT_LOCATIONCHANGE ||   // Only for the on-demand hook
            winEvent == WinEvent.EVENT_OBJECT_SELECTION ||        // Only for the PopupList
            winEvent == WinEvent.EVENT_OBJECT_TEXTSELECTIONCHANGED);
 }
コード例 #11
0
 // A quick filter that runs on the Excel main thread (or other thread handling the WinEvent)
 bool IsSupportedWinEvent(WinEvent winEvent)
 {
     return(winEvent == WinEvent.EVENT_OBJECT_CREATE ||
            winEvent == WinEvent.EVENT_OBJECT_DESTROY ||
            winEvent == WinEvent.EVENT_OBJECT_SHOW ||
            winEvent == WinEvent.EVENT_OBJECT_HIDE ||
            winEvent == WinEvent.EVENT_OBJECT_FOCUS ||
            winEvent == WinEvent.EVENT_OBJECT_LOCATIONCHANGE ||   // Only for the on-demand hook
            winEvent == WinEvent.EVENT_OBJECT_SELECTION ||        // Only for the PopupList
            winEvent == WinEvent.EVENT_OBJECT_TEXTSELECTIONCHANGED);
 }
コード例 #12
0
 public void Death()
 {
     --lives;
     if (lives >= 0)
     {
         animators[lives].SetBool("active", false);
     }
     if (lives <= 0)
     {
         WinEvent.Loose();
     }
 }
コード例 #13
0
 public override void OnWin(WinEvent evnt)
 {
     while (true)
     {
         ScanColor = Color.Black;
         TurnRadarLeft(45);
         Scan();
         ScanColor = Color.White;
         TurnRadarRight(45);
         Scan();
     }
 }
コード例 #14
0
 void Repop()
 {
     gameObject.SetActive(false);
     poolOn.Remove(this);
     //poolOff.Add(this);
     Destroy(this);
     if (poolOn.Count + DDYellow.poolOn.Count + CubeCounter.instance.Count() < DDRed.poolOn.Count)
     {
         WinEvent.Loose();
     }
     SoundPool.PlayEatWhite();
 }
コード例 #15
0
    //=================================================================================================================

    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        //The events from the UI
        GetUIEvent.RegisterListener(GetUIInput);
        //Regestiring the events for the game states
        RunEvent.RegisterListener(RunPressed);
        WinEvent.RegisterListener(WinGame);
        DeathEvent.RegisterListener(LoseGame);

        Load();
        Init();
    }
コード例 #16
0
        public void OnWin(WinEvent evnt)
        {
            count(evnt);

            // this is tested output
            foreach (KeyValuePair <string, object> s in counts)
            {
                Out.WriteLine(s.Key + " " + s.Value);
            }

            Out.WriteLine("last bullet heading " + bullet.HeadingRadians.ToString("F5"));
        }
コード例 #17
0
 public override void _Ready()
 {
     WinEvent.RegisterListener(ShowWinScreen);
     DeathEvent.RegisterListener(ShowDeathScreen);
     //Grab a refference to all the ui screens for hte game
     ui          = GetNode <Node2D>("UI");
     menu        = GetNode <Node2D>("Menu");
     winScreen   = GetNode <Node2D>("WinScreen");
     DeathScreen = GetNode <Node2D>("DeathScreen");
     //Hide all the screens for the game
     HideAll();
     //Show the menu screen at startup
     ShowMenu();
 }
コード例 #18
0
        private void Hook_EventProc(IntPtr hWinEventHook, WinEvent @event, IntPtr hwnd,
                                    WinObject objectId, WinChild childId, int thread, uint time)
        {
            var args = new WinEventEventArgs(this, @event, hwnd, objectId, childId, thread, time);

            CallbackContext(() =>
            {
                HookTriggered?.Invoke(this, args);
                foreach (var s in Observers)
                {
                    s.OnNext(args);
                }
            });
        }
コード例 #19
0
 public void Death()
 {
     SoundPool.PlayDeath();
     this.gameObject.SetActive(false);
     DDRed.poolOn.Remove(this);
     DDRed.poolOff.Add(this);
     if (!MapEditor.active)
     {
         ScoreCounter.instance.Collect();
     }
     if (poolOn.Count == 0)
     {
         WinEvent.Win();
     }
 }
コード例 #20
0
ファイル: RecipeChecker.cs プロジェクト: MaratG2/borger
    private bool WinChecker()
    {
        var roasts = Controller.Cooker.FryingBorger.Roast;

        foreach (var roast in roasts)
        {
            if (roast > CurrentRecipe.MaxFry || roast < CurrentRecipe.MinFry)
            {
                return(false);
            }
        }

        WinEvent?.Invoke();
        return(true);
    }
コード例 #21
0
ファイル: Main.cs プロジェクト: IndieRonin/InfectABounce
 private void CellConverted(CellConvertEvent ccei)
 {
     for (int i = 0; i < cellsLeftToConvert.Count; i++)
     {
         if (cellsLeftToConvert[i].GetInstanceId() == ccei.CovertedCell.GetInstanceId())
         {
             cellsLeftToConvert.RemoveAt(i);
             if (cellsLeftToConvert.Count == 0)
             {
                 StopGame();
                 WinEvent wei = new WinEvent();
                 wei.FireEvent();
             }
         }
     }
 }
コード例 #22
0
ファイル: Main.cs プロジェクト: IndieRonin/Blocko
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        //Pre load the scenes for the game
        playerScene   = ResourceLoader.Load("res://Scenes/Player.tscn") as PackedScene;
        mapScene      = ResourceLoader.Load("res://Scenes/Map.tscn") as PackedScene;
        enemyScene    = ResourceLoader.Load("res://Scenes/Enemy.tscn") as PackedScene;
        artifactScene = ResourceLoader.Load("res://Scenes/Artifact.tscn") as PackedScene;
        uiScene       = ResourceLoader.Load("res://Scenes/UI.tscn") as PackedScene;
        //The UI of the game
        ui = uiScene.Instance();
        AddChild(ui);

        SendUIEvent.RegisterListener(StartGame);
        DeathEvent.RegisterListener(LoseGame);
        WinEvent.RegisterListener(WinGame);
    }
コード例 #23
0
 /// <summary>
 /// WinEventDelegate for the creation & destruction
 /// </summary>
 /// <param name="eventType"></param>
 /// <param name="hWnd"></param>
 /// <param name="idObject"></param>
 /// <param name="idChild"></param>
 /// <param name="dwEventThread"></param>
 /// <param name="dwmsEventTime"></param>
 private void WinEventHandler(WinEvent eventType, IntPtr hWnd, EventObjects idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
 {
     if (hWnd == IntPtr.Zero || idObject != EventObjects.OBJID_WINDOW)
     {
         return;
     }
     if (eventType == WinEvent.EVENT_OBJECT_NAMECHANGE)
     {
         if (_titleChangeEvent != null)
         {
             string newTitle = new WindowDetails(hWnd).Text;
             _titleChangeEvent(new TitleChangeEventArgs {
                 HWnd = hWnd, Title = newTitle
             });
         }
     }
 }
コード例 #24
0
ファイル: WinEvents.cs プロジェクト: Excel-DNA/IntelliSense
        bool disposedValue = false; // To detect redundant calls

        #endregion Fields

        #region Constructors

        public WinEventHook(WinEvent eventMin, WinEvent eventMax, SynchronizationContext syncContextAuto, IntPtr hWndFilterOrZero)
        {
            if (syncContextAuto == null)
                throw new ArgumentNullException(nameof(syncContextAuto));
            _syncContextAuto = syncContextAuto;
            _hWndFilterOrZero = hWndFilterOrZero;
            var xllModuleHandle = Win32Helper.GetXllModuleHandle();
            var excelProcessId = Win32Helper.GetExcelProcessId();
            _handleWinEventDelegate = HandleWinEvent;
            _hWinEventHook = SetWinEventHook(eventMin, eventMax, xllModuleHandle, _handleWinEventDelegate, excelProcessId, 0, SetWinEventHookFlags.WINEVENT_INCONTEXT);
            if (_hWinEventHook == IntPtr.Zero)
            {
                Logger.WinEvents.Error("SetWinEventHook failed");
                // Is SetLastError used? - SetWinEventHook documentation does not indicate so
                throw new Win32Exception("SetWinEventHook failed");
            }
            Logger.WinEvents.Info($"SetWinEventHook success on thread {Thread.CurrentThread.ManagedThreadId}");
        }
コード例 #25
0
ファイル: Main.cs プロジェクト: IndieRonin/Guardian
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        //Grabs the map scene from the Scene tree on the games start up
        mapScene           = ResourceLoader.Load("res://Scenes/Map.tscn") as PackedScene;
        playerScene        = ResourceLoader.Load("res://Scenes/Player.tscn") as PackedScene;
        crystalScene       = ResourceLoader.Load("res://Scenes/Crystal.tscn") as PackedScene;
        enemySpawnerScene  = ResourceLoader.Load("res://Scenes/EnemySpawner.tscn") as PackedScene;
        UIScene            = ResourceLoader.Load("res://Scenes/UI.tscn") as PackedScene;
        missilePickupScene = ResourceLoader.Load("res://Scenes/MissilePickup.tscn") as PackedScene;
        MainEvent.RegisterListener(UIEventFired);
        UnitDeathEvent.RegisterListener(EndGame);
        WinEvent.RegisterListener(WinTriggered);
        LoseEvent.RegisterListener(LostTriggered);

        ui      = UIScene.Instance();
        ui.Name = "UI";
        AddChild(ui);
    }
コード例 #26
0
        //------------------------------------------------------
        //
        //  Private Methods
        //
        //------------------------------------------------------

        #region Private Methods

        // queue winevents so that the get processed in the order we receive them. If we just
        // dispatch them as we get them, we'll end up getting some _while_ we are processing others,
        // and end up completing those events out of order, making the event order appear backwards.
        // This code checks whether we are currently processing an event, and if so, queues it so that
        // we process it when we're done with the current event.
        private void WinEventReentrancyFilter(int winEventHook, int eventId, IntPtr hwnd, int idObject, int idChild, int eventThread, uint eventTime)
        {
            if (_fBusy)
            {
                _qEvents.Enqueue(new WinEvent(eventId, hwnd, idObject, idChild, eventTime));
            }
            else
            {
                _fBusy = true;
                try
                {
                    PreWinEventProc(eventId, hwnd, idObject, idChild, eventTime); // deliver this event
                }
                catch (Exception e)
                {
                    if (Misc.IsCriticalException(e))
                    {
                        throw;
                    }

                    // ignore exceptions for now since we've no way to let clients add exception handlers
                }

                while (_qEvents.Count > 0)
                {
                    WinEvent e = (WinEvent)_qEvents.Dequeue(); // process queued events
                    try
                    {
                        PreWinEventProc(e._eventId, e._hwnd, e._idObject, e._idChild, e._eventTime);
                    }
                    catch (Exception ex)
                    {
                        if (Misc.IsCriticalException(ex))
                        {
                            throw;
                        }

                        // ignore exceptions for now since we've no way to let clients add exception handlers
                    }
                }
                _fBusy = false;
            }
        }
コード例 #27
0
ファイル: WinEvents.cs プロジェクト: ruo2012/IntelliSense
        readonly WinEventDelegate _handleWinEventDelegate; // Ensures delegate that we pass to SetWinEventHook is not GC'd

        public WinEventHook(WinEvent eventMin, WinEvent eventMax, SynchronizationContext syncContextAuto, IntPtr hWndFilterOrZero)
        {
            if (syncContextAuto == null)
            {
                throw new ArgumentNullException(nameof(syncContextAuto));
            }
            _syncContextAuto  = syncContextAuto;
            _hWndFilterOrZero = hWndFilterOrZero;
            var xllModuleHandle = Win32Helper.GetXllModuleHandle();
            var excelProcessId  = Win32Helper.GetExcelProcessId();

            _handleWinEventDelegate = HandleWinEvent;
            _hWinEventHook          = SetWinEventHook(eventMin, eventMax, xllModuleHandle, _handleWinEventDelegate, excelProcessId, 0, SetWinEventHookFlags.WINEVENT_INCONTEXT);
            if (_hWinEventHook == IntPtr.Zero)
            {
                Logger.WinEvents.Error("SetWinEventHook failed");
                // Is SetLastError used? - SetWinEventHook documentation does not indicate so
                throw new Win32Exception("SetWinEventHook failed");
            }
            Logger.WinEvents.Info($"SetWinEventHook success on thread {Thread.CurrentThread.ManagedThreadId}");
        }
コード例 #28
0
ファイル: WinEvents.cs プロジェクト: jmptrader/IntelliSense
        // This runs on the Excel main thread - get off quickly
        void HandleWinEvent(IntPtr hWinEventHook, WinEvent eventType, IntPtr hWnd,
                            int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
        {
            try
            {
                if (disposedValue)
                {
                    return;
                }

                if (_hWndFilterOrZero != IntPtr.Zero && hWnd != _hWndFilterOrZero)
                {
                    return;
                }

                // CONSIDER: We might add some filtering here... maybe only interested in some of the window / event combinations
                _syncContextAuto.Post(OnWinEventReceived, new WinEventArgs(eventType, hWnd, idObject, idChild, dwEventThread, dwmsEventTime));
            }
            catch (Exception ex)
            {
                Logger.WinEvents.Warn($"HandleWinEvent Exception {ex}");
            }
        }
コード例 #29
0
        // This runs on the Excel main thread (usually, not always) - get off quickly
        void HandleWinEvent(IntPtr hWinEventHook, WinEvent eventType, IntPtr hWnd,
                            WinEventObjectId idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
        {
            // Debug.Print($"++++++++++++++ WinEvent Received: {eventType} on thread {Thread.CurrentThread.ManagedThreadId} from thread {dwEventThread} +++++++++++++++++++++++++++");
            try
            {
                if (_hWndFilterOrZero != IntPtr.Zero && hWnd != _hWndFilterOrZero)
                {
                    return;
                }

                if (!IsSupportedWinEvent(eventType))
                {
                    return;
                }

                // CONSIDER: We might add some filtering here... maybe only interested in some of the window / event combinations
                _syncContextAuto.Post(OnWinEventReceived, new WinEventArgs(eventType, hWnd, idObject, idChild, dwEventThread, dwmsEventTime));
            }
            catch (Exception ex)
            {
                Logger.WinEvents.Warn($"HandleWinEvent Exception {ex}");
            }
        }
コード例 #30
0
ファイル: Methods.cs プロジェクト: ngollon/snaptiler
 internal static extern IntPtr SetWinEventHook(Event eventMin, Event eventMax, IntPtr hmodWinEventProc, WinEventDelegate lpfnWinEventProc, uint idProcess, uint idThread, WinEvent dwFlags);
コード例 #31
0
ファイル: Interop.cs プロジェクト: HaKDMoDz/GNet
 public static extern IntPtr SetWinEventHook(WinEvent eventMin, WinEvent eventMax, IntPtr hmodWinEventProc, WinEventDelegate lpfnWinEventProc, uint idProcess, uint idThread, SetWinEventHookFlags dwFlags);
コード例 #32
0
 public override void OnWin(WinEvent e)
 {
     Out.WriteLine("Win!");
 }
コード例 #33
0
ファイル: TrackFire.cs プロジェクト: boosheng/robocode
 public override void OnWin(WinEvent e)
 {
     // Victory dance
     TurnRight(36000);
 }
コード例 #34
0
ファイル: Form_MouseMove.cs プロジェクト: Meragon/win-bot
 private void button1_Click(object sender, EventArgs e)
 {
     ev = new WinEvent(new MouseEventArgs(System.Windows.Forms.MouseButtons.None, 0, (int) numericUpDown1.Value, (int) numericUpDown2.Value, 0), 0, WinEvent.ArgsEventType.None);
     FormClose(null, new EventArgs());
     this.Close(); 
 }
コード例 #35
0
 public override void OnWin(WinEvent evnt)
 {
     SetTurnGunLeft(50000);
     SetTurnRight(90);
 }
コード例 #36
0
 static extern IntPtr SetWinEventHook(uint eventMin, uint eventMax, IntPtr
                                      hmodWinEventProc, WinEventDelegate lpfnWinEventProc, uint idProcess,
                                      uint idThread, WinEvent dwFlags);
コード例 #37
0
ファイル: WinEvents.cs プロジェクト: Excel-DNA/IntelliSense
 public WinEventArgs(WinEvent eventType, IntPtr hWnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
 {
     EventType = eventType;
     WindowHandle = hWnd;
     ObjectId = idObject;
     ChildId = idChild;
     EventThreadId = dwEventThread;
     EventTimeMs = dwmsEventTime;
 }
コード例 #38
0
 private void button1_Click(object sender, EventArgs e)
 {
     ev = new WinEvent(new KeyEventArgs((Keys)Enum.Parse(typeof(Keys), comboBox1.SelectedItem.ToString())), 0, WinEvent.ArgsEventType.Pressed);
     FormClose(null, new EventArgs());
     this.Close();
 }
コード例 #39
0
	private void OnWinEvent(WinEvent evt)
	{
		winObject.SetActive(true);
		GlobalEvents.Invoke(new PauzeEvent("pauze"));
	}
コード例 #40
0
ファイル: WinEvents.cs プロジェクト: Excel-DNA/IntelliSense
        // This runs on the Excel main thread - get off quickly
        void HandleWinEvent(IntPtr hWinEventHook, WinEvent eventType, IntPtr hWnd, 
                            int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
        {
            try
            {
                if (disposedValue)
                    return;

                if (_hWndFilterOrZero != IntPtr.Zero && hWnd != _hWndFilterOrZero)
                    return;

                // CONSIDER: We might add some filtering here... maybe only interested in some of the window / event combinations
                _syncContextAuto.Post(OnWinEventReceived, new WinEventArgs(eventType, hWnd, idObject, idChild, dwEventThread, dwmsEventTime));
            }
            catch (Exception ex)
            {
                Logger.WinEvents.Warn($"HandleWinEvent Exception {ex}");
            }
        }