Sign in to follow this  
Followers 0
Wolvereness

Tired of copy pasted help doc scripts?

5 posts in this topic

Run this code then while reading the help document just highlight, copy, and press ctrl+alt+home.

To exit press ctrl+alt+end

;Run it once before you start reading the help file
;Ctrl+Alt+Home AFTER YOU ADD THE SCRIPT TO THE CLIPBOARD (highlight, right click, press copy)
;Ctrl+Alt+End to stop the script

$x = ""
$x = $x & @CRLF & "$wFileDir = " & "'" & '"' & "'" & " & @TempDir & '\TempA.au3" & '"' & "'"
$x = $x & @CRLF & '$wExe =  ' & "'" & '"' & "'" & ' & RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\Autoit", "InstallDir") & '& "'" & '\AutoIt3.exe"' & "'"
$x = $x & @CRLF & "$wFileHandle = FileOpen(@TempDir & '\TempA.au3',2)"
$x = $x & @CRLF & "FileWrite($wFileHandle,ClipGet())"
$x = $x & @CRLF & 'FileClose($wFileHandle)'
$x = $x & @CRLF & 'Run($wExe & " " & $wFileDir)'

$wFileHandle = FileOpen(@TempDir & '\TempB.au3',2)
FileWrite($wFileHandle,$x)
FileClose($wFileHandle)
$wFileDir = '"' & @TempDir & '\TempB.au3"'
$wExe = '"' & RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\Autoit", "InstallDir") & '\AutoIt3.exe"'

HotKeySet("^!{HOME}","wRun")
HotKeySet("^!{END}","wExit")

While 1
  Sleep(10)
WEnd

Func wRun()
  Run($wExe & " " & $wFileDir)
EndFunc


Func wExit()
  Exit
EndFunc

Offering any help to anyone (to my capabilities of course)Want to say thanks? Click here! [quote name='Albert Einstein']Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.[/quote][quote name='Wolvereness' date='7:35PM Central, Jan 11, 2005']I'm NEVER wrong, I call it something else[/quote]

Share this post


Link to post
Share on other sites



For those of you who want to have the ability to call another script from the clipboard while one ios already running:

Au3ClipRun.au3 :

opt("TrayIconHide", 1)
#include "shellexecute.au3"
$fullpath = ""
$clp = ClipGet()
if not @error Then
  $flnm = Int(Random(10000000, 99999999))
  $fullpath = @Tempdir & "\" & $flnm & ".au3"
  FileWrite($fullpath, $clp)
  $chk = RunWait('C:\Program Files\AutoIt3\SciTe\Au3Check\Au3Check.exe "' & $fullpath & '"', "", @SW_HIDE)
  if $chk <> 0 Then
     $msg = Msgbox(4, "Au3ClipRun", "Bad Scripting. Run Still?")
     if $msg <> 6 Then
        del()
        Exit
     EndIf
  EndIf
  shellexecute($fullpath, "", 1)
  del()
EndIf

func del()
  FileDelete($fullpath)
EndFunc

shellexecute.au3 :

#include-once
func shellexecute($file, $verb, $wait)
    local $oldopt = opt("expandenvstrings", 0)
    $ext = StringTrimLeft($file, StringInStr($file, ".", 0, -1))
    $fltp = RegRead("HKEY_CLASSES_ROOT\." & $ext, "")
    if @error Then $fltp = $ext & "file"
    $defverb = RegRead("HKEY_CLASSES_ROOT\" & $fltp & "\shell", "")
    if $defverb = "" Then $defverb = "Open"
    if $verb = "" Then
        $cmd = RegRead("HKEY_CLASSES_ROOT\" & $fltp & "\shell\" & $defverb & "\command", "")
    Else
        $cmd = RegRead("HKEY_CLASSES_ROOT\" & $fltp & "\shell\" & $verb & "\command", "")
    EndIf
    if @error Then
        $cmd = RegEnumKey("HKEY_CLASSES_ROOT\" & $fltp & "\shell", 1)
        if @error Then Return 2
    EndIf
    $cmd = StringReplace($cmd, "%l", FileGetLongName($file))
    $cmd = StringReplace($cmd, "%1", $file)
    $cmd = StringReplace($cmd, "%*", "")
    for $i = 2 to 9
        $cmd = StringReplace($cmd, "%" & $i, "")
    Next
;Why do I have to do this instead of expandenvstrings?
    $env = StringInStr($cmd, "%", 0, 1)
    if not @error Then
        for $i = 1 to 5 Step 2
            if not StringInStr($cmd, "%", 0, $i) Then ExitLoop
            $envx = StringMid($cmd, StringInStr($cmd, "%", 0, $i) + 1, StringInStr($cmd, "%", 0, $i + 1) - 2)
            $cmd = StringReplace($cmd, "%" & $envx & "%", EnvGet($envx))
        Next
    EndIf
    if $wait Then
        RunWait($cmd)
    Else
        Run($cmd)
    EndIf
    opt("expandenvstrings", $oldopt)
endfunc

Who else would I be?

Share this post


Link to post
Share on other sites

Copy and paste is evil if made mindlessy... Be careful!

Share this post


Link to post
Share on other sites

That's why I included au3check in my script. If you run the script without an au3 file in the clipboard, it says there is something wrong.


Who else would I be?

Share this post


Link to post
Share on other sites

Copy and paste is evil if made mindlessy... Be careful!

<{POST_SNAPBACK}>

What do you mean by that? my script doesn't paste and only has 2 temporary files.

Offering any help to anyone (to my capabilities of course)Want to say thanks? Click here! [quote name='Albert Einstein']Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.[/quote][quote name='Wolvereness' date='7:35PM Central, Jan 11, 2005']I'm NEVER wrong, I call it something else[/quote]

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  
Followers 0