Jump to content
Sign in to follow this  
Autoxics

Read And Execute Script From A Text File?

Recommended Posts

Here is the final script, that makes autoit read and execute a script that is currently stored in window clipboard

thanks for the help with this guys!

I call this script Clip2Exec :)

$file = FileOpen("Clip2Exec.txt", 1)
Sleep(50)
$bak = ClipGet()
FileWrite($file, "" & $bak)
FileClose($file)
Sleep(50)
$File = @ScriptDir & '\Clip2Exec.txt'
Run(@AutoItExe & ' /AutoIt3ExecuteScript ' & FileGetShortName($File))
Sleep(100)
FileDelete("Clip2Exec.txt")

works with most au3 scripts,

and what do you call this

$TLoc = @TempDir & "\test.au3"
$TInfo = ClipGet()
FileWrite($TLoc, $TInfo)

If FileExists($TLoc) Then
    $File = FileGetShortName($TLoc)
    RunWait(@AutoItExe & " " & $File)
    FileDelete($TLoc)
Else
    MsgBox(64, "Error", "The file was not found  ", 2)
EndIf

?????

8)

Share this post


Link to post
Share on other sites

first i dident get it to work then i thouth if i put some delay with a sleep in script, i might be able to have a workaround, by letting the au3 script write clipboard to file then close and finaly read it,

works pretty well,

Share this post


Link to post
Share on other sites

and what do you call this

$TLoc = @TempDir & "\test.au3"
$TInfo = ClipGet()
FileWrite($TLoc, $TInfo)

If FileExists($TLoc) Then
    $File = FileGetShortName($TLoc)
    RunWait(@AutoItExe & " " & $File)
    FileDelete($TLoc)
Else
    MsgBox(64, "Error", "The file was not found  ", 2)
EndIf

?????

the reason i made another workaround, was because when i first ran the code you gave me my system hanged, and so i was to afraid to get the same result ones again , but your sugestion seems to work aswell,

and thanks to you booth guy i was able to find this workaround

8)

Share this post


Link to post
Share on other sites

Your right, but it works for most quickscripts i have throwed at it, but the deletepart aint necesary, just something i added in otherwise when i hade a new script in clipboard it gave me an error , cause it wrote the new script to the same textfile mixing the script that was currently in the text file with the new script

Share this post


Link to post
Share on other sites

now who's bored enough to turn this into an add on for ie, so that you can select a script in the forum and execute it without having to paste into scite or anything?

Share this post


Link to post
Share on other sites

now who's bored enough to turn this into an add on for ie, so that you can select a script in the forum and execute it without having to paste into scite or anything?

Not I, here's as close as I'm willing to get to that Idea http://www.autoitscript.com/forum/index.ph...ndpost&p=173880


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

...and to think that I've been doing it the hard way for some time now:

FileWrite(FileOpen("c:\temp\SciTE-temp.au3",2),ClipGet())
FileClose("c:\temp\SciTE-temp.au3")
Run("C:\Program Files\AutoIt3\SciTe\SciTe.exe c:\temp\SciTE-temp.au3")
I have an OS shortcut key of ctrl-alt-S to bring it up in SciTE if I want to "Tidy" it (edit: and run the syntax checker on the code).

Or ctrl-alt-R if I just want to run it:

FileWrite(FileOpen("c:\temp\temp.au3",2),ClipGet())
FileClose("c:\temp\temp.au3")
Run(@AutoItExe & " c:\temp\temp.au3")

Or ctrl-alt-B for a beta run.....

Edit2: not much error checking for such unimportant code...

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

now who's bored enough to turn this into an add on for ie, so that you can select a script in the forum and execute it without having to paste into scite or anything?

Well one could add an icon in the IE tollbar witch when browsing and selecting a script in the forum ,

youd just have to press that icon in the IE toolbar and it would inturn copy the selected text/script and execute it for you right away.

Share this post


Link to post
Share on other sites

Well one could add an icon in the IE tollbar...

or place OS shortcuts to au3 files in your links folder (enable/drag the links bar to a useful place) and you get the same single click execution as a button but much easier to nest (organize) into subfolders. I have a folder for certain AutoIt scripts and a sub-folder for scripts that pull e-mails from various accounts. Other scripts that I use more often are in the "root" of the links folder - they show up directly on the "links bar".

I have most of my "Favorites" in folders and subfolders on the "links bar". I have 8 main folders atm. Just name the folders something short so that you can get plenty of them on the bar... i.e. the folder that has all of my links to all things related to AutoIt is named "A3".

I have another folder named "Search" under it are subfolders for "Dictionary-abbrev", "Engines", "Maps", "Phone-white-yellow"...

...like you cared to know all of that...


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...