Sign in to follow this  
Followers 0
Xandy

Fileopendialog() start focus file list

13 posts in this topic

Is there a way to set focus in a fileopendialog()?

I would like to set the initial focus to the file selection where up, down, left, right arrows, select different files.

I tried scanning the init dir first and selecting the first file as the first file suggested by fileopendialog().

Although it did change the file suggestion it did not affect control focus within the dialog.

I allow users to select options via keyboard, a option brings up a fileopendialog().  It would be nice not to force the user to grab his or her mouse.

Video Example:

http://www.youtube.com/watch?v=0PA29bwDeGU&feature=youtu.be

Share this post


Link to post
Share on other sites



I presume you've tried the Window Info Tool, and used Window Title, Class, etc?

And Tabs etc if need be?

1 person likes this

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I have not, but I see where you are going.

That might be the way I'll have to do it.

Thank you!

Edited by Xandy

Share this post


Link to post
Share on other sites

I was thinking you meant ControlClick() or setting focus prier.

The problem I'm having with that logic is the dialog would have to exist.

The program is held at the call to fileopendialog() and the controls don't exist until I call fileopendialog().

The Windows Info Tool showed distinguishable results for the file list section.

Class: DirectUIHWND

Classname: DirectUIHWND2

Advanced Mode: [CLASS:DirectUIHWND; INSTANCE:2]

but I don't know how to use them before the controls exist.

Share this post


Link to post
Share on other sites

If you are trying to avoid writing your own fileopendialog, then you could write a temp file to do the work for you.

$sTitle = 'This is my file open title'
$sTempau3 = "WinWaitActive('" & $sTitle & "', '', 10)" & @CRLF
$sTempau3 &= "ControlFocus('" & $sTitle & "', '', '[CLASS:DirectUIHWND; INSTANCE:2]')"
$hFile = FileOpen(@TempDir & '\tempau3.au3', 2)
FileWrite($hFile, $sTempau3)
FileClose($hFile)

Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @TempDir & '\tempau3.au3"')
FileOpenDialog($sTitle,'','')
1 person likes this

Share this post


Link to post
Share on other sites

Better yet, don't use a temp file at all by getting the winwait and controlfocus in the same singe line.

$sTitle = 'This is my file open title'
$sTempau3 = "If WinWaitActive('" & $sTitle & "', '', 10) And ControlFocus('" & $sTitle & "', '', '[CLASS:DirectUIHWND; INSTANCE:2]') Then ConsoleWrite('')"
Run(@AutoItExe & ' /AutoIt3ExecuteLine "' & $sTempau3 & '"')
FileOpenDialog($sTitle,'','')
1 person likes this

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

It took me a little while because I just to had to learn how it worked by doing it wrong.

Your example works as is.

Building my own browse file dialog is the other solution.  I have one I built for browsing images, but sometimes it glitches when traversing a new dirpath and I'd want to reorganize the button layout.  Not what I want to be doing right now.

Your solution rocks!  Do you know of any reading material on AutoIt3ExecuteLine use and formatting?

I noticed FileOpenDialog() wouldn't run from there, I don't think beep() worked either.

Either way, Thanks danwilli.

Edited by Xandy

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

The only documentation for it that I know of is in the Using AutoIt > Running Scripts part of the help file.  It doesn't go in to very much detail.  It's at the bottom of the page under "AutoIt specific command Line Switches".

Both Beep() and FileOpenDialog() worked fine for me using AutoIt3ExecuteLine.  Strange that it didn't for you.

$sTempau3 = 'FileOpenDialog(''' & $sTitle & ''', '''', '''')'
Run(@AutoItExe & ' /AutoIt3ExecuteLine "' & $sTempau3 & '"')


$sTempau3 = 'Beep()'
Run(@AutoItExe & ' /AutoIt3ExecuteLine "' & $sTempau3 & '"')
Edited by danwilli
1 person likes this

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I'm to new to the ability.  I'm sure I messed something up with the commands when splicing it with my code.

I'll learn thank you for the support and feed back.

Edited by Xandy

Share this post


Link to post
Share on other sites

Maybe you give the WinApiEX function with the fabulous name _WinAPI_ShellOpenFolderAndSelectItems() a try too?

1 person likes this

Share this post


Link to post
Share on other sites

Maybe you give the WinApiEX function with the fabulous name _WinAPI_ShellOpenFolderAndSelectItems() a try too?

What an aptly named function that I've never noticed before.  Good call :)

Share this post


Link to post
Share on other sites

It took me a little while because I just to had to learn how it worked by doing it wrong.

An abject lesson to many others here, that is the continual pathway for most of us, as it can't be helped ... if you actually want to learn.

1 person likes this

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

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