Sign in to follow this  
Followers 0
failedtocompile

FileSelectFolder and ControlGetText

3 posts in this topic

Hi guys,

Is it possible to easily get the current folder selected within Autoit's created FileSelectFolder?

snip of script:

Func _test1()
    ControlHide($MainGui, "", GUICtrlGetHandle($input_output))
    ControlHide($MainGui, "", GUICtrlGetHandle($TheGO_button))
    GUICtrlSetData($Activatedfunction, "", "")
    GUICtrlSetData($input_output, "", "")
    ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    $alpha = FileSelectFolder("Choose a folder.", $server_store, 7) <------- This is where i need to read text from
    If @error = 1 Then
    Else

        GUICtrlSetData($Activatedfunction, "", "")
        GUICtrlSetData($input_output, $alpha, GUICtrlSetFont($input_output, 8, 600, "", "CLEARTYPE_QUALITY=5"))
        ControlShow($MainGui, "", GUICtrlGetHandle($input_output))
        GUICtrlSetData($Activatedfunction, "alpha Function has been selected" & @CR & "Will 123 to the following location", "")
        GUICtrlSetData($TheGO_button, "You have a go for launch", "")
        ControlShow($MainGui, "", GUICtrlGetHandle($TheGO_button))

    EndIf
EndFunc   ;==>_test1

I have tried a few methods but i dont want to lose the option of checking if okay and cancel was pressed

Tried1: 
$alpha = FileSelectFolder("Choose a folder to backup profile to.", $server_store, 7, $123 = ControlGetText("Browse For Folder", "", "Edit1"))

Tried2:
    $bkupto = FileSelectFolder("Choose a folder.", $server_store, 7)
        If @error = 1 Then
    $i = 1
    while $i = WinActive("Browse For Folder", "")
            $123 = ControlGetText("Browse For Folder", "", "Edit1")
        WEnd
    Else

Both outputed to a msgbox(0, "", $123) which displays blank.

anyone know of a way to successfully capture the text.

Thanks in advance.

ftc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I think you would have to have a second scipt monitor for the "Browse Folder" window since the script pauses with the FileSelectFolder() function. Even AdLibRegister() won't work. Here is an example to retrieve the Text in the Edit Box, but it will only return the name, not the full path.

Main Script.au3

$hPID = Run('"' & @AutoItExe & '" "' & @ScriptDir & '\helper.au3"')
$Bkupto = FileSelectFolder("Choose a folder.", '', 7)
If @error = 1 Then
    ProcessClose($hPID)
Else
    ProcessClose($hPID)
    MsgBox(32, 'Finished', $Bkupto)
EndIf
Helper.au3

_Splash(' ')
While 1
    Show()
    Sleep(10)
WEnd

Func Show()
    Local $sText, $eText
    If Not WinExists("Browse For Folder", "") Then Exit
    $eText = ControlGetText("Browse For Folder", "", "Edit1")
    $sText = ControlGetText('[CLASS:AutoIt v3]', '', 'Static1')
    If $sText <> $eText Then ControlSetText('[CLASS:AutoIt v3]', '', 'Static1', $eText)
EndFunc   ;==>Show

Func _Splash($Text) ;Shows a small borderless splash message.
    SplashTextOn('', $Text, @DesktopWidth, 25, -1, 5, 33, '', 14)
EndFunc   ;==>_Splash
Place both files in the same directory and run the Main Script Edited by Varian

Share this post


Link to post
Share on other sites

I think you would have to have a second scipt monitor for the "Browse Folder" window since the script pauses with the FileSelectFolder() function. Even AdLibRegister() won't work. Here is an example to retrieve the Text in the Edit Box, but it will only return the name, not the full path.

Main Script.su3

$hPID = Run('"' & @AutoItExe & '" "' & @ScriptDir & '\helper.au3"')
$bkupto = FileSelectFolder("Choose a folder.", '', 7)
If @error = 1 Then
    ProcessClose($hPID)
    Else
        ProcessClose($hPID)
        MsgBox(32, 'Finished', $bkupto)
EndIf
Helper.au3
_Splash(' ')
While 1
    Show()
    Sleep(10)
WEndPlace both files in the same directory and run the Main Script

Func Show()
    If WinExists("Browse For Folder", "") Then
        $Text = ControlGetText("Browse For Folder", "", "Edit1")
        ControlSetText('[CLASS:AutoIt v3]', '', 'Static1', $Text)
    EndIf
EndFunc

Func _Splash($Text) ;Shows a small borderless splash message.
    SplashTextOn('', $Text, @DesktopWidth, 25, -1, 5, 33, '', 14)
EndFunc   ;==>_Splash

Thanks Varian,

I have it already working in a secondary script to monitor the first script as i was testing functionality, I just really wanted to see if it could all be self contained in single script, possibly something i have overlooked.

Thanks anyway Varian, Have a great Xmas and new year :x

FTC

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