Sign in to follow this  
Followers 0
jezzzzy

Hidden window taking focus

8 posts in this topic

#1 ·  Posted (edited)

I run GUISetState(@SW_HIDE,$GUIMain) when the close icon is clicked to imitate a "minimized to tray" behavior. However, this minimized GUI steals focus for each update. These updates happen every 30s. You can imagine how aggravating it is to have your active window lose focus every 30 seconds. When this window is "maximized" again with GUISetState(), it doesn't steal the focus. My update function is lengthy and I can't seem to narrow down what is causing the hidden window to grab focus. I don't use any weird functions in my update function: _inetget stuff and string manipulation is really all. There are some GUISetState(@SW_DISABLE) and GUISetState(@SW_ENABLE) also.

Edit: spelling

Edited by jezzzzy

Share this post


Link to post
Share on other sites



I run GUISetState(@SW_HIDE,$GUIMain) when the close icon is clicked to imitate a "minimized to tray" behavior. However, this minimized GUI steals focus for each update. These updates happen every 30s. You can imagine how aggravating it is to have your active window lose focus every 30 seconds. When this window is "maximized" again with GUISetState(), it doesn't steal the focus. My update function is lengthy and I can't seem to narrow down what is causing the hidden window to grab focus. I don't use any weird functions in my update function: _inetget stuff and string manipulation is really all. There are some GUISetState(@SW_DISABLE) and GUISetState(@SW_ENABLE) also.

Edit: spelling

I think you'll need to post some code which reproduces the problem to make progress with that one.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Ok. I've narrowed down the problem to the following functions:

Func _LockAndWait()
    GUISetState(@SW_DISABLE)
    GUISetCursor(15, 1)
EndFunc ;==>_LockAndWait

Func _ResetLockWait()
    GUISetState(@SW_ENABLE)
    GUISetCursor(2, 1)
EndFunc ;==>_ResetLockWait

I believe these are a variation of GaryFrost's functions. If I comment out the function call for these, the gui doesn't steal focus. I have narrowed it down to the GUISetState(@SW_ENABLE) and GUISetState(@SW_DISABLE). I'm guessing this is just a by-product of enabling and disabling the GUI. Is there a better way to disable the GUI without it getting focused?

Share this post


Link to post
Share on other sites

Ok. I've narrowed down the problem to the following functions:

Func _LockAndWait()
     GUISetState(@SW_DISABLE)
     GUISetCursor(15, 1)
 EndFunc;==>_LockAndWait
 
 Func _ResetLockWait()
     GUISetState(@SW_ENABLE)
     GUISetCursor(2, 1)
 EndFunc;==>_ResetLockWait

I believe these are a variation of GaryFrost's functions. If I comment out the function call for these, the gui doesn't steal focus. I have narrowed it down to the GUISetState(@SW_ENABLE) and GUISetState(@SW_DISABLE). I'm guessing this is just a by-product of enabling and disabling the GUI. Is there a better way to disable the GUI without it getting focused?

Do you repeatedly call those functions when you have the problem?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

They get called once each update cycle (generally every 30s).

Share this post


Link to post
Share on other sites

They get called once each update cycle (generally every 30s).

I think you just need to remember the set state, or read the state.

Global $LockState = 0

Func _LockAndWait()
If $LockState = @SW_DISABLE then return
     GUISetState(@SW_DISABLE)
     GUISetCursor(15, 1)
$LockState = @SW_DISABLE
 EndFunc;==>_LockAndWait
 
 Func _ResetLockWait()
If $LockState = @SW_ENABLE then return
     GUISetState(@SW_ENABLE)
     GUISetCursor(2, 1)
   $LockState = @SW_ENABLE 
 EndFunc;==>_ResetLockWait

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Why are you enabling and disabling a hidden window? That seems very unnecessary to me

Disabling it in the off chance that the user unhides the window with the task tray icon during the update. I may just disable the "unhide" option during the update. That seems to be a good workaround. Thanks for helping me noodle the problem.

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