Jump to content

GUI noob question about focus


 Share

Recommended Posts

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?

Link to comment
Share on other sites

  • Developers

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) ?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Developers

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 ...

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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.

Set the window to @SW_SHOW after the @SW_ENABLE.

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

Edited by Sokko
Link to comment
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.

Link to comment
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

Link to comment
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.

Link to comment
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).
Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...