Sign in to follow this  
Followers 0
Roel

Active program loose focus after autoit popup

7 posts in this topic

Hi,

We've got a popup when there is a new message in a chat. The problem is that when someone is typing in eg Word and there is a message in the chat, Word looses focus. So you have to click in Word before you can type again.

Are there solutions, maybe a splash screen or somehting, to avoid this?

Thanks!!

Roel

Share this post


Link to post
Share on other sites



Local $hWndActive = WinGetHandle("[ACTIVE]") ; Store a handle to the currently active window

; Do whatever you do here that loses focus
; I'm going to open notepad
Run("notepad.exe")
WinWaitActive("[CLASS:Notepad]")

If ($hWndActive <> "") Then ; Check if there was a window active in the first place
    WinActivate($hWndActive) ; Activate that window
EndIf

Comments describe the solution. ; )

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi Manadar,

The solution you gave is a good solution. However, the program loose for a couple of seconds focus. Is there a solution that the active program will not loose focus at anytime?

@Smashly, it is already a gui.

Regards,

Roel

Edited by Roel

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hi Manadar,

The solution you gave is a good solution. However, the program loose for a couple of seconds focus. Is there a solution that the active program will not loose focus at anytime?

@Smashly, it is already a gui.

Regards,

Roel

Try Smashly's solution.

GUISetState(@SW_SHOWNA, $hGui)

@SW_SHOWNA means show GUI but do not activate it.

You can also try @SW_SHOWMINNOACTIVE .

Edited by Manadar

Share this post


Link to post
Share on other sites

That is the solution! I didn't see the SHOWNA :-(

Thanks!

Roel

Share this post


Link to post
Share on other sites

Try Smashly's solution.

GUISetState(@SW_SHOWNA, $hGui)

@SW_SHOWNA means show GUI but do not activate it.

You can also try @SW_SHOWMINNOACTIVE .

In my opinion it should be standard practice to show a new window but not steal focus.

The number of times I've agreed to something, or acknowledged an unknown error when a dialog pops up and steals focus from the Word Processor and started parsing the keyboard input.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0