Sign in to follow this  
Followers 0
Top Qat

GUI noob question about focus

17 posts in this topic

I have an AutoIT3 script that works fine except for one minor problem.

Whenever I show a MSGbox or get a file or folder the main GUI controls can still be used.

I need to be able to stop the main GUI from being focus whenever I have MSG box / FileSelectFolder / FileOpenDialog active.

Any idea?

Share this post


Link to post
Share on other sites



I have an AutoIT3 script that works fine except for one minor problem.

Whenever I show a MSGbox or get a file or folder the main GUI controls can still be used.

I need to be able to stop the main GUI from being focus whenever I have MSG box / FileSelectFolder / FileOpenDialog active.

Any idea?

GUISetState(@SW_Disable) or GUISetState(@SW_Hide) ?


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Ahha! Told ya i was a noob didn't I !

Thanks that seems to work except for one problem

GUISetState (@SW_Disable ,  $Form[1] )
    $result = FileSelectFolder ( 'Select the remote Windows directory...', $MyComputer , 0 )
    $error = @error
    GUISetState (@SW_Enable ,  $Form[1] )

This makes the GUI jump behind the last active window and lose focus.

So I need to make sure it has focus.

What now?

...more...

How do I set the OK button to be default and respond to the Enter key?

Edited by Top Qat

Share this post


Link to post
Share on other sites

This makes the GUI jump behind the last active window and lose focus.

So I need to make sure it has focus.

What now?

WInActivate() ?

How do I set the OK button to be default and respond to the Enter key?

Set Button style to $BS_DEFPUSHBUTTON ...


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

This makes the GUI jump behind the last active window and lose focus.

So I need to make sure it has focus.

Set the window to @SW_SHOW after the @SW_ENABLE.

EDIT: JdeB got in while I was posting (fast!).

Edited by Sokko

Share this post


Link to post
Share on other sites

GUISetState (@SW_Disable ,  $Form[1] )
    $result = FileSelectFolder ( 'Select the remote Windows directory...', $MyComputer , 0 )
    $error = @error
    GUISetState (@SW_Enable ,  $Form[1] )
    GUISetState (@SW_Show ,  $Form[1] )

@Sokko

Still the same focus problem with this code.

@JdeB

The WinActivate( ) method seems a little untidy, I would prefer to use the saved Form GUI ID if possible.

Share this post


Link to post
Share on other sites

maybe

GUISetState (@SW_Hide , $Form[1] )

$result = FileSelectFolder ( 'Select....... blah


NEWHeader1.png

Share this post


Link to post
Share on other sites

GUISetState (@SW_Hide , $Form[1])

Ok, that works better.

Only thing I don't like is that it leaves the File/Folder dialog without any reference to which program it belongs to.

I'm a bit of a perfectionist I am :o

Share this post


Link to post
Share on other sites

FileSelectFolder Dialoge has a title and text lines.. use that to keep your Program title/info

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

FileSelectFolder Dialoge has a title and text lines.. use that to keep your Program title/info

Yup, thought about that. Works for FileOpenDialog.

FileSelectFolder does not allow the window title to be specified.

Share this post


Link to post
Share on other sites

Whenever I get an AutoIT error box, it behaves exactly the way I need.

:o

Share this post


Link to post
Share on other sites

maybe you could use an inputbox that would act the same and put this as the "default"

$MyComputer

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

MsgBox ( 16 + 8192 + 262144 , $Title , 'Blah blah blah!' )

Those numbers fix the MsgBox focus problem.

They are:

Stop-sign icon

Task modal

MsgBox has top-most attribute set

Share this post


Link to post
Share on other sites

GUISetState (@SW_Disable ,  $Form[1] )
    $result = FileSelectFolder ( 'Select the remote Windows directory...', $MyComputer , 0 )
    $error = @error
    GUISetState (@SW_Enable ,  $Form[1] )
    GUISetState (@SW_Show ,  $Form[1] )

@Sokko

Still the same focus problem with this code.

Whoops, nevermind. I had this same problem before, but with a child window instead of a folder selection, and I thought I fixed it by doing that. Looking at the code, I actually did it another way, which wouldn't be possible to use with a folder selection (since I'm fairly certain it relies on the properties of child windows).

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Don't know if I mentioned it before but what about WinActivate? :o

Something like:

Opt("WinTitleMatchMode", 4) 
$H_Active_Win = WinGetHandle()
; your msgbox
WinActivate($H_Active_Win)
Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Thanks guys, i'll give it a go.

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

So to sum up. I can't set File/Folder dailogs to act as 'task modal' like the message box.

The only way to stop any extra GUI form events is to disable all the controls before the call, then re-enable them all after.

...or do this after each Folder/File dialog

;Get rid of any excess events
Func ClearGuiEvents ( )

    While GuiGetMsg()
; Do nothing
    Wend

EndFunc

Perhaps this is something to look at as a new feature that can be added (i.e Task modal for browse dialogs)

Edited by Top Qat

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