I'm not getting what you're debating, I answered for IS IT WORKING?, now you're saying it's practical solid approach, and there is no problem with at all, you don't see a problem with what you're doing?
if you were a user would like a programmer to ask you:
Please put bla somewhere to put a file's path in its place when you select one, even though it should just be where ever the caret is, and one more thing please make sure the bla isn't in the text more than once, unless you want me to put the file's path in the first bla, OK?
but it seems like a pretty positive way to ensure the file name will go exactly where you want it.
define positive way, is it working way? it is working
If they want to avoid typing any extra characters, it can easily be changed to append to the end of the text that was typed when they pressed the button for selecting the file. Then they can continue typing after that.
how would go and do that?
- get the text in the edit control, by
Gui, Submit,
GuiControlGet,
ControlGetText or
Control+C
- append file path to the text from the edit control...
- put the text back to edit control, by
GuiControl,
Control or Control+V
that would work too.
Capbat's idea would work too, and good idea too, had he known the right commands and used them, his approach works too, just without the user interference, like this:
Code: Select all
#Singleinstance Force
Gui,Add, Edit, x10 y10 w630 h250 vEditNewProcedure
Gui,Add, Button, x10 y270 vSaveProcedureBtn , Save
Gui,Add, Button, x55 y270 vGetFileBtn gGetfileBtn , Get File
Gui,Show ,w650 h300, Edit Procedure
Return
GetFileBtn:
Gui, Submit, NoHide
FileSelectFile, SelectedDocumentationFile,1,,Select Documentation to be associated.,*.*
OldClip:=ClipboardAll ; save the content of the clipboard for the user, since he's not expecting his clipboard to change by selecting a file
Clipboard:="" ; empty the clipboard to get the error if it doesn't get written to
Clipboard:=SelectedDocumentationFile ; put file's path in the clipboard
ClipWait, 3 ; 3 sec waiting for the clip to have somthing
if ErrorLevel {
MsgBox, can't copy file path, well you should have used a better way, there must be better way
Clipboard:=OldClip ; let's hope we didn't ruin anything, there is no ClipWaiting since we don't want to inform the user that we screw his clipboard content
return
}
GuiControl, Focus, EditNewProcedure ; set focus to the edit control
Send, ^V ; send the edit control a Ctrl+V, to paste the file path, wherever the heck that caret is
Clipboard:=OldClip ; clipboard back to just before we changed it (hoping nothing went wrong)
return