Jump to content
Sign in to follow this  
Jos

Copy Script Source to SciTE

Recommended Posts

Jos

This script will allow you to copy Script source from the forum in IE by doing a Right-mouse-click and selecting "Open in SciTE".

Works also correctly with CodeBoxes ....

Copy the script source to a separate directory in file: OpenInSciTE.au3.

Compile it

Run it ones to install itself.

To uninstall run "OpenInSciTE.exe /remove"

Close all IE windows and then STart IE again.

You will now Have an Option called "Open in SciTE" when you right-mouse-click"

Enjoy

#NoTrayIcon
#Region Compiler directives section
#Compiler_Allow_Decompile=y                       ;y= allow decompile
#Compiler_UseUpx=y                                ;Compress output program works only for 3.1.1.110 and up. Default=Yes
;** Target program Resource info
;#Compiler_Res_Language=1033                      ;Resource Language code . default 2057=English (United Kingdom)
#Compiler_Res_Comment=Program to be able to RightMouseClick on select IE script information and then select OpenInSciTE.
#Compiler_Res_Description=Program to be able to RightMouseClick on select IE script information and then select OpenInSciTE.
#Compiler_Res_Fileversion=1.0.0.0                 ;File Version
#Compiler_Res_FileVersion_AutoIncrement=n         ;AutoIncrement FileVersion After Aut2EXE is finished.
#Compiler_Res_LegalCopyright=JoSoft :-)
; free form resource fields ... max 15
#Compiler_Res_Field=Made By|Jos van der Zande
#Compiler_Res_Field=Email|jdeb at autoitscript dot com
#Compiler_Res_Field=AutoIt Version|%AutoItVer%
#Compiler_Res_Field=Compile Date|%date% %time%
#Compiler_Run_Tidy=y                              ;Run au3check before compilation. default=y
#Tidy_Parameters=/nsdp /sci 9 /gd 0               ;Tidy parameters
#Compiler_Tidy_Stop_onerror=y                     ;Continue when only Warnings. default=y
#Compiler_Run_AU3Check=y                          ;Run au3check before compilation. default=y
#Compiler_AU3Check_Stop_OnWarning=N               ;Continue when only Warnings. default=y
;#Compiler_AU3Check_Dat=C:\Program Files\AutoIt3\SciTe\Defs\unstable\Au3Check\au3check.dat  ;Override the default AU3Check Definition file
;#Compiler_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7     ;Au3Check parameters
; The following directives can contain %in% , %out%, %icon% which will be replaced by the fullpath\filename.
;#Compiler_Run_Before=
#Compiler_Run_cvsWrapper=n                        ;(y/n) Run cvsWrapper to update the script source. Default=n
#Compiler_Run_After=
#EndRegion
If StringInStr($cmdlineraw, "/remove") Then
    RegDelete("HKCU\Software\Microsoft\Internet Explorer\MenuExt\OpenInSciTE")
    FileDelete(@ScriptDir & "\OpenInSciTE.htm")
    MsgBox(0, "Open in SciTE", "Open in SciTE IE Extension removed, you need to restart IE.")
    Exit
EndIf
If Not FileExists(@ScriptDir & "\OpenInSciTE.htm") Or RegRead("HKCU\Software\Microsoft\Internet Explorer\MenuExt\Open in SciTE", "") <> @ScriptDir & "\OpenInSciTE.htm" Then
    RegWrite("HKCU\Software\Microsoft\Internet Explorer\MenuExt\Open in SciTE", "", "REG_SZ", @ScriptDir & "\OpenInSciTE.htm")
    RegWrite("HKCU\Software\Microsoft\Internet Explorer\MenuExt\Open in SciTE", "Context", "REG_DWORD", 10)
    FileDelete(@ScriptDir & "\OpenInSciTE.htm")
    CreateOpenInSciTE_HTM()
    MsgBox(0, "Open in SciTE", "Open in SciTE IE Extension Added, you need to restart IE before it is available.")
    Exit
EndIf
If $cmdline[0] = 0 Then Exit
;
If Not FileExists(@ScriptDir & "\CapturedScripts") Then DirCreate(@ScriptDir & "\CapturedScripts")
;
; Process the captured IE HTLM information
$outtext = $cmdlineraw
$outtext = StringReplace($outtext, @CRLF, "")
$outtext = StringReplace($outtext, "<BR>", @CRLF)
;<div class='codetop'>CODE</div>
;<div class='codetop'>CODE: AutoIt</div>
$outtext = StringRegExpReplace($outtext, "<(?i)(?s)div class=codetop(.*?)</div>", ";*** CodeBox Start *****************************************" & @CRLF)
;Remove DIVs
$outtext = StringRegExpReplace($outtext, "<(?i)(?s)(/?)DIV(.*?)>", "")
;Remove SPANs
$outtext = StringRegExpReplace($outtext, "<(?i)(?s)(/?)SPAN(.*?)>", "")
$outtext = StringRegExpReplace($outtext, "<!--(.*?)-->", "")
;Translater Hyper characters
$outtext = StringReplace($outtext, "&amp;", "&")
$outtext = StringReplace($outtext, "&nbsp;", " ")
$outtext = StringReplace($outtext, "&lt;", "<")
$outtext = StringReplace($outtext, "&gt;", ">")

; Find first free filename
$Count = 0
Do
    $Count += 1
    $FileName = @ScriptDir & "\CapturedScripts\OpenInScite" & $Count & ".au3"
Until Not FileExists($FileName)
; Write processed information
FileWriteLine($FileName, "#Tidy_Parameters=/rel 1")
FileWrite($FileName, $outtext)
$SciTE_Pgm = RegRead('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths\SciTE.exe', '')
RunWait('"' & StringReplace($SciTE_Pgm, "scite.exe", "Tidy\tidy.exe") & '" "' & $FileName & '"', "", @SW_HIDE)
DirRemove(@ScriptDir & "\CapturedScripts\Backup", 1)
;Run($SciTE_Pgm & ' "-open:' & StringReplace($FileName, "\", "\\") & '" "-menucommand:1109"')
Run($SciTE_Pgm & ' "-open:' & StringReplace($FileName, "\", "\\") & '"')
;
;
;Create needed file to launch SciTE which is referenced in the registry
Func CreateOpenInSciTE_HTM()
    FileWriteLine(@ScriptDir & "\OpenInSciTE.htm", '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">')
    FileWriteLine(@ScriptDir & "\OpenInSciTE.htm", '    <head>')
    FileWriteLine(@ScriptDir & "\OpenInSciTE.htm", '        <title>WebImageViewer 2005 redirector page</title>')
    FileWriteLine(@ScriptDir & "\OpenInSciTE.htm", '        &lt;script type="text/javascript">')
    FileWriteLine(@ScriptDir & "\OpenInSciTE.htm", '            var shell = new ActiveXObject("WScript.Shell");')
    FileWriteLine(@ScriptDir & "\OpenInSciTE.htm", '            shell.Exec("' & StringReplace(@ScriptFullPath, "\", "\\") & ' " + window.external.menuArguments.document.selection.createRange().htmlText);')
    FileWriteLine(@ScriptDir & "\OpenInSciTE.htm", '        </script>')
    FileWriteLine(@ScriptDir & "\OpenInSciTE.htm", '    </head>')
    FileWriteLine(@ScriptDir & "\OpenInSciTE.htm", '    <body>')
    FileWriteLine(@ScriptDir & "\OpenInSciTE.htm", '    </body>')
    FileWriteLine(@ScriptDir & "\OpenInSciTE.htm", '</html>')
EndFunc   ;==>CreateOpenInSciTE_HTM
Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
MHz

Looks good JdeB.

A lot easier then pasting into Wordpad, save it and then open in Scite as suggested previously.

:shocked:

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  

×