Jump to content

Fileopendialog() start focus file list


Go to solution Solved by DW1,

Recommended Posts

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

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

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

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

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

  • Solution

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

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

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

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

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

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