ChrisJakarta Posted August 24, 2008 Posted August 24, 2008 (edited) Is there any way to link an edit control to an external editor (I use TextPad), similar to the "It's All Text!" extension in FireFox? The intent is to be able to click a button on the GUI which would transfer the text to the external editor, where it could be edited with all the additional functionality of the editor, then when complete, saved in the external editor, returning the edited text back to the edit control. Chris Edited August 25, 2008 by ChrisJakarta
dbzfanatic Posted August 24, 2008 Posted August 24, 2008 Try using Run() to call your editor, store the text to a variable, write the variable to your editor and put something like While 1 If Not WinExists("TextPad") Then $file = FileOpen("filename") ;filename you saved it to GuiCtrlSetData($idofedit,FileRead($file)) EndIf WEnd Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote]
ChrisJakarta Posted August 25, 2008 Author Posted August 25, 2008 (edited) dbzfanatic, Thanks for the idea. From this seed, I offer the following solution, based upon the Editbox example: expandcollapse popup; External Editor ; ; Author: Chris Green ; ; Based on EditBox example by: ; Author: "SlimShady" ; ;Include constants, etc #include <GUIConstantsEx.au3> #include <Constants.au3> #include <File.au3> #include <ButtonConstants.au3> Opt('MustDeclareVars', 1) _Main() Func ExtEdit($edit_id) Local $file, $text, $tfname, $tfpath, $szDrive, $szDir, $szFName, $szExt, $title Dim $tfar[5] $text = GuiCtrlRead($edit_id) $tfpath = _TempFile("","",".txt") $tfar = _PathSplit($tfpath,$szDrive, $szDir, $szFName, $szExt) $tfname = $tfar[3] & $tfar[4] $file = FileOpen($tfpath,2) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWrite($file,$text) FileClose($file) ShellExecute($tfpath) Sleep(1000) $title = WinGetTitle("[active]") WinWaitClose($title) $file = FileOpen($tfpath,0) $text = FileRead($file) GUICtrlSetBkColor($edit_id, $COLOR_YELLOW) WinActivate("New GUI") GuiCtrlSetData($edit_id,$text) Sleep(1000) GUICtrlSetBkColor($edit_id, $CLR_NONE) FileClose($file) FileDelete($tfpath) EndFunc ;==>ExtEdit Func _Main() ;Initialize variables Local $GUIWidth = 300, $GUIHeight = 250 Local $Edit_1, $OK_Btn, $Cancel_Btn, $Edit_Btn, $msg #forceref $Edit_1 ;Create window GUICreate("New GUI", $GUIWidth, $GUIHeight) ;Create an edit box with no text in it $Edit_1 = GUICtrlCreateEdit("", 10, 10, 280, 190) ;Create an "OK" button $OK_Btn = GUICtrlCreateButton("OK", 40, 210, 70, 25) ;Create a "CANCEL" button $Cancel_Btn = GUICtrlCreateButton("Cancel", 200, 210, 70, 25) ;Create a "EDIT" button $Edit_Btn = GUICtrlCreateButton("Edit", 120, 210, 70, 25) ;Show window/Make the window visible GUISetState(@SW_SHOW) ;Loop until: ;- user presses Esc ;- user presses Alt+F4 ;- user clicks the close button ;- user clicks the Cancel button While 1 ;After every loop check if the user clicked something in the GUI window $msg = GUIGetMsg() Select ;Check if user clicked on the close button Case $msg = $GUI_EVENT_CLOSE ;Destroy the GUI including the controls GUIDelete() ;Exit the script Exit ;Check if user clicked on the "OK" button Case $msg = $OK_Btn MsgBox(64, "New GUI", GuiCtrlRead($Edit_1)) ;Check if user clicked on the "CANCEL" button Case $msg = $Cancel_Btn Exit Case $msg = $Edit_Btn ExtEdit($Edit_1) EndSelect WEnd EndFunc ;==>_Main Hopefully this might be useful to others. It should be generic for any text editor that is associated with the '.txt' extension. Chris Edited August 25, 2008 by ChrisJakarta
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