My GUI takes focus every second, not allowing me to work at all. Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
rx65m
Posts: 19
Joined: 16 Mar 2018, 17:29

My GUI takes focus every second, not allowing me to work at all.

Post by rx65m » 29 Jan 2023, 08:29

I've created this script to notify me every 20 minutes while I'm working on my computer.
It has a GUI that displays the remaining time until the next notification.
However, I've encountered an issue where the GUI takes focus every time it updates the remaining time, making it impossible for me to work on any other window.
I've tried for over 8 hours to resolve this issue but I haven't been able to find a solution.

I would greatly appreciate any suggestions or advice on how to make the GUI behave like any regular window, remaining unnoticed unless I need to check it.
I am open to every possible solution, including a complete change of the approach if necessary.

I run Version 1.1.36.02

Thank you in advance for your time and help.

Code: Select all

counter = 0

Alarm() {
	global counter
	counter := 0
	Sleep, 500
	SoundPlay, alarm.wav
	Sleep, 500
	Run, alarm.ahk
	Sleep, 500
	ExitApp
}

TrackTime() {
	global counter
	counter++
	if (counter >= 1200) {  ; 15 minutes in seconds
		counter := 0
		Alarm()
	}
	minutes_remaining := Floor((1200-counter)/60)  ; convert to minutes
	seconds_remaining := Mod(1200-counter, 60)  ; calculate remaining seconds
	if (seconds_remaining < 10) {
		seconds_remaining := "0" . seconds_remaining
	}
	Gui, Add, Text, x7 y7, Time Remaining: %minutes_remaining%:%seconds_remaining%
	Gui, Show, x0 y1030
	Gui, +LastFound
}

Gui, Destroy

SetTimer, TrackTime, 1000
SetTimer, Alarm, 1200000
return

User avatar
mikeyww
Posts: 27041
Joined: 09 Sep 2014, 18:38

Re: My GUI takes focus every second, not allowing me to work at all.  Topic is solved

Post by mikeyww » 29 Jan 2023, 09:05

Show:
NoActivate: Unminimizes or unmaximizes the window, if necessary. The window is also shown without activating it.
You may prefer the NA option if you are minimizing the GUI.
Last edited by mikeyww on 29 Jan 2023, 09:08, edited 1 time in total.

rx65m
Posts: 19
Joined: 16 Mar 2018, 17:29

Re: My GUI takes focus every second, not allowing me to work at all.

Post by rx65m » 29 Jan 2023, 10:04

Amazing!
That was extremely simple!
Thanks a lot mikeyww ! That works charmingly!

Post Reply

Return to “Ask for Help (v1)”