Oldwilly Posted March 15, 2008 Share Posted March 15, 2008 Hi there. I've been looking for answers and digging the documentation but I might be real dumb because I can't get what I need to work correctly... So I guess I need some help. Goal : very simple, having a "Select folder" window opening on request with a hotkey and having it on top of other windows... My script : note > "Rechercher un dossier" is the Title of this kind of window on WinXP french. (I just copy/pasted what Au3Info gave me anyway) HotKeySet("{F6}", "selectdialog") Func selectdialog() $var = FileSelectFolder("Select a folder.", "D:\",1) If @error = 1 Then Exit WinSetOnTop("Rechercher un dossier", "", 1) MsgBox(4096,"Result","Folder selected : "&$var) EndFunc Don't answer with "it can't be on top of a 3rd-party app if it has its own "on-top" attribute" .. I'm not that noob, it doesn't work even with an explorer window... a browser window...or any other.. Are those select folder windows different from common windows? Isn't it possible to put them ontop? How to do that? Help much appreciated because I wasted too many hours on this already. Thanks. Link to comment Share on other sites More sharing options...
MHz Posted March 15, 2008 Share Posted March 15, 2008 I am not sure of "Rechercher un dossier" as a title (i am english) but a loop would help for a start to keep the script alive. HotKeySet("{F6}", "selectdialog") While 1 Sleep(1000) WEnd Func selectdialog() $var = FileSelectFolder("Select a folder.", "D:\",1) If @error = 1 Then Exit WinSetOnTop("Rechercher un dossier", "", 1) MsgBox(4096,"Result","Folder selected : "&$var) EndFunc Link to comment Share on other sites More sharing options...
Oldwilly Posted March 15, 2008 Author Share Posted March 15, 2008 well I just forgot to copy/paste your loop here but of course I've put one.. it doesn't work Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 15, 2008 Moderators Share Posted March 15, 2008 (edited) You can't set it on top that way because it pauses the script until you get a response. The way you have it written, you would expect to get the messagebox below before you did anything int he dialog: [/autoit] Edit: Added #NoTrayIcon Edited July 21, 2009 by Jon Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 15, 2008 Moderators Share Posted March 15, 2008 (edited) Since it won't let me edit my post without garbling it up again (2 AutoIt code blocks will do that )... I couldn't get my folder browser to say anything but what I hard coded there... I thought that $sDialogText would change the title of the dialog ... but it didn't for me. Edit2: I think I totally mis-read what you wanted to do! Edited March 15, 2008 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 15, 2008 Share Posted March 15, 2008 (edited) Your basic problem is that FileSelectFolder() is a blocking function. The script is paused, so it can't modify it's own dialog (same problem with MsgBox, for example). The work around is to kick off a separate process to do either the function or the modification. This demo launches the file selection as a separate process, and handles the WinSetOnTop() with it's own loop. In order for the processes to communicate the selection, a hidden GUI is created with an input control to catch the path: HotKeySet("{ESC}", "_Quit") HotKeySet("{F6}", "selectdialog") Global $sInput = "<None>" While 1 Sleep(20) WEnd Func selectdialog() ; Create GUI to receive input Local $hGUI = GUICreate("Hidden Input GUI", 300, 100) Local $ctrlInput = GUICtrlCreateInput("", 10, 10, 280, 30) GUISetState(@SW_HIDE) ShellExecute(@AutoItExe, ' /AutoIt3ExecuteLine ' & _ '"ControlSetText(''Hidden Input GUI'', '''', Number(' & $ctrlInput & '), FileSelectFolder(''Select a folder.'', '''', 1))"') WinWait('Browse For Folder', 'Select a folder.', 5) While 1 If WinExists('Browse For Folder', 'Select a folder.') Then WinSetOnTop('Browse For Folder', 'Select a folder.', 1) Else $sInput = ControlGetText("Hidden Input GUI", "", $ctrlInput) GUIDelete($hGUI) ExitLoop EndIf Sleep(250) WEnd MsgBox(64, "Input", "$sInput = " & $sInput) EndFunc ;==>selectdialog Func _Quit() Exit EndFunc ;==>_Quit This works either from SciTE or compiled. Interestingly, it also works by running @ScriptFullPath in place of @AutoItExe in SciTE, but not if compiled that way... Hmm... Edit: Ouch! Totaly upstaged by SmOke_N with the same idea! Edited March 15, 2008 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Oldwilly Posted March 15, 2008 Author Share Posted March 15, 2008 I love you guys.. well it's almost 6 am and I'm in zombie mode already but you understood what i was trying to do 100%. I'll take a deeper look at this tomorrow since I can't do anything with half a neuron working but I just tried your scripts and that's perfect. Thank you very much ! <3 AutoIt community I always had nice people to help here the few times I came. off to Morpheus arms! Link to comment Share on other sites More sharing options...
rasim Posted March 15, 2008 Share Posted March 15, 2008 Mayb this: Global $handle, $SetTimer Dim $Folder $handle = DllCallbackRegister("_WinOnTop", "int", "") $SetTimer = DllCall("User32.dll", "int", "SetTimer", "hwnd", 0, "int", 0, "int", 100, "ptr", DllCallbackGetPtr($handle)) $SetTimer = $SetTimer[0] $Folder = FileSelectFolder("Choose your folder", "") If Not @error Then MsgBox(0, "Folder Name", $Folder) Func _WinOnTop() If WinExists("Browse For Folder") Then WinSetOnTop("Browse For Folder", "", 1) DllCallbackFree($handle) DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "int", $SetTimer) EndIf EndFunc Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 15, 2008 Moderators Share Posted March 15, 2008 Mayb this: Global $handle, $SetTimer Dim $Folder $handle = DllCallbackRegister("_WinOnTop", "int", "") $SetTimer = DllCall("User32.dll", "int", "SetTimer", "hwnd", 0, "int", 0, "int", 100, "ptr", DllCallbackGetPtr($handle)) $SetTimer = $SetTimer[0] $Folder = FileSelectFolder("Choose your folder", "") If Not @error Then MsgBox(0, "Folder Name", $Folder) Func _WinOnTop() If WinExists("Browse For Folder") Then WinSetOnTop("Browse For Folder", "", 1) DllCallbackFree($handle) DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "int", $SetTimer) EndIf EndFunc I looked at this and said Unique!... but it doesn't work Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
The Kandie Man Posted March 15, 2008 Share Posted March 15, 2008 (edited) I looked at this and said Unique!... but it doesn't work I figured out what was wrong. The window title is "Browse for Folder" not "Browse For Folder". This works:Global $handle, $SetTimer Dim $Folder $handle = DllCallbackRegister("_WinOnTop", "int", "") $SetTimer = DllCall("User32.dll", "int", "SetTimer", "hwnd", 0, "int", 0, "int", 100, "ptr", DllCallbackGetPtr($handle)) $SetTimer = $SetTimer[0] $Folder = FileSelectFolder("Choose your folder", "") If Not @error Then MsgBox(0, "Folder Name", $Folder) Func _WinOnTop() If WinExists("Browse for Folder") Then ConsoleWrite("CalledBack"&@LF) WinSetOnTop("Browse for Folder", "", 1) DllCallbackFree($handle) DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "int", $SetTimer) EndIf EndFunc - The Kandie Man ;-) Edit Fixed changed param for testing. Edited March 15, 2008 by The Kandie Man "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 15, 2008 Moderators Share Posted March 15, 2008 I figured out what was wrong. The window title is "Browse for Folder" not "Browse For Folder". This works:Global $handle, $SetTimer Dim $Folder $handle = DllCallbackRegister("_WinOnTop", "int", "") $SetTimer = DllCall("User32.dll", "int", "SetTimer", "hwnd", 0, "int", 0, "int", 100, "ptr", DllCallbackGetPtr($handle)) $SetTimer = $SetTimer[0] $Folder = FileSelectFolder("Choose your folder", "") If Not @error Then MsgBox(0, "Folder Name", $Folder) Func _WinOnTop() If WinExists("Browse for Folder") Then ConsoleWrite("CalledBack"&@LF) WinSetOnTop("Browse for Folder", "", 1) DllCallbackFree($handle) DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "int", $SetTimer) EndIf EndFunc - The Kandie Man ;-) Edit Fixed changed param for testing.Nice catch... Nice work rasim ... I like it a lot. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
rover Posted March 15, 2008 Share Posted March 15, 2008 beta 3.2.11.2 New dialog style (option 2) = Browse For Folder Old dialog style (default) = Browse for Folder I see fascists... Link to comment Share on other sites More sharing options...
The Kandie Man Posted March 15, 2008 Share Posted March 15, 2008 beta 3.2.11.2New dialog style (option 2) = Browse For FolderOld dialog style (default) = Browse for FolderThanks, I just noticed the new WinTitleMatchMode Options.Place Opt("WinTitleMatchMode",-1) at the top of the script to make the title match non case sensitive.- The Kandie Man ;-) "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire Link to comment Share on other sites More sharing options...
Oldwilly Posted March 15, 2008 Author Share Posted March 15, 2008 (edited) I looked at your solution rasim and all I gotta say is.. wow. My level isn't high enough to code that under 15-20 hours but at least I could understand it and it does the trick as well as I wanted ! I didn't have that little case issue since I just copy/pasted the window title with Au3Info and it's.. in french anyway hehe. Ty again! Edited March 15, 2008 by Oldwilly Link to comment Share on other sites More sharing options...
MrCreatoR Posted July 20, 2009 Share Posted July 20, 2009 I konw it's an old thread, but here is a method that works better and faster (set WinWaitDelay option to 0, and instead of title search used text search): Global $hCallback, $iSetTimer, $sFSF_Title $sFolder = _FileSelectFolderEx("Choose your folder", "", 0, "", 0, 1) If Not @error Then MsgBox(0, "Folder Name", $sFolder) Func _FileSelectFolderEx($sTitle, $sRootDir, $iFlag=0, $sInitDir="", $hWnd=0, $iOnTop=0) If Not $iOnTop Then Return FileSelectFolder($sTitle, $sRootDir, $iFlag, $sInitDir, $hWnd) Local $sOld_Opt_WWD = Opt("WinWaitDelay", 0) $hCallback = DllCallbackRegister("__FSF_Callback_Proc", "int", "") $iSetTimer = DllCall("User32.dll", "int", "SetTimer", "hwnd", 0, "int", 0, "int", 100, "ptr", DllCallbackGetPtr($hCallback)) $iSetTimer = $iSetTimer[0] $sFSF_Title = $sTitle Local $sRet = FileSelectFolder($sTitle, $sRootDir, $iFlag, $sInitDir, $hWnd) Local $iError = @error Opt("WinWaitDelay", $sOld_Opt_WWD) Return SetError($iError, 0, $sRet) EndFunc Func __FSF_Callback_Proc() If Not WinExists("", $sFSF_Title) Then Return WinSetOnTop("", $sFSF_Title, 1) DllCallbackFree($hCallback) DllCall("User32.dll", "int", "KillTimer", "hwnd", 0, "int", $iSetTimer) Dim $hCallback = 0, $iSetTimer = 0, $sFSF_Title = "" EndFunc Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
MrCreatoR Posted July 20, 2009 Share Posted July 20, 2009 Or this simple method: $sFolder = _FileSelectFolderEx("Choose your folder", "") If Not @error Then MsgBox(0, "Folder Name", $sFolder) Func _FileSelectFolderEx($sTitle, $sRootDir, $iFlag=0, $sInitDir="") Local $h_Parent = GUICreate("", 200, 200, 0, 0) WinSetOnTop($h_Parent, "", 1) Return FileSelectFolder($sTitle, $sRootDir, $iFlag, $sInitDir, $h_Parent) EndFunc Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now