IvanCodin Posted June 7, 2009 Posted June 7, 2009 (edited) I am trying to use text in the clipboard and append it to the end of a GUI txt box. As an example the text box contains "This is the text box" and the clipboard contains the text "This is the clipboard". When I click $Button01 the GUI text box will be updated. The clipboard will be appended to the GUI window. I have all of this working but I canot figure out how to write the text backinto the GUI. Any suggestions would be appreciated. Here is a test script I wrote that shows what I am trying to do: CODE#include <IE.au3> #include <GUIConstantsEX.au3> #include <Misc.au3> #include <Process.au3> Opt('GUIOnEventMode',True) HotKeySet("^x", "_Bye") $my_version = "0.91.1" Global $Width = ('499') Global $Height = ('447') $cCommand1 = "" ; => Main Form $hGUI1 = GUICreate("Tools", $Width, $Height, 270, 98) GUISetOnEvent($GUI_EVENT_CLOSE, '_Exit', $hGUI1) ; =>Context Menu MainFrom $Context_Menu = GUICtrlCreateContextMenu() $Item_1 = GUICtrlCreateMenuItem("About", $Context_Menu) GUICtrlSetOnEvent($Item_1, "_About") $Item_2 = GUICtrlCreateMenuItem("Exit", $Context_Menu) GUICtrlSetOnEvent($Item_2, "_Exit") GUICtrlCreateLabel("<====== My Notes =====>", 115, 10) ; =>MainForm buttons $Button01 = GUICtrlCreateButton("Frm Clp", 392, 40, 89, 23, 0) GUICtrlSetOnEvent($Button01, "FrmClip1") $cCommand1 = GUICtrlCreateEdit("", 20, 40, 365, 397) $Button0 = GUICtrlCreateButton("CP My Notes", 392, 75, 89, 23, 0) GUICtrlSetOnEvent($Button0,"MyClip1") GUISetState(@SW_SHOW, $hGUI1) While 1 $msg = GUIGetMsg() If $msg = $Item_2 Or $msg = -3 Or $msg = -1 Then ExitLoop EndIf Sleep(20) ; Idle around WEnd Func MyClip1() ClipPut("") ; clear to prevent duplicate entries ClipPut(GUICtrlRead($cCommand1) & @CRLF) If (@error == 1) Then MsgBox(0, "", "Unable to copy to the ClipBoard.") EndIf ;EndSelect Sleep(2000) EndFunc ; => Myclip1 Func FrmClip1() $bak = ClipGet() $bak1 = GUICtrlRead($Ccommand1) MsgBox(0, "notes contains:", $bak1, 3) MsgBox(0, "Clipboard contains:", $bak, 3) ClipPut($bak1 & @CRLF & $bak) MsgBox(0, "Clipboard contains:", ClipGet()) ;GUICtrlCreateEdit ($Ccommand1 = $bak & @CRLF & $bak1) ; The text existing in the $Ccommand1 will be appended with the clipboard text and displayed GUI window. EndFunc ;=> FrmClip1 Func _About() MsgBox(0, "About", "Text Tool Box " & $my_version, 4) EndFunc ;==>_About Func _Bye() ;SoundPlay(@WindowsDir & "\media\tada.wav",1) MsgBox(0, "Bye", "Exiting program", 4) _Exit() EndFunc ;==>_Bye Func _Exit() GUIDelete($hGUI1) Exit EndFunc ;==>_Exit Edited June 7, 2009 by IvanCodin
E1M1 Posted June 7, 2009 Posted June 7, 2009 (edited) wow, I got nice visual pattern This is your code expandcollapse popup#include <IE.au3> #include <GUIConstantsEX.au3> #include <Misc.au3> #include <Process.au3> #Include <GuiEdit.au3> Opt('GUIOnEventMode',True) HotKeySet("^x", "_Bye") $my_version = "0.91.1" Global $Width = ('499') Global $Height = ('447') $cCommand1 = "" ; => Main Form $hGUI1 = GUICreate("Tools", $Width, $Height, 270, 98) GUISetOnEvent($GUI_EVENT_CLOSE, '_Exit', $hGUI1) ; =>Context Menu MainFrom $Context_Menu = GUICtrlCreateContextMenu() $Item_1 = GUICtrlCreateMenuItem("About", $Context_Menu) GUICtrlSetOnEvent($Item_1, "_About") $Item_2 = GUICtrlCreateMenuItem("Exit", $Context_Menu) GUICtrlSetOnEvent($Item_2, "_Exit") GUICtrlCreateLabel("<====== My Notes =====>", 115, 10) ; =>MainForm buttons $Button01 = GUICtrlCreateButton("Frm Clp", 392, 40, 89, 23, 0) GUICtrlSetOnEvent($Button01, "FrmClip1") $cCommand1 = GUICtrlCreateEdit("", 20, 40, 365, 397) $Button0 = GUICtrlCreateButton("CP My Notes", 392, 75, 89, 23, 0) GUICtrlSetOnEvent($Button0,"MyClip1") GUISetState(@SW_SHOW, $hGUI1) While 1 $msg = GUIGetMsg() If $msg = $Item_2 Or $msg = -3 Or $msg = -1 Then ExitLoop EndIf Sleep(20) ; Idle around WEnd Func MyClip1() ClipPut("") ; clear to prevent duplicate entries ClipPut(GUICtrlRead($cCommand1) & @CRLF) If (@error == 1) Then MsgBox(0, "", "Unable to copy to the ClipBoard.") EndIf ;EndSelect Sleep(2000) EndFunc ; => Myclip1 Func FrmClip1() $bak = ClipGet() _GUICtrlEdit_AppendText($cCommand1, $bak) $bak1 = GUICtrlRead($Ccommand1) MsgBox(0, "notes contains:", $bak1, 3) MsgBox(0, "Clipboard contains:", $bak, 3) ClipPut($bak1 & @CRLF & $bak) MsgBox(0, "Clipboard contains:", ClipGet()) ;GUICtrlCreateEdit ($Ccommand1 = $bak & @CRLF & $bak1) ; The text existing in the $Ccommand1 will be appended with the clipboard text and displayed GUI window. EndFunc ;=> FrmClip1 Func _About() MsgBox(0, "About", "Text Tool Box " & $my_version, 4) EndFunc ;==>_About Func _Bye() ;SoundPlay(@WindowsDir & "\media\tada.wav",1) MsgBox(0, "Bye", "Exiting program", 4) _Exit() EndFunc ;==>_Bye Func _Exit() GUIDelete($hGUI1) Exit EndFunc ;==>_Exit Edited June 7, 2009 by E1M1 edited
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