eythaann / Seelen-UI

The Fully Customizable Desktop Environment for Windows 10/11.
Other
1.47k stars 39 forks source link

[FEAT] Optimizing AHK script, closing shortcut key when paused. #10

Closed mystery4f closed 5 months ago

mystery4f commented 5 months ago

seelen.ahk:

#Requires AutoHotkey v2.0
; #SingleInstance Force
#UseHook true
#Include shortcut.ahk
#SuspendExempt 

; Window manager options
^#!p:: InnerTogglePause()

shortcut.ahk is the original seelen.ahk.

eythaann commented 5 months ago

#UseHook true add the $ prefix to all shortcuts, but can you explain me why this will perform better that normals shortcuts?

mystery4f commented 5 months ago

The TogglePause in komorebic.lib.ahk can now pause komorebic, but at this time the hotkey defined in ahk is still occupied and has no effect, so I feel that the ahk script can be "suspended" here:

seelen.ahk

TogglePausePlus() {
    Suspend(-1)
    TogglePause()
}

^#!p:: TogglePausePlus()

By doing this, we need to ensure that ^#!p can still be used normally; this can be achieved by using #SuspendExempt (ignore suspend).

At this point, only ^#!p should be left in seelen.ahk, and the rest of the custom shortcuts should be moved to shortcut.ahk (the shortcuts that we need to pause).

mystery4f commented 5 months ago

#UseHook true add the $ prefix to all shortcuts, but can you explain me why this will perform better that normals shortcuts? sorry ,I'm not expressing myself clearly.

eythaann commented 5 months ago

The TogglePause in komorebic.lib.ahk can now pause komorebic, but at this time the hotkey defined in ahk is still occupied and has no effect, so I feel that the ahk script can be "suspended" here:

seelen.ahk

TogglePausePlus() {
    Suspend(-1)
    TogglePause()
}

^#!p:: TogglePausePlus()

By doing this, we need to ensure that ^#!p can still be used normally; this can be achieved by using #SuspendExempt (ignore suspend).

At this point, only ^#!p should be left in seelen.ahk, and the rest of the custom shortcuts should be moved to shortcut.ahk (the shortcuts that we need to pause).

Yes I understand this I decide implement other stuff instead of suspend to follow the user settings but in resume the pause will be:

^#!p:: {
  PauseWM()
  ExitApp()
}

I separate the script files for apps to avoid add shortcuts if user disable the app entirely, also to follow the encapsulation and SRP principles. The resume will be added to the main file to when this willl trigger the program will open again the shortcuts if the user have enabled the included AHK scripts.

eythaann commented 5 months ago

This should be working on the next release. Separations of AHK by settings in c07a8e3578709368cbbb0b2af2bcab73076e69cd