Ejoc Posted April 4, 2005 Share Posted April 4, 2005 So I got sick of making new files, and pasting code in the new window to test out someones code that they posted, so I threw this together real quick. I can copy someones code from the board and run it without putting it in a file. #cs vi:ts=4 sw=4: ExecuteClip.au3 - Ejoc Execute the autoit script in the clipboard, Makes it easy to tryout someones code that they posted. #ce #include <File.au3> $szTempFile = @TempDir & "\Clipboard.au3" $szClipBoard = ClipGet() if @error Then exit $fd = FileOpen($szTempFile,2) FileWrite($fd,$szClipBoard) FileClose($fd) Run(@AutoItExe & ' "' & $szTempFile & '"') Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs Link to comment Share on other sites More sharing options...
layer Posted April 4, 2005 Share Posted April 4, 2005 Pretty cool Very usefull too! FootbaG Link to comment Share on other sites More sharing options...
CyberSlug Posted April 5, 2005 Share Posted April 5, 2005 Not to nitpick, but it's always a good idea to error check FileOpen: #cs vi:ts=4 sw=4: ExecuteClip.au3 - Ejoc Execute the autoit script in the clipboard, Makes it easy to tryout someone's code that he/she posted. #ce #include <File.au3> $szTempFile = @TempDir & "\Clipboard.au3" $szClipBoard = ClipGet() if @error Then exit $fd = FileOpen($szTempFile,2) If $fd <> -1 Then FileWrite($fd,$szClipBoard) FileClose($fd) Run(@AutoItExe & ' "' & $szTempFile & '"') Else MsgBox(4096,"Error","Could not open temp file to run the script...") EndIf Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Ejoc Posted April 5, 2005 Author Share Posted April 5, 2005 (edited) True... Let me copy your version to my clipboard and use the script to see if it works *EditI'm no english major but I thought 'they' was oktryout someone's code that he/she posted.The 's did need to be corrected Edited April 5, 2005 by Ejoc Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs Link to comment Share on other sites More sharing options...
zcoacoaz Posted April 5, 2005 Share Posted April 5, 2005 this was already made a while ago but good job anyway i don't think you were around when the older one was made HotKeySet("^r","RunScript") HotKeySet("!r","SaveAndRunScript") While 1 Sleep ( 5000 ) WEnd Func RunScript() DoSaveAndRun(@tempdir & "\TempScript.au3") EndFunc Func SaveAndRunScript() $File=FileSaveDialog("Save AutoIt File", @MyDocumentsDir, "Scripts (*.au3)", 16, "*.au3") if @error=0 Then DoSaveAndRun($File) EndIf EndFunc Func DoSaveAndRun($FileName) $Script=ClipGet() $Handle=FileOpen($FileName, 2) FileWrite($Handle,$Script) FileClose($Handle) Run("AutoIt3" & ' "' & $FileName & '"') EndFunc I don't remember who made it though [font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font] Link to comment Share on other sites More sharing options...
GaryFrost Posted April 5, 2005 Share Posted April 5, 2005 a modified version of the one Xenogis posted with error checking and Icon Hide/Unhide and exit hotkeys expandcollapse popup#include <File.au3> Dim $TrayHide = 0 HotKeySet("^r","RunScript") HotKeySet("!r","SaveAndRunScript") HotKeySet("!e","ExitApp") HotKeySet("!h","HideMe") While 1 Sleep ( 5000 ) WEnd Func RunScript() DoSaveAndRun(StringReplace(_TempFile(),".tmp",".au3")) EndFunc Func SaveAndRunScript() $File=FileSaveDialog("Save AutoIt File", @MyDocumentsDir, "Scripts (*.au3)", 16, "*.au3") if @error=0 Then DoSaveAndRun($File) EndIf EndFunc Func DoSaveAndRun($FileName) $Script=ClipGet() $Handle=FileOpen($FileName, 2) If($Handle <> -1) Then FileWrite($Handle,$Script) FileClose($Handle) Run("AutoIt3" & ' "' & $FileName & '"') EndIf EndFunc Func ExitApp() Exit EndFunc Func HideMe() $TrayHide = Not $TrayHide Opt('TrayIconHide',$TrayHide) EndFunc SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
Ejoc Posted April 5, 2005 Author Share Posted April 5, 2005 (edited) Since I dont like apps running in the background I did a new version that has the above features(minus the hot keys) plus, an edit option. When you run it, you can just hit enter to run the script expandcollapse popup#cs vi:ts=4 sw=4: ExecuteClip.au3 - Ejoc Execute the autoit script in the clipboard, Makes it easy to tryout someone's code that they posted. #ce #include <File.au3> #include <GUIConstants.au3> #notrayicon $szTempFile = @TempDir & "\Clipboard.au3" $szClipBoard = ClipGet() if @error Then MsgBox(0,"Error","Clipboard empty or it is not text") exit EndIf $hGUI = GUICreate("Execute Clipboard",200,145) $hExecute = GuiCtrlCreateRadio("Execute Script in Clipboard",5,10,195) $hSave = GuiCtrlCreateRadio("Save Script in Clipboard",5,35,195) $hSaveExec = GuiCtrlCreateRadio("Save && Execute Script in Clipboard",5,60,195) $hEdit = GUICtrlCreateRadio("Save && Edit Script in Clipboard",5,85,195) $hOk = GUICtrlCreateButton("Ok",50,110,40,-1,$BS_DEFPUSHBUTTON) $hCancel = GUICtrlCreateButton("Cancel",110,110,40) GUICtrlSetState($hExecute,$GUI_CHECKED) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $hCancel GUIDelete($hGUI) Exit Case $msg = $hOk Select Case GUICtrlRead($hExecute) = $GUI_CHECKED GUIDelete($hGUI) SaveScript($szTempFile) ExecuteScript($szTempFile) Exit Case GUICtrlRead($hSave) = $GUI_CHECKED GUIDelete($hGUI) SaveDiag() SaveScript($szTempFile) Exit Case GUICtrlRead($hSaveExec) = $GUI_CHECKED GUIDelete($hGUI) SaveDiag() SaveScript($szTempFile) ExecuteScript($szTempFile) Exit Case GUICtrlRead($hEdit) = $GUI_CHECKED GUIDelete($hGUI) SaveDiag() SaveScript($szTempFile) EditScript($szTempFile) Exit EndSelect EndSelect Wend exit Func SaveDiag() $szTempFile = FileSaveDialog("Save AutoIt File", @MyDocumentsDir, "Scripts (*.au3)", 16, "*.au3") if @error Or $szTempFile = "" Then Exit EndFunc Func SaveScript($szFilename) Local $fd $fd = FileOpen($szFilename,2) if $fd <> -1 Then FileWrite($fd,$szClipBoard) FileClose($fd) Endif EndFunc Func ExecuteScript($szFilename) Run(@AutoItExe & ' "' & $szFilename & '"') EndFunc Func EditScript($szFilename) Local $szEditorExe = "" $szEditorExe = RegRead("HKLM\SOFTWARE\Classes\AutoiT3Script\Shell\Edit\Command","") if $szEditorExe <> "" Then Run(StringReplace($szEditorExe,"%1",$szFilename)) Endif EndFunc Edited April 6, 2005 by Ejoc Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs Link to comment Share on other sites More sharing options...
GaryFrost Posted April 6, 2005 Share Posted April 6, 2005 (edited) For those who want a choice of either running in the background or just run once Merged the other with yours Ejoc. expandcollapse popup#include <File.au3> #include <GUIConstants.au3> $GUIMode = 0 $TrayHide = 0 $szTempFile = @TempDir & "\Clipboard.au3" $szClipBoard = "" If($CMDLine[0] > 0 And StringInStr($CMDLine[1],"tray")) Then HotKeySet("^r","RunScript") HotKeySet("^s","Save") HotKeySet("!s","SaveRun") HotKeySet("!e","SaveEdit") HotKeySet("!h","HideTray") HotKeySet("!g","GUIMode") HotKeySet("!q","Quit") While 1 Sleep ( 5000 ) WEnd Else HideTray() $GUIMode = 1 GUIMode() EndIf Func GUIMode() $hGUI = GUICreate("Execute Clipboard",200,145) $hExecute = GuiCtrlCreateRadio("Execute Script in Clipboard",5,10,195) $hSave = GuiCtrlCreateRadio("Save Script in Clipboard",5,35,195) $hSaveExec = GuiCtrlCreateRadio("Save && Execute Script in Clipboard",5,60,195) $hEdit = GUICtrlCreateRadio("Save && Edit Script in Clipboard",5,85,195) $hOk = GUICtrlCreateButton("Ok",50,110,40,-1,$BS_DEFPUSHBUTTON) $hCancel = GUICtrlCreateButton("Cancel",110,110,40) GUICtrlSetState($hExecute,$GUI_CHECKED) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $hCancel GUIDelete($hGUI) If($GUIMode) Then Exit Else ExitLoop EndIf Case $msg = $hOk Select Case GUICtrlRead($hExecute) = $GUI_CHECKED GUIDelete($hGUI) RunScript() If($GUIMode) Then Exit Else ExitLoop EndIf Case GUICtrlRead($hSave) = $GUI_CHECKED GUIDelete($hGUI) Save() If($GUIMode) Then Exit Else ExitLoop EndIf Case GUICtrlRead($hSaveExec) = $GUI_CHECKED GUIDelete($hGUI) SaveRun() If($GUIMode) Then Exit Else ExitLoop EndIf Case GUICtrlRead($hEdit) = $GUI_CHECKED GUIDelete($hGUI) SaveEdit() If($GUIMode) Then Exit Else ExitLoop EndIf EndSelect EndSelect Wend EndFunc Func GetClip() $szClipBoard = ClipGet() if @error Then MsgBox(0,"Error","Clipboard empty or it is not text") exit EndIf EndFunc Func SaveDiag() $szTempFile = FileSaveDialog("Save AutoIt File", @MyDocumentsDir, "Scripts (*.au3)", 16, "*.au3") if @error Or $szTempFile = "" Then Exit EndFunc Func SaveScript($szFilename) Local $fd $fd = FileOpen($szFilename,2) if $fd <> -1 Then FileWrite($fd,$szClipBoard) FileClose($fd) Endif EndFunc Func ExecuteScript($szFilename) Run(@AutoItExe & ' "' & $szFilename & '"') EndFunc Func EditScript($szFilename) Local $szEditorExe = "" $szEditorExe = RegRead("HKLM\SOFTWARE\Classes\AutoiT3Script\Shell\Edit\Command","") if $szEditorExe <> "" Then Run(StringReplace($szEditorExe,"%1",$szFilename)) Endif EndFunc Func RunScript() GetClip() SaveScript($szTempFile) ExecuteScript($szTempFile) EndFunc Func Save() GetClip() SaveDiag() SaveScript($szTempFile) EndFunc Func SaveRun() Save() ExecuteScript($szTempFile) EndFunc Func SaveEdit() Save() EditScript($szTempFile) EndFunc Func HideTray() $TrayHide = Not $TrayHide Opt('TrayIconHide',$TrayHide) EndFunc Func Quit() Exit EndFunc Edited April 6, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
Ejoc Posted April 6, 2005 Author Share Posted April 6, 2005 cool Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs Link to comment Share on other sites More sharing options...
zcoacoaz Posted April 6, 2005 Share Posted April 6, 2005 (edited) what about the ability to keep a collection of scripts in a folder and you have a little script manager built in? it would automaticly add each script you run unless its already been run then it doesn't save edit: oh yeah if i get time i might make it and if i do it will also minimize to tray automaticly Edited April 6, 2005 by Xenogis [font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font] Link to comment Share on other sites More sharing options...
Ejoc Posted April 6, 2005 Author Share Posted April 6, 2005 what about the ability to keep a collection of scripts in a folder and you have a little script manager built in? it would automaticly add each script you run unless its already been run then it doesn't saveedit: oh yeah if i get time i might make it and if i do it will also minimize to tray automaticly<{POST_SNAPBACK}>Wow, I was actually thinking about doing the exact same thing, not built into this script but making a stand alone script manager. It could quite easily be a part of this script and it would be handy.I wanted it to keep track of all your scripts, let you edit and run them and I was also thinking about adding a "Grep" feature to search for text in all your scripts. Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs Link to comment Share on other sites More sharing options...
Ejoc Posted April 8, 2005 Author Share Posted April 8, 2005 (edited) I made a change that should apply to the variations as well as mine. It wasnt working right when the script was compiled, now it does: Func ExecuteScript($szFilename) Local $exe If @Compiled Then $exe = RegRead("HKLM\SOFTWARE\AutoIt v3\AutoIt","InstallDir") if $exe = "" Then MsgBox(0,"AutoIt not installed","AutoIt is not installed") Run($exe & '\AutoIt3.exe "' & $szFilename & '"') Else Run(@AutoItExe & ' "' & $szFilename & '"') Endif EndFuncExecuteClip.au3 Edited April 8, 2005 by Ejoc Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs 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