Ventura Posted July 23, 2015 Share Posted July 23, 2015 (edited) I have created a simple gui tool to open files for me and create shortcut in script dir, but actually ShellExecute doesn't work when I select the text file and open it from gui.. and the shortcut file is there.. but it works when I close the gui and open it again.. so what am I doing wrong? code here...#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form = GUICreate("Open", 154, 76, 399, 245) $Button = GUICtrlCreateButton("Open file", 32, 24, 89, 33) GUISetState(@SW_SHOW) If FileExists("text.lnk") = True Then GUICtrlSetData($Button, "Open text") Else GUICtrlSetData($Button, "Open file") EndIf While 1 Switch GUIGetMsg() Case $gui_event_close Exit Case $Button Switch GUICtrlRead($Button) Case "Open file" $Dialog = FileOpenDialog("Select text", "\", "(*.txt)", "", "") If Not @error Then FileCreateShortcut($Dialog, @ScriptDir & "\text.lnk") EndIf GUICtrlSetData($Button, "Open text") Case "Open text" ShellExecute("text.lnk") EndSwitch EndSwitch WEnd Edited July 23, 2015 by Ventura Link to comment Share on other sites More sharing options...
J2TeaM Posted July 23, 2015 Share Posted July 23, 2015 Edit your code like this and try again:$Dialog = FileOpenDialog("Select text", @ScriptDir, "Text files (*.txt)", 1) My UDF/Example Scripts: Imgur UDF | AutoIt & PHP/MySQL | Font Icon UDF | Awesome AutoIt My Blog: https://junookyo.blogspot.com/ Link to comment Share on other sites More sharing options...
lorenkinzel Posted July 23, 2015 Share Posted July 23, 2015 Worked fine for me as written IF the text file was in same dir as the script. Otherwise "Windows can't find text.lnk".What made it work was: Case "Open text" ShellExecute(@ScriptDir & "\text.lnk") Ventura 1 Link to comment Share on other sites More sharing options...
Ventura Posted July 23, 2015 Author Share Posted July 23, 2015 (edited) @J2team tested and it didn't work @lorenkinzel it works.. didn't think I was missing that part hehe Edited July 23, 2015 by Ventura 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