Skip to content

Commit

Permalink
added Events + Polling process detection option, increase polling to …
Browse files Browse the repository at this point in the history
…2 seconds
  • Loading branch information
Aytackydln committed Dec 30, 2024
1 parent 55a5a60 commit 6b5c525
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ private set
internal ActiveProcessMonitor()
{
_dele = WinEventProc;
if (Global.Configuration.DetectionMode != ApplicationDetectionMode.WindowsEvents)
if (Global.Configuration.DetectionMode is ApplicationDetectionMode.WindowsEvents or ApplicationDetectionMode.EventsAndForeground)
{
return;
_setWinEventHook = User32.SetWinEventHook(EventSystemForeground, EventSystemForeground,
IntPtr.Zero, _dele, 0, 0, WinEventOutOfContext);
}

_setWinEventHook = User32.SetWinEventHook(EventSystemForeground, EventSystemForeground,
IntPtr.Zero, _dele, 0, 0, WinEventOutOfContext);
}

private void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr windowHandle, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
Expand Down Expand Up @@ -77,6 +75,9 @@ private void SetActiveWindowProperties(IntPtr windowHandle)

public void Dispose()
{
User32.UnhookWinEvent(_setWinEventHook);
if (_setWinEventHook != IntPtr.Zero)
{
User32.UnhookWinEvent(_setWinEventHook);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,10 @@ private void TimerUpdate()

private void UpdateProcess()
{
if (Global.Configuration.DetectionMode != ApplicationDetectionMode.ForegroundApp ||
_currentTick < _nextProcessNameUpdate) return;
var pollingEnabled = Global.Configuration.DetectionMode is ApplicationDetectionMode.ForegroundApp or ApplicationDetectionMode.EventsAndForeground;
if (!pollingEnabled || _currentTick < _nextProcessNameUpdate) return;
_activeProcessMonitor.Result.UpdateActiveProcessPolling();
_nextProcessNameUpdate = _currentTick + 1000L;
_nextProcessNameUpdate = _currentTick + 2000L;
}

private void UpdateIdleEffects(EffectFrame newFrame)
Expand Down
3 changes: 3 additions & 0 deletions Project-Aurora/Project-Aurora/Settings/SettingEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,9 @@ public enum ApplicationDetectionMode
[Description("Foreground App Scan")]
ForegroundApp = 1,

[Description("Windows Events and Foreground App Scan")]
EventsAndForeground = 2,

[Description("None")]
[UsedImplicitly]
None = -1,
Expand Down

0 comments on commit 6b5c525

Please sign in to comment.