Jump to content

Recommended Posts

Posted

HI all 

Is that possible to have the FileSelectFolder comes up in the center of screen?  What commands I must use?

also change the position's

Now it is popup in upper left corner that is standard i think

 

Posted (edited)

Hi, you can winmove to move that window to where you want, and you can use a udf like melba23's, that allows you to set the coordinates directly.

EDIT: on second thought, i think fileselectfolder stops the script, like winwait or msgbox, so winmove wouldn't be able to move the window, unless it's running in a loop outside of the function where select folder is.

Edited by careca
  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

  • Moderators
Posted

careca,

As that function is blocking, how do you intend to move it from within the script? There is a way, but it is not that simple.

Borje,

As you might expect, I second the vote for my UDF.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

Yeah, it blocks either way. :\

Maybe with AdlibRegister and checking for the window, and move it if exists..

  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

  • Moderators
Posted

Borje,

You cannot WinMove the FileSelectFolder dialog from within your script - at least not without getting into some very complicated /AutoIt3ExecuteScript stuff, which I would not recommend.

As both of us suggested, if you really want a controllable dialog in terms of position and size then take a look at my UDF - that is one of the reasons I wrote it!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

I had the impression your udf had a folder select like the regular one, instead of treeview.

TBH im not a big fan of treeview, is there something like the OP wants, that allows selection,

with the "normal" icon view, and window position customizable?

  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted (edited)

This works for me
Based on a script from funkey (initially used to manage a msgbox)

#include <GUIConstantsEx.au3>
#include <WinAPI.au3>

Global $fsfX = 800
Global $fsfY = 200
Global $hHookFsF


$gui = GuiCreate("test", 200, 100)
$btn = GuiCtrlCreateButton("test", 50, 30, 50, 25)
GuiSetState()

While 1
   $msg = GuiGetMsg()
   Switch $msg
     Case $GUI_EVENT_CLOSE
         Exit
     Case $btn
         $sFileSelectFolder = _FileSelectFolder("test", "")
         If $sFileSelectFolder = "" Then
            MsgBox(0, "", "No folder was selected.")
         Else
            MsgBox(0, "", "You chose the following folder:" & @CRLF & $sFileSelectFolder)
         EndIf
   EndSwitch
Wend


Func _FileSelectFolder($dialog, $rootdir, $flag = 0, $initdir = "", $hwnd = 0)
   Local $hProcFsF = DllCallbackRegister("CbtHookProcFsF", "int", "int;int;int")
   Local $TIDFsF = _WinAPI_GetCurrentThreadId()
   $hHookFsF = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($hProcFsF), 0, $TIDFsF)
   Local $iRet = FileSelectFolder($dialog, $rootdir, $flag, $initdir, $hwnd)
   _WinAPI_UnhookWindowsHookEx($hHookFsF)
   DllCallbackFree($hProcFsF)
   Return $iRet 
EndFunc

Func CbtHookProcFsF($nCode, $wParam, $lParam)
   Local $RET = 0
    If $nCode < 0 Then
        $RET = _WinAPI_CallNextHookEx($hHookFsF, $nCode, $wParam, $lParam)
        Return $RET
    EndIf
    Switch $nCode
        Case 5   ;5=HCBT_ACTIVATE
           If $wParam <> $gui Then _WinAPI_SetWindowPos($wParam, $HWND_TOP, $fsfX, $fsfY, _ 
            _WinAPI_GetWindowWidth($wParam), _WinAPI_GetWindowHeight($wParam), $SWP_NOZORDER)
    EndSwitch
    Return
EndFunc   ;==>CbtHookProcFsF

 

Edited by mikell
Posted

@Mikell
Looks like you made a typo.
$hHookFsF is use in function CbtHookProcFsF but not declared. It's declared in _FileSelectFolder as Local but needs to be Global. 

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Posted (edited)

I made a kind of a workaround, just for fun.

First part is a compiled exe that accepts parameters, called right before the fileselectfolder, and timeouts after 3 secs.

Local $begin = TimerInit()
Local $dif
Do
    $dif = TimerDiff($begin)
    If WinExists($CmdLine[1]) Then
    WinMove($CmdLine[1],$CmdLine[2], $CmdLine[3], $CmdLine[4], $CmdLine[5], $CmdLine[6])
    EndIf
    Sleep(100)
Until $dif >= 3000

Second is the script, that passes parameters, title, text, coordinates, size.

$Title = 'SelectTest'
$Text = '""'
$X = 500
$Y = 500
$XSize = 800
$YSize = 400
Go()
Func Go()
    ShellExecute('MoveDlg.exe', $Title&' '&$Text&' '&$X&' '&$Y&' '&$XSize&' '&$YSize)
    Local $Select = FileSelectFolder('SelectTest', '', 0, '')
    Exit
EndFunc

While 1
    Sleep(100)
WEnd

So if the user has the compiled script somewhere and calls it this way, with these parameters,

the window gets re-positioned and re-sized as desired.

To ignore the re-size its just a matter of replacing the number with '""' double quotes, inside quotes, can't have spaces.

:)

Edited by careca
  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

  • Moderators
Posted

careca,

That is essentially the /AutoIt3ExecuteScript method I mentioned - you need to run something outside the main script, either compiled or as another script.

mikell,

Very clever.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

Thanks all for the tips and examples it works perfect now I am supriced you is so helpful I have to study this examples

from the members of this forum...

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
  • Recently Browsing   0 members

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