How to raise thread priority of GUI window

Get help with using AutoHotkey and its commands and hotkeys
pneumatic
Posts: 299
Joined: 05 Dec 2016, 01:51

How to raise thread priority of GUI window

14 Apr 2017, 16:19

Hello

My script implements process detection which runs a Timer in a loop every 10ms to detect if a process is running. This timer is constantly running in the background and causes window movement in my GUI to become stuttery and low frame rate. I presume this is because the window rendering thread is constantly being interrupted every 10ms (well, 15.6ms apparently) as the timer fires off. If I turn the timer off, the window movement is smooth again.

I have tried the following:

1. SetBatchlines -1
2. Lower the timer's priority
3. Make the autoexec section critical
4. Make the GUI section (which is contained within a function) critical

Another idea might be to turn the timer off OnMessage(window moving) and then turn it back on again OnMessage(window stopped moving), however I think that may cause bugs as the timer's duration must expire before it's turned off, and so any repetitive movements of the window may create a long stack of weird threads waiting to be turned on and off again. I cannot afford to have the thread bugging out or becoming unreliable. I am already quite lucky to have it running without bugs as previously I had to move the entire timer to a separate .ahk file as some weird things were happening when 3 timers are running and one of them is sleeping, where one of the threads would become blocked (the documentation doesn't specify what happens to a thread that becomes interrupted while sleeping).

Any tips appreciated for achieving smooth window movement while timers running.

Thanks
pneumatic
Posts: 299
Joined: 05 Dec 2016, 01:51

Re: How to raise thread priority of GUI window

14 Apr 2017, 22:41

pneumatic wrote:
Another idea might be to turn the timer off OnMessage(window moving) and then turn it back on again OnMessage(window stopped moving)

Seems to work. I'm turning timers off when WM_ENTERSIZEMOVE and back on when WM_EXITSIZEMOVE. No bugs so far. I think it will only work reliably for timers with very short durations as every time a timer is turned back on it has to wait the full duration of the timer before turning it back on. For turning it off, the ahk documentation doesn't say anything about whether it shuts the timer off in the middle of its routine or whether it waits for the current iteration to finish. Would be nice to know. I am still concerned about whether win10 implements the WM messages the same as on win7, which could break my whole script.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], f1ster, Google [Bot], Jovannb, mikeyww, Rikk03 and 47 guests