LithiumLi Posted February 8, 2009 Share Posted February 8, 2009 (edited) I can get the path of the file but I want to read the information of the file using GUICtrlSetData($Edit1 , FileRead(Dropped File.txt)) #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 400, 400, Default, Default , Default , $WS_EX_ACCEPTFILES) $Edit1 = GUICtrlCreateEdit("", 0, 0, 400, 400 , $ES_READONLY) GUICtrlSetState($Edit1 , $GUI_DROPACCEPTED) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Also I got another question that is somewhat related, if I make my own file type and make a editor executable out of Autoit and change the properties of the new file type to open with my Autoit Executable how can I output the info on the script. Drag and drop file on to Autoit Executable and it takes the information from the file and displays it on the Autoit Edit box. Edited February 8, 2009 by LithiumLi Link to comment Share on other sites More sharing options...
martin Posted February 8, 2009 Share Posted February 8, 2009 I can get the path of the file but I want to read the information of the file using GUICtrlSetData($Edit1 , FileRead(Dropped File.txt)) #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 400, 400, Default, Default , Default , $WS_EX_ACCEPTFILES) $Edit1 = GUICtrlCreateEdit("", 0, 0, 400, 400 , $ES_READONLY) GUICtrlSetState($Edit1 , $GUI_DROPACCEPTED) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Also I got another question that is somewhat related, if I make my own file type and make a editor executable out of Autoit and change the properties of the new file type to open with my Autoit Executable how can I output the info on the script. Drag and drop file on to Autoit Executable and it takes the information from the file and displays it on the Autoit Edit box. Try this #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 400, 400, Default, Default, Default, $WS_EX_ACCEPTFILES) $Edit1 = GUICtrlCreateEdit("", 0, 0, 400, 400, $ES_READONLY) GUICtrlSetState($Edit1, $GUI_DROPACCEPTED) GUISetState(@SW_SHOW) $setdata = '' $text = '' While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_DROPPED $setdata = @GUI_DragFile ;unfortunately @GUI_DragFile has @CRLF at end which ;will stop it working as a file name $setdata = stringreplace($setdata,@CR,"") $setdata = stringreplace($setdata,@LF,"") $Text = FileRead($setdata) ;ConsoleWrite($setdata & @CRLF) guictrlsetdata($Edit1, $text) EndSwitch WEnd I don't understand your second question. Output the file to what? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
LithiumLi Posted February 8, 2009 Author Share Posted February 8, 2009 (edited) Try this #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 400, 400, Default, Default, Default, $WS_EX_ACCEPTFILES) $Edit1 = GUICtrlCreateEdit("", 0, 0, 400, 400, $ES_READONLY) GUICtrlSetState($Edit1, $GUI_DROPACCEPTED) GUISetState(@SW_SHOW) $setdata = '' $text = '' While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_DROPPED $setdata = @GUI_DragFile ;unfortunately @GUI_DragFile has @CRLF at end which ;will stop it working as a file name $setdata = stringreplace($setdata,@CR,"") $setdata = stringreplace($setdata,@LF,"") $Text = FileRead($setdata) ;ConsoleWrite($setdata & @CRLF) guictrlsetdata($Edit1, $text) EndSwitch WEnd I don't understand your second question. Output the file to what? Thanks just what I wanted. My second question was...well it's hard to explain so lets use some examples. Notepad that comes with Windows can recognize *.txt files right and when you open up a *.txt file it knows that it should open it up with Notepad thats what i would like to do. Edited February 8, 2009 by LithiumLi Link to comment Share on other sites More sharing options...
Robjong Posted February 8, 2009 Share Posted February 8, 2009 Hey,Check out this page Q16http://www.autoitscript.com/forum/index.ph...showtopic=37289 Link to comment Share on other sites More sharing options...
LithiumLi Posted February 8, 2009 Author Share Posted February 8, 2009 wow thanks for the quick reply to the both of you. Link to comment Share on other sites More sharing options...
LithiumLi Posted February 9, 2009 Author Share Posted February 9, 2009 I am having a few more problems, I went to go tweak my code and wanted to disallow all file types except for one and it works but for some strange reason it wants to send the file path into the edit control? $Buffer = GUICtrlRead($Text) $SetData = @GUI_DragFile $SetData = StringReplace($SetData,@CR,"") $SetData = StringReplace($SetData,@LF,"") If StringTrimLeft($SetData , StringLen($SetData) -4) = ".ZZZ" Then GUICtrlSetData($Text , FileRead($SetData)) ;GUICtrlSetData($Text , $Buffer) Else If IniRead($Path , $Section , "Always on Top" , 0) = 1 Then WinSetOnTop($ZZZ , "" , 0) MsgBox(16 , "Error" , "This isn't a ZZZ File!") WinSetOnTop($ZZZ , "" , 1) Else MsgBox(16 , "Error" , "This isn't a ZZZ File!") EndIf EndIf Link to comment Share on other sites More sharing options...
martin Posted February 9, 2009 Share Posted February 9, 2009 I am having a few more problems, I went to go tweak my code and wanted to disallow all file types except for one and it works but for some strange reason it wants to send the file path into the edit control? $Buffer = GUICtrlRead($Text) $SetData = @GUI_DragFile $SetData = StringReplace($SetData,@CR,"") $SetData = StringReplace($SetData,@LF,"") If StringTrimLeft($SetData , StringLen($SetData) -4) = ".ZZZ" Then GUICtrlSetData($Text , FileRead($SetData)) ;GUICtrlSetData($Text , $Buffer) Else If IniRead($Path , $Section , "Always on Top" , 0) = 1 Then WinSetOnTop($ZZZ , "" , 0) MsgBox(16 , "Error" , "This isn't a ZZZ File!") WinSetOnTop($ZZZ , "" , 1) Else MsgBox(16 , "Error" , "This isn't a ZZZ File!") EndIf EndIfIf you mean that it writes the file path when you use the line which you have commented out then I could understand it. If the edit starts off as empty, then it will contain the file path when you drop a file into it, so $buffer will be that file path which you write back to the edit. Otherwise I don't understand it from what you've posted. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
LithiumLi Posted February 9, 2009 Author Share Posted February 9, 2009 If you mean that it writes the file path when you use the line which you have commented out then I could understand it. If the edit starts off as empty, then it will contain the file path when you drop a file into it, so $buffer will be that file path which you write back to the edit. Otherwise I don't understand it from what you've posted. I made a example, when you drop a *.zzz file it will output the data on to the edit box but when you drop a file that isn't a *.zzz it will give you the message box but for some strange reason it will still return the file path in the edit box #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Test = GUICreate("Form1", 250, 250, Default, Default , Default , $WS_EX_ACCEPTFiles) $Text = GUICtrlCreateEdit("", 0, 0, 250, 250) GUICtrlSetState($Text, $GUI_DROPACCEPTED) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_DROPPED $Buffer = GUICtrlRead($Text) $SetData = @GUI_DragFile $SetData = StringReplace($SetData,@CR,"") $SetData = StringReplace($SetData,@LF,"") If StringTrimLeft($SetData , StringLen($SetData) -4) = ".ZZZ" Then GUICtrlSetData($Text , FileRead($SetData)) ;GUICtrlSetData($Text , $Buffer) Else MsgBox(16 , "Error" , "This isn't a ZZZ File!") EndIf EndSwitch WEnd Link to comment Share on other sites More sharing options...
martin Posted February 9, 2009 Share Posted February 9, 2009 I made a example, when you drop a *.zzz file it will output the data on to the edit box but when you drop a file that isn't a *.zzz it will give you the message box but for some strange reason it will still return the file path in the edit box #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Test = GUICreate("Form1", 250, 250, Default, Default , Default , $WS_EX_ACCEPTFiles) $Text = GUICtrlCreateEdit("", 0, 0, 250, 250) GUICtrlSetState($Text, $GUI_DROPACCEPTED) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_DROPPED $Buffer = GUICtrlRead($Text) $SetData = @GUI_DragFile $SetData = StringReplace($SetData,@CR,"") $SetData = StringReplace($SetData,@LF,"") If StringTrimLeft($SetData , StringLen($SetData) -4) = ".ZZZ" Then GUICtrlSetData($Text , FileRead($SetData)) ;GUICtrlSetData($Text , $Buffer) Else MsgBox(16 , "Error" , "This isn't a ZZZ File!") EndIf EndSwitch WEnd Yes, but when you drop a file into the edit the file path is written to the edit. Since you don't write anything else to the edit if it's the wrong file type you are left with that file path being written to the edit. All you have to do is something like this. Else MsgBox(16, "Error", "This isn't a ZZZ File!") GUICtrlSetData($Text, StringReplace($Buffer, @GUI_DragFile, "") EndIf Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
LithiumLi Posted February 9, 2009 Author Share Posted February 9, 2009 Yes, but when you drop a file into the edit the file path is written to the edit. Since you don't write anything else to the edit if it's the wrong file type you are left with that file path being written to the edit. All you have to do is something like this. Else MsgBox(16, "Error", "This isn't a ZZZ File!") GUICtrlSetData($Text, StringReplace($Buffer, @GUI_DragFile, "") EndIf Wonderful! did not think of doing it that way 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