Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- THESE ARE A BUNCH OF MESSY BRAINSTORM/TEST NOTES TO TRY AND UNDERSTAND CRITICAL BETTER, FOR NOW I'LL BE USING CRITICAL ONLY WHEN ABSOLUTELY NECESSARY. WHICH SEEMS ONLY TO BE THE CASE FOR HOTKEYS AND TIMERS INTERRUPTING OTHER THREADS. COULD DO THE INITIAL TESTS AGAIN TO MAKE SURE I DIDN'T FORGET ANYTHING. BUT I'M SURE I HAVE IT FIGURED OUT ALREADY, SO I'LL JUST SKIP DIGGING INTO THE INITIAL TESTS AGAIN FOR NOW (MAYBE I'LL DO IT LATER). CRITICAL SEEMS RATHER USELESS FOR WINEVENT HANDLERS
- /********** TRASH: `...txt` (part of initial test files) **********/
- I do not think that there will be issues, not even without Critical b/c the sleep used in either fullscreen mark feature does not affect it, since it's the first action, only the thread
- being busy could let it get overtaken but it doesn't do much so that is like basically impossible.. Still, I could just do Critical everywhere to stay consistent so there won't ever be a
- problem, not even when I decide to expand stuff and then suddenly do need it. So use Critical and do not use the bool now all of the sudden! Only Critical(-1) in the workaround
- [pretty sure Critical will only affect busy-wait to make it not get interrupted when it's busy, doesn't affect sleep at all it seems and sleep lets it get interrupted by new threads but not
- threads that got paused while a new thread took over. So if you use both busy-wait and sleep, then sleep will let it get interrupted in the way I just described, because it isn't protected
- by Critical, the busy-wait is just extra then so that won't make the sleep suddenly protected as well..]
- we'll do critical I guess, so just make the new fullscreen mark-toggle feature first and then we'll see what it needs exactly?
- /********** TRASH: `Critical(-1) in event handlers.txt` (part of initial test files) **********/
- I might wanna add Critical(-1) to all my event handlers above the isScopeEntered condition set instruction, b/c it does seem to help while there are no Sleep nor A_WinDelay/WinWait
- so it's always good, can try the pastebin again just to be sure
- Critical/Sleep Event Test.ahk
- Add comment to the Critical(-1) that it only works on overtakes 'in event handlers', not win delays, nor Sleep() and WinWait(). So the condition is only for in case win delays, Sleep() or
- WinWait() gets added (or to discard queued events but that'd be done with Sleep() as well). I'm 100% positive that Critical(-1) in non-event threads such as a hotkey thread, makes it
- actually work for Sleep() as well. Though not sure what happens in mouse event handlers (mouse hook is irrelevant, already has Critical in it), perhaps the same as win event handlers
- is the event handler bool still necessary if critical is enabled? o.o [YES, good to consistently put it in there for any interruptions that Critical has no effect on]
- don't forget WinEvent Monitor, GW2, and some scripts on the 2nd github acc and pastebin (such as magic bullet)
- be careful with WinEvent handlers that take a lot of time to execute, with other code such as hotkeys.. because if for example a hotkey starts and then waits,
- then if a WinEvent runs for a long time, that hotkey won't be able to continue until the WinEvent waits as well or ends.. just an edge case, all WinEvent handlers are probably fast.
- the HDR subs fix > loop btn fix also has a WinEvent handler but that one is so fast it didn't even need a LButton and Enter hotkey for protection, and if it did; does not actually hinder
- the LButton and Enter hotkey.. unless ofc if you make it intentionally take a long time
- /********** TRASH: `test - Copy.ahk` (part of initial test files) **********/
- #Requires AutoHotkey 2.0
- Persistent()
- A_CoordModeToolTip := "Screen"
- EVENT_SYSTEM_FOREGROUND := 0x0003
- EVENT_OBJECT_SHOW := 0x8002
- text := ""
- HookEvent(EVENT_SYSTEM_FOREGROUND, HandleActivatedWindowTaskbarEvent)
- HookEvent(EVENT_OBJECT_SHOW, HandleShowedFullscreenWinEvent)
- HandleActivatedWindowTaskbarEvent(hWinEventHook, event, hWnd, *)
- {
- static count := 0
- try
- {
- Critical(-1) ; (W/ BUSY-WAIT) 1 1 2 2 3 3 when uncommented, 1 2 3 3 2 1 when commented-out
- global text .= " ^^f" (id := ++count)
- Tooltip(text)
- loop (8000000) ; Approx. 2sec busy-wait (has approx. 30% CPU usage at most)
- continue
- ;loop (4)
- ; Sleep(200) ;Sleep(-1) ; (W/ CRITICAL ON) 1 2 3 3 2 1 when uncommented, 1 1 2 2 3 3 when commented-out
- ;,
- Tooltip(text .= " ^^f" id)
- }
- }
- HandleShowedFullscreenWinEvent(hWinEventHook, event, hWnd, *)
- {
- static count := 0
- try
- {
- Critical(-1) ; (W/ BUSY-WAIT) 1 1 2 2 3 3 when uncommented, 1 2 3 3 2 1 when commented-out
- global text .= " __s" (id := ++count)
- Tooltip(text)
- loop (8000000) ; Approx. 2sec busy-wait (has approx. 30% CPU usage at most)
- continue
- ;loop (4)
- ; Sleep(200) ;Sleep(-1) ; (W/ CRITICAL ON) 1 2 3 3 2 1 when uncommented, 1 1 2 2 3 3 when commented-out
- ;,
- Tooltip(text .= " __s" id)
- }
- }
- HookEvent(event, fnObj, pid := 0) => DllCall("SetWinEventHook", "UInt", event, "UInt", event, "Ptr", 0, "Ptr", CallbackCreate(fnObj), "UInt", pid, "UInt", 0, "UInt", 0)
- /********** TRASH: `test..ahk` (part of initial test files) **********/
- #Requires AutoHotkey 2.0
- Persistent()
- A_CoordModeToolTip := "Screen"
- EVENT_SYSTEM_FOREGROUND := 0x0003
- EVENT_OBJECT_SHOW := 0x8002
- txt := "", cnt1 := 0, cnt2 := 0, isBusy1 := false, isBusy2 := false
- HookEvent(EVENT_SYSTEM_FOREGROUND, HandleActivatedWindowTaskbarEvent)
- HookEvent(EVENT_OBJECT_SHOW, HandleShowedFullscreenWinEvent)
- F1::
- {
- global isBusy1 := false
- global isBusy2 := false
- global cnt1 := 0
- global cnt2 := 0
- }
- HandleActivatedWindowTaskbarEvent(hWinEventHook, event, hWnd, *)
- {
- static cnt := 0
- ;Critical(-1)
- ;Sleep(30)
- if (!isBusy1)
- {
- global isBusy1 := true
- tooltip("?")
- ;cnt := 0
- loop
- {
- global cnt1 := cnt1 + 1
- if (cnt1 = 5)
- break
- Sleep(200)
- global txt .= cnt1 " Foreground`t" hWnd "`n"
- Tooltip(txt, 1000, 1000)
- }
- }
- ;global txt .= "Foreground`n"
- ;tooltip(txt, 1000, 1000)
- else
- {
- ++cnt
- global txt .= cnt " __Foreground`t" hWnd "`n"
- tooltip(txt, 1000, 1000)
- }
- }
- HandleShowedFullscreenWinEvent(hWinEventHook, event, hWnd, *)
- {
- static cnt := 0
- ;Critical(-1)
- ;Sleep(200)
- if (!isBusy2)
- {
- global isBusy2 := true
- tooltip("??")
- ;cnt := 0
- loop
- {
- global cnt2 := cnt2 + 1
- if (cnt2 = 5)
- break
- Sleep(200)
- global txt .= cnt2 " Show`t`t" hWnd "`n"
- Tooltip(txt, 1000, 1000)
- }
- }
- ;global txt .= "Show`n"
- ;tooltip(txt, 1000, 1000)
- else
- {
- ++cnt
- global txt .= cnt " __Show`t" hWnd "`n"
- tooltip(txt, 1000, 1000)
- }
- }
- HookEvent(event, fnObj, pid := 0) => DllCall("SetWinEventHook", "UInt", event, "UInt", event, "Ptr", 0, "Ptr", CallbackCreate(fnObj), "UInt", pid, "UInt", 0, "UInt", 0)
- /********** TRASH: `README.txt` (part of latest test files) **********/
- in Time Saver I can use FIND and then Event(
- there PUT AT THE FIRST LINE OF THE WINEVENT HANDLER (it is best to put it there, do not put it at the first line of the if statement scope..)
- Critical(-1) ; Enables only the Critical mode of the thread made for this specific WinEvent handler (buffers hotkeys and timers until Critical is disabled or the thread finishes)
- however there's a WinEvent handler that uses a temporary hotkey, which must not have Critical
- I think it won't help the WinEvent Monitor at all, b/c it only has an effect on interruptions by hotkeys and timers
- it will also make WinEvent handlers take a tiny bit longer to execute the rest of the code, b/c it'd have to execute the Critical(-1) first, which is likely only bad in MTO though but still
- and b/c hotkeys will get buffered, that might very well cause key-press lag.. which would likely be pretty annoying with the LButton hotkeys
- pretty sure it's better to just leave it out and keep everything fast, I doubt very much that anything will go wrong because of it
- but I can still keep it in WinEvent handlers that absolutely need it, such as:
- HandleActivatedWindowExplorerEvent(hWinEventHook, event, hWnd, *) => (Critical(-1), SetVlcVideoOutputForRelevantFeatureFix(hWnd))
- HandleSelectionExplorerEvent(hWinEventHook, event, hWnd, *) => (Critical(-1), SetVlcVideoOutputForRelevantFeatureFix(hWnd))
- >>>I think it's like this ("New AutoHotkey Script.ahk" & "New AutoHotkey Script - Copy.ahk" shows the following behaviour when critical is used in all WinEvent handlers):
- Critical(-1) in WinEvent handler will make any non-WinEvent-handler thread unable to overtake, doesn't matter if there are windowing delays, sleep or Wait functions. instead they will get
- buffered until the WinEvent handler finishes completely. but other WinEvent handlers can overtake it immediately, doesn't matter if there are windowing delays, sleep or Wait functions.
- however when the DllCall "Sleep" is used, then as long as that DllCall hasn't finished, it will buffer any WinEvent and any other event such as hotkeys and timers
- could check "test - Copy - Copy.ahk" as well but the two new scripts seemed to indicate the complete behaviour clear enough
- /********** TRASH: `test - Copy - Copy.ahk` (part of latest test files) **********/
- #Requires AutoHotkey 2.0
- Persistent()
- A_CoordModeToolTip := "Screen"
- EVENT_SYSTEM_FOREGROUND := 0x0003
- EVENT_OBJECT_SHOW := 0x8002
- text := ""
- HookEvent(EVENT_SYSTEM_FOREGROUND, HandleActivatedWindowTaskbarEvent)
- HookEvent(EVENT_OBJECT_SHOW, HandleShowedFullscreenWinEvent)
- HookEvent(event, fnObj, pid := 0) => DllCall("SetWinEventHook", "UInt", event, "UInt", event, "Ptr", 0, "Ptr", CallbackCreate(fnObj), "UInt", pid, "UInt", 0, "UInt", 0)
- ;there's also a WinAPI Sleep fn..
- F1:: ; seems like hotkeys and timers can interrupt w/o critical and get buffered w/ critical (tested with Sleep only, but Sleep might be irrelevant b/c they might overtake at any line)
- tf(*) ; and I think WinEvent handlers can interrupt a thread whether it has or doesn't have critical, as long as it's sleeping (not sure if I actually ever tested it w/ critical tho)
- {
- global text .= " _____"
- Tooltip(text)
- }
- HandleActivatedWindowTaskbarEvent(hWinEventHook, event, hWnd, *)
- {
- static count := 0
- try
- {
- Critical(-1) ; (W/ BUSY-WAIT) 1 1 2 2 3 3 when uncommented, 1 2 3 3 2 1 when commented-out
- ;SetTimer(tf, -1)
- global text .= " ^^f" (id := ++count)
- Tooltip(text)
- loop (8000000) ; Approx. 2sec busy-wait (has approx. 30% CPU usage at most)
- continue
- ;loop (4)
- ; Sleep(200) ;Sleep(-1) ; (W/ CRITICAL ON) 1 2 3 3 2 1 when uncommented, 1 1 2 2 3 3 when commented-out
- ;,
- Tooltip(text .= " ^^f" id)
- }
- }
- HandleShowedFullscreenWinEvent(hWinEventHook, event, hWnd, *)
- {
- static count := 0
- try
- {
- Critical(-1) ; (W/ BUSY-WAIT) 1 1 2 2 3 3 when uncommented, 1 2 3 3 2 1 when commented-out
- ;SetTimer(tf, -1)
- global text .= " __s" (id := ++count)
- Tooltip(text)
- loop (8000000) ; Approx. 2sec busy-wait (has approx. 30% CPU usage at most)
- continue
- ;loop (4)
- ; Sleep(200) ;Sleep(-1) ; (W/ CRITICAL ON) 1 2 3 3 2 1 when uncommented, 1 1 2 2 3 3 when commented-out
- ;,
- Tooltip(text .= " __s" id)
- }
- }
- /********** TRASH: `New AutoHotkey Script.ahk` (part of latest test files) **********/
- #Requires AutoHotkey 2.0
- A_WinDelay := -1 ; For the snip feature, HandleNameChangedThunderbirdEvent, HandleNameChangedTabsOutlinerEvent and the two different HandleCreatedVlcEvent functions
- A_KeyDelay := -1 ; For the XButton hotkeys (ControlSend) and for Send b/c it reverts to the Event SendMode when another AHK script installs a native low-level keyboard/mouse hook
- A_KeyDuration := 1 ; For the XButton hotkeys
- /* [..,..,.. Sleep workaround works no matter what, but WinEvent handler can overtake shortly before or immediately after the Sleep workaround is done in the other WinEvent handler]
- ;HookEvent(0x8000, _HandleCreatedVlcEvent) ; [DIFFERENT EVENT, SAME FN, YES]
- HookEvent(0x0003, __HandleCreatedVlcEvent) ; [SAME EVENT, DIFFERENT FN, YES]
- HookEvent(0x0003, _HandleCreatedVlcEvent) ; [SAME EVENT, DIFFERENT FN, YES] ; [DIFFERENT EVENT, SAME FN, YES] ; TESTING IF A FOREGROUND WINEVENT HANDLER CAN OVERTAKE THE CREATE WINEVENT....
- */
- HookEvent(0x8000, HandleCreatedVlcEvent)
- ;HookEvent(0x0003, __HandleCreatedVlcEvent)
- HookEvent(0x0003, _HandleCreatedVlcEvent) ; TESTING IF A FOREGROUND WINEVENT HANDLER CAN OVERTAKE THE CREATE WINEVENT HANDLER ABOVE (W/ & W/O CRITICAL)
- /* [..,..,.. LAST ONE I TESTED]
- HookEvent(0x8000, _HandleCreatedVlcEvent) ; [DIFFERENT EVENT, DIFFERENT FN, YES]
- ;HookEvent(0x0003, __HandleCreatedVlcEvent)
- HookEvent(0x0003, HandleCreatedVlcEvent) ; [DIFFERENT EVENT, DIFFERENT FN, YES] ; TESTING IF A FOREGROUND WINEVENT HANDLER CAN OVERTAKE THE CREATE WINEVENT HANDLER ABOVE (W/ & W/O CRITICAL)
- */
- loop
- Sleep(100)
- /*F1::
- {
- Critical(-1)
- Sleep(5000)
- tooltip("k")
- }
- */F11::tooltip("hm")
- txt := ""
- HandleCreatedVlcEvent(hWinEventHook, event, hWnd, *)
- {
- ;Critical(-1)
- static bool := false
- try
- if (!bool && WinGetProcessName(hWnd) = "vlc.exe" && WinGetClass(hWnd) = "Qt5QWindowIcon" && WinGetTitle(hWnd) != "Building font cache")
- {
- bool := true
- global txt .= "start "
- tooltip("> " txt)
- Hotkey("F12", (*) => MsgBox("hi " (A_TickCount - start)), "On")
- SetTimer((*) => MsgBox("TIME " (A_TickCount - start)), -2000)
- global start := A_TickCount
- while (A_TickCount - start < 7000)
- { ; / immediately on event
- ;continue ;Sleep(3510) ; both make hotkey and timer interrupt immediately w/o critical Timer, F11 & F12 get buffered until after `Done` is shown w/ critical,other WinEvent handler overtake
- DllCall("Sleep", "UInt", 6510) ; ...makes hotkey and timer get buffered w/o critical Timer, F11 & F12 get buffered until after `Done` is shown w/ critical,other WinEvent handler overtake
- } ; \ after DllCall
- tooltip("done " (A_TickCount - start))
- Sleep(-1) ; Discards queued events that might remain
- DllCall("Sleep", "UInt", 3510)
- bool := false
- }
- }
- _HandleCreatedVlcEvent(hWinEventHook, event, hWnd, *)
- {
- Critical(-1)
- static bool := false
- static cnt := 0
- try
- if (!bool && WinGetProcessName(hWnd) = "vlc.exe" && WinGetClass(hWnd) = "Qt5QWindowIcon" && WinGetTitle(hWnd) != "Building font cache")
- {
- ; bool := true
- /*global txt .= "_start "
- tooltip(txt)
- start := A_TickCount
- if (++cnt = 1)
- while (A_TickCount - start < 7000)
- {
- ;continue ;Sleep(26510) ;continue ;Sleep(3510) ; both make hotkey and timer interrupt immediately w/o critical Timer, F11 & F12 get buffered until after `Done` is shown w/ critical
- ;DllCall("Sleep", "UInt", 26510) ; ...makes hotkey and timer get buffered w/o critical Timer, F11 & F12 get buffered until after `Done` is shown w/ critical
- }
- */
- tooltip("_done " txt)
- ; LEAVE BOOL TRUE B/C VLC WILL OTHERWISE RETRIGGER FOREGROUND EVENT WHEN MSGBOX GETS CLOSED
- }
- }
- __HandleCreatedVlcEvent(hWinEventHook, event, hWnd, *)
- {
- Critical(-1)
- static bool := false
- static cnt := 0
- try
- if (!bool && WinGetProcessName(hWnd) = "vlc.exe" && WinGetClass(hWnd) = "Qt5QWindowIcon" && WinGetTitle(hWnd) != "Building font cache")
- {
- ; bool := true
- tooltip("_DONE " txt)
- ; LEAVE BOOL TRUE B/C VLC WILL OTHERWISE RETRIGGER FOREGROUND EVENT WHEN MSGBOX GETS CLOSED
- }
- }
- HookEvent(event, fnObj, pid := 0) => DllCall("SetWinEventHook", "UInt", event, "UInt", event, "Ptr", 0, "Ptr", CallbackCreate(fnObj), "UInt", pid, "UInt", 0, "UInt", 0)
- /********** TRASH: `New AutoHotkey Script - Copy.ahk` (part of latest test files) **********/
- #Requires AutoHotkey 2.0
- A_WinDelay := -1 ; For the snip feature, HandleNameChangedThunderbirdEvent, HandleNameChangedTabsOutlinerEvent and the two different HandleCreatedVlcEvent functions
- A_KeyDelay := -1 ; For the XButton hotkeys (ControlSend) and for Send b/c it reverts to the Event SendMode when another AHK script installs a native low-level keyboard/mouse hook
- A_KeyDuration := 1 ; For the XButton hotkeys
- HookEvent(0x8000, HandleCreatedVlcEvent) ; TESTING THIS ONE ALONE WITH HOTKEY & TIMER, BUT COMMENT-OUT THE HOTKEY & TIMER WHEN TESTING THE WINEVENT HANDLER BELOW OVERTAKING THIS ONE <----
- ;HookEvent(0x0003, _HandleCreatedVlcEvent) ; TESTING IF A FOREGROUND WINEVENT HANDLER CAN OVERTAKE THE CREATE WINEVENT HANDLER ABOVE (W/ & W/O CRITICAL)
- ;Critical(-1) ; disabled early or not, doesn't matter.. WinEvent handlers still overtake eachother
- loop
- Sleep(100)
- F1::
- {
- Critical(-1)
- tooltip("F1")
- ;SetTimer((*) => MsgBox("TIME"), -2000)
- Sleep(10000)
- tooltip("k")
- }
- F11::tooltip("hm")
- txt := ""
- HandleCreatedVlcEvent(hWinEventHook, event, hWnd, *)
- {
- Critical(-1)
- static bool := false
- try
- if (!bool && WinGetProcessName(hWnd) = "vlc.exe" && WinGetClass(hWnd) = "Qt5QWindowIcon" && WinGetTitle(hWnd) != "Building font cache")
- {
- bool := true
- global txt .= "start "
- tooltip(txt)
- ;Hotkey("F12", (*) => MsgBox("hi"), "On")
- ;SetTimer((*) => MsgBox("TIME"), -2000)
- start := A_TickCount
- while (A_TickCount - start < 7000)
- { ; / immediately on event
- ;continue ;Sleep(13510) ; both make hotkey and timer interrupt immediately w/o critical Timer, F11 & F12 get buffered until after `Done` is shown w/ critical,other WinEvent handler overtake
- DllCall("Sleep", "UInt", 13510) ; ...makes hotkey and timer get buffered w/o critical Timer, F11 & F12 get buffered until after `Done` is shown w/ critical,other WinEvent handler overtake
- } ; \ after DllCall
- tooltip("done")
- Sleep(-1) ; Discards queued events that might remain
- DllCall("Sleep", "UInt", 3510)
- bool := false
- }
- }
- _HandleCreatedVlcEvent(hWinEventHook, event, hWnd, *)
- {
- Critical(-1)
- static bool := false
- try
- if (!bool && WinGetProcessName(hWnd) = "vlc.exe" && WinGetClass(hWnd) = "Qt5QWindowIcon" && WinGetTitle(hWnd) != "Building font cache")
- {
- bool := true
- global txt .= "_start "
- tooltip(txt)
- start := A_TickCount
- while (A_TickCount - start < 7000)
- {
- ;continue ;Sleep(3510) ; both make hotkey and timer interrupt immediately w/o critical Timer, F11 & F12 get buffered until after `Done` is shown w/ critical
- DllCall("Sleep", "UInt", 3510) ; ...makes hotkey and timer get buffered w/o critical Timer, F11 & F12 get buffered until after `Done` is shown w/ critical
- }
- tooltip("_done")
- ; LEAVE BOOL TRUE B/C VLC WILL OTHERWISE RETRIGGER FOREGROUND EVENT WHEN MSGBOX GETS CLOSED
- }
- }
- HookEvent(event, fnObj, pid := 0) => DllCall("SetWinEventHook", "UInt", event, "UInt", event, "Ptr", 0, "Ptr", CallbackCreate(fnObj), "UInt", pid, "UInt", 0, "UInt", 0)
- /********** TRASH: `_test - Copy - Copy - Copy.ahk` (part of extra test files that are even newer) **********/
- #Requires AutoHotkey 2.0
- Persistent()
- A_CoordModeToolTip := "Screen"
- EVENT_SYSTEM_FOREGROUND := 0x0003
- EVENT_OBJECT_SHOW := 0x8002
- text := ""
- HookEvent(EVENT_SYSTEM_FOREGROUND, HandleActivatedWindowTaskbarEvent)
- HookEvent(EVENT_OBJECT_SHOW, HandleShowedFullscreenWinEvent)
- HookEvent(event, fnObj, pid := 0) => DllCall("SetWinEventHook", "UInt", event, "UInt", event, "Ptr", 0, "Ptr", CallbackCreate(fnObj), "UInt", pid, "UInt", 0, "UInt", 0)
- ;there's also a WinAPI Sleep fn..
- F1:: ; seems like hotkeys and timers can interrupt w/o critical and get buffered w/ critical (tested with Sleep only, but Sleep might be irrelevant b/c they might overtake at any line)
- tf(*) ; and I think WinEvent handlers can interrupt a thread whether it has or doesn't have critical, as long as it's sleeping (not sure if I actually ever tested it w/ critical tho)
- {
- global text .= " _____"
- Tooltip(text)
- }
- HandleActivatedWindowTaskbarEvent(hWinEventHook, event, hWnd, *)
- {
- ;Critical(-1) ; Even without this, it finishes completely before the next goes (w/ busy-wait, plus w/ and w/o sleep)
- static count := 0
- try
- {
- ; Critical(-1) ; (W/ BUSY-WAIT) 1 1 2 2 3 3 when uncommented, 1 2 3 3 2 1 when commented-out
- ;SetTimer(tf, -1)
- global text .= " ^^f" (id := ++count)
- Tooltip(text)
- start := A_TickCount
- while (A_TickCount - start < 200) ;7000)
- ; loop (80000000) ; Approx. 2sec busy-wait (has approx. 30% CPU usage at most)
- continue
- ;loop (4)
- Sleep(7000) ;200) ;Sleep(-1) ; (W/ CRITICAL ON) 1 2 3 3 2 1 when uncommented, 1 1 2 2 3 3 when commented-out
- ;,
- Tooltip(text .= " ^^f" id)
- }
- }
- HandleShowedFullscreenWinEvent(hWinEventHook, event, hWnd, *)
- {
- ;Critical(-1)
- static count := 0
- try
- {
- ; Critical(-1) ; (W/ BUSY-WAIT) 1 1 2 2 3 3 when uncommented, 1 2 3 3 2 1 when commented-out
- ;SetTimer(tf, -1)
- global text .= " __s" (id := ++count)
- Tooltip(text)
- loop (800000000) ; Approx. 2sec busy-wait (has approx. 30% CPU usage at most)
- continue
- ;loop (4)
- Sleep(200) ;Sleep(-1) ; (W/ CRITICAL ON) 1 2 3 3 2 1 when uncommented, 1 1 2 2 3 3 when commented-out
- ;,
- Tooltip(text .= " __s" id)
- }
- }
- /********** TRASH: `_test - Copy - Copy - Copy - Copy.ahk` (part of extra test files that are even newer) **********/
- #Requires AutoHotkey 2.0
- Persistent()
- A_CoordModeToolTip := "Screen"
- EVENT_SYSTEM_FOREGROUND := 0x0003
- EVENT_OBJECT_SHOW := 0x8002
- text := ""
- HookEvent(EVENT_SYSTEM_FOREGROUND, HandleActivatedWindowTaskbarEvent)
- HookEvent(EVENT_OBJECT_SHOW, HandleShowedFullscreenWinEvent)
- HookEvent(event, fnObj, pid := 0) => DllCall("SetWinEventHook", "UInt", event, "UInt", event, "Ptr", 0, "Ptr", CallbackCreate(fnObj), "UInt", pid, "UInt", 0, "UInt", 0)
- ;there's also a WinAPI Sleep fn..
- F1:: ; seems like hotkeys and timers can interrupt w/o critical and get buffered w/ critical (tested with Sleep only, but Sleep might be irrelevant b/c they might overtake at any line)
- tf(*) ; and I think WinEvent handlers can interrupt a thread whether it has or doesn't have critical, as long as it's sleeping (not sure if I actually ever tested it w/ critical tho)
- {
- global text .= " _____"
- Tooltip(text)
- }
- HandleActivatedWindowTaskbarEvent(hWinEventHook, event, hWnd, *)
- {
- Critical(-1)
- static bool := false
- try
- if (!bool && WinGetProcessName(hWnd) = "vlc.exe" && WinGetClass(hWnd) = "Qt5QWindowIcon" && WinGetTitle(hWnd) != "Building font cache")
- {
- bool := true
- global text .= " ^^f" (id := ++count)
- Tooltip(text)
- start := A_TickCount
- ;while (A_TickCount - start < 7000)
- loop (80000000) ; Approx. 2sec busy-wait (has approx. 30% CPU usage at most)
- continue
- ;loop (4)
- Sleep(200) ;Sleep(-1) ; (W/ CRITICAL ON) 1 2 3 3 2 1 when uncommented, 1 1 2 2 3 3 when commented-out
- ;,
- Tooltip(text .= " ^^f" id)
- bool := false
- }
- }
- HandleShowedFullscreenWinEvent(hWinEventHook, event, hWnd, *)
- {
- Critical(-1)
- static bool := false
- try
- if (!bool && WinGetProcessName(hWnd) = "vlc.exe" && WinGetClass(hWnd) = "Qt5QWindowIcon" && WinGetTitle(hWnd) != "Building font cache")
- {
- bool := true
- ;msgbox("?")
- global text .= " ^^f" (id := ++count)
- Tooltip(text)
- start := A_TickCount
- ;while (A_TickCount - start < 7000)
- loop (80000000) ; Approx. 2sec busy-wait (has approx. 30% CPU usage at most)
- continue
- ;loop (4)
- Sleep(200) ;Sleep(-1) ; (W/ CRITICAL ON) 1 2 3 3 2 1 when uncommented, 1 1 2 2 3 3 when commented-out
- ;,
- Tooltip(text .= " ^^f" id)
- bool := false
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement