Jump to content

Recommended Posts

Posted

I'm working on a notification script, but I don't like that every time a notification pops up it takes the computers focus. Any ideas how to make a GUI that exists only as a notification (always on top, but no focus)

Posted

I'm working on a notification script, but I don't like that every time a notification pops up it takes the computers focus. Any ideas how to make a GUI that exists only as a notification (always on top, but no focus)

Try this.

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

$hWnd = DllCall('user32.dll', 'hwnd', 'GetForegroundWindow')
GUICreate('', 400, 200, -1, -1, BitOR($WS_POPUP, $WS_OVERLAPPEDWINDOW), $WS_EX_TOPMOST)
GUISetState()
DllCall('user32.dll', 'hwnd', 'SetForegroundWindow', 'hwnd', $hWnd[0])

do
    Sleep(10)
until GUIGetMsg() = $GUI_EVENT_CLOSE
Posted

Try this.

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

$hWnd = DllCall('user32.dll', 'hwnd', 'GetForegroundWindow')
GUICreate('', 400, 200, -1, -1, BitOR($WS_POPUP, $WS_OVERLAPPEDWINDOW), $WS_EX_TOPMOST)
GUISetState()
DllCall('user32.dll', 'hwnd', 'SetForegroundWindow', 'hwnd', $hWnd[0])

do
    Sleep(10)
until GUIGetMsg() = $GUI_EVENT_CLOSE
I wish more devs thought like this, focus stealing is the biggest pain in the @rse

I added a sleep(1000) st the start so I could activate something else before it kicked in, works lovely :)

How many times have I hit enter at the end of my sentence to then wonder why my pc is rebooting or some other such nonsense!

Posted

This is better.

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>

$Form = GUICreate('', 400, 200, -1, -1, BitOR($WS_POPUP, $WS_OVERLAPPEDWINDOW), $WS_EX_TOPMOST)
_WinAPI_ShowWindow($Form, @SW_SHOWNOACTIVATE)

do
    Sleep(10)
until GUIGetMsg() = $GUI_EVENT_CLOSE
Posted

This is better.

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>

$Form = GUICreate('', 400, 200, -1, -1, BitOR($WS_POPUP, $WS_OVERLAPPEDWINDOW), $WS_EX_TOPMOST)
_WinAPI_ShowWindow($Form, @SW_SHOWNOACTIVATE)

do
    Sleep(10)
until GUIGetMsg() = $GUI_EVENT_CLOSE
Thanks very much! But there is an even easier way, without having to use the WinApi just GUISetState(@SW_SHOWNOACTIVATE)

Thanks again for your help!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...