General :  K-Meleon Web Browser Forum
General discussion about K-Meleon 
code tester
Posted by: disrupted
Date: April 03, 2009 11:12AM

sometimes you run into a script on a webpage and would like to test it and see how it functions..so you need to copy the script and paste it in notepad, save it with the appropriate extension and then launch it for previewing.

kmcoder automates this procedure by automatically creating a file with the selected extension and writing the code to it and finally executing it with the default handler.
http://necb.bizhat.com/kmeleon/kmcoder.7z

how to:
-highlight code and rightclick and select "code tester"
-choose the extension that corresponds to the code
-if the script is a widget like flash or js, you can select embed in html which will generate an html file wih the copied code
-use with caution and only with scripts you can trust.


macro:
# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)

# ---------- script codes tester--------------------------------------------------------

$_tool_path=getfolder(RootFolder)."\\Tools";

codetest{
setclipboard("");
id(ID_EDIT_COPY);
exec($_tool_path."\\codetester\\codetester.exe \"");
}

codetest_BuildMenu{
setmenu(Selection,inline,coder_page,2);
setmenu(coder_page,macro,"Code Tester",codetest);
}

$OnInit=$OnInit."codetest_BuildMenu;";
# ------------------------------------------------------------------
$macroModules=$macroModules."codetester;";


autoit src: (can also be executed directly without kmeleon and without compiling)
; AutoIt Version: 3.0
; Language: English
; Platform: Win9x/NT
; Author: yanni
;
#include <GuiConstants.au3>
#include <GUIConstantS E X.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>
#Include <File.au3>
#Include <Clipboard.au3>

#NoTrayIcon

$testcode=ClipGet()
$htmlpend=(@scriptDir &"\testembed.html")

$sStrippedCmd = StringRegExpReplace($CmdLineRaw, "download:", "")
$main = GUICreate("K-Meleon Code Tester", 194, 258, -1, -1, BitOR($WS_SYSMENU, $WS_EX_TOPMOST))
$Label = GUICtrlCreateLabel("Select script type :", 10, 10, 182, 20)
$Radio_1 = GUICtrlCreateRadio("AutoIt (*.au3)", 10, 30, 182, 20)
$Radio_2 = GUICtrlCreateRadio("AutoHotKey (*.ahk)", 10, 50, 200, 20)
$Radio_3 = GUICtrlCreateRadio("Visual Basic (*.vb)", 10, 70, 182, 20)
$Radio_4 = GUICtrlCreateRadio("Win Script (*.wsh)", 10, 90, 182, 20)
$Radio_5 = GUICtrlCreateRadio("Java Script (*.js)", 10, 110, 182, 20)
$Radio_6 = GUICtrlCreateRadio("Perl Script (*.pl)", 10, 130, 182, 20)
$Radio_7 = GUICtrlCreateRadio("Python Script (*.py)", 10, 150, 182, 20)
$Radio_8 = GUICtrlCreateRadio("embed in HTML (*.html)", 10, 170, 182, 20)
$Button_3 = GUICtrlCreateButton("Execute", 10, 200, 80, 20, BitOR($BS_FLAT, $WS_BORDER, $WS_EX_STATICEDGE))
$Button_c = GUICtrlCreateButton("Cancel", 98, 200,80, 20, BitOR($BS_FLAT, $WS_BORDER, $WS_EX_STATICEDGE))

GUICtrlSetState($Radio_1, $GUI_CHECKED)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
;Handle Start/Button_3 Click
Case $msg = $Button_3
Select
Case GUICtrlRead($Radio_1) = $GUI_CHECKED
GUISetState(@SW_HIDE)
if FileExists(@TempDir & "\testcode.au3") Then
FileDelete(@TempDir & "\testcode.au3")
sleep(80)
_FileCreate(@TempDir & "\testcode.au3")
FileWrite(@TempDir & "\testcode.au3", $testcode)
sleep(1200)
shellexecute(@TempDir & "\testcode.au3")
Else
_FileCreate(@TempDir & "\testcode.au3")
FileWrite(@TempDir & "\testcode.au3", $testcode)
sleep(1200)
shellexecute(@TempDir & "\testcode.au3")
EndIf
ExitLoop
Case GUICtrlRead($Radio_2) = $GUI_CHECKED
GUISetState(@SW_HIDE)
if FileExists(@TempDir & "\testcode.ahk") Then
FileDelete(@TempDir & "\testcode.ahk")
sleep(80)
_FileCreate(@TempDir & "\testcode.ahk")
FileWrite(@TempDir & "\testcode.ahk", $testcode)
sleep(1200)
shellexecute(@TempDir & "\testcode.ahk")
Else
_FileCreate(@TempDir & "\testcode.ahk")
FileWrite(@TempDir & "\testcode.ahk", $testcode)
sleep(1200)
shellexecute(@TempDir & "\testcode.ahk")
EndIf
ExitLoop
Case GUICtrlRead($Radio_3) = $GUI_CHECKED
GUISetState(@SW_HIDE)
if FileExists(@TempDir & "\testcode.vb") Then
FileDelete(@TempDir & "\testcode.vb")
sleep(80)
_FileCreate(@TempDir & "\testcode.vb")
FileWrite(@TempDir & "\testcode.vb", $testcode)
sleep(1200)
shellexecute(@TempDir & "\testcode.vb")
Else
_FileCreate(@TempDir & "\testcode.vb")
FileWrite(@TempDir & "\testcode.vb", $testcode)
sleep(1200)
shellexecute(@TempDir & "\testcode.vb")
EndIf
ExitLoop
Case GUICtrlRead($Radio_4) = $GUI_CHECKED
GUISetState(@SW_HIDE)
if FileExists(@TempDir & "\testcode.wsh") Then
FileDelete(@TempDir & "\testcode.wsh")
sleep(80)
_FileCreate(@TempDir & "\testcode.wsh")
FileWrite(@TempDir & "\testcode.au3", $testcode)
sleep(1200)
shellexecute(@TempDir & "\testcode.wsh")
Else
_FileCreate(@TempDir & "\testcode.wsh")
FileWrite(@TempDir & "\testcode.wsh", $testcode)
sleep(1200)
shellexecute(@TempDir & "\testcode.wsh")
EndIf
ExitLoop
Case GUICtrlRead($Radio_5) = $GUI_CHECKED
GUISetState(@SW_HIDE)
if FileExists(@TempDir & "\testcode.js") Then
FileDelete(@TempDir & "\testcode.js")
sleep(80)
_FileCreate(@TempDir & "\testcode.js")
FileWrite(@TempDir & "\testcode.js", $testcode)
sleep(1200)
shellexecute(@TempDir & "\testcode.js")
Else
_FileCreate(@TempDir & "\testcode.js")
FileWrite(@TempDir & "\testcode.js", $testcode)
sleep(1200)
shellexecute(@TempDir & "\testcode.js")
EndIf
ExitLoop
Case GUICtrlRead($Radio_6) = $GUI_CHECKED
GUISetState(@SW_HIDE)
if FileExists(@TempDir & "\testcode.pl") Then
FileDelete(@TempDir & "\testcode.pl")
sleep(80)
_FileCreate(@TempDir & "\testcode.pl")
FileWrite(@TempDir & "\testcode.pl", $testcode)
sleep(1200)
shellexecute(@TempDir & "\testcode.pl")
Else
_FileCreate(@TempDir & "\testcode.pl")
FileWrite(@TempDir & "\testcode.pl", $testcode)
sleep(1200)
shellexecute(@TempDir & "\testcode.pl")
EndIf
ExitLoop
Case GUICtrlRead($Radio_7) = $GUI_CHECKED
GUISetState(@SW_HIDE)
if FileExists(@TempDir & "\testcode.py") Then
FileDelete(@TempDir & "\testcode.py")
sleep(80)
_FileCreate(@TempDir & "\testcode.py")
FileWrite(@TempDir & "\testcode.py", $testcode)
sleep(1200)
shellexecute(@TempDir & "\testcode.py")
Else
_FileCreate(@TempDir & "\testcode.py")
FileWrite(@TempDir & "\testcode.py", $testcode)
sleep(1200)
shellexecute(@TempDir & "\testcode.py")
EndIf
ExitLoop
Case GUICtrlRead($Radio_8) = $GUI_CHECKED
GUISetState(@SW_HIDE)
if FileExists(@TempDir & "\testembed.html") Then
FileDelete(@TempDir & "\testembed.html")
sleep(80)
FileCopy($htmlpend, @TempDir)
sleep(80)
_FileWriteToLine(@TempDir & "\testembed.html", 8, $testcode, 1)
sleep(1200)
shellexecute(@TempDir & "\testembed.html")
Else
FileCopy($htmlpend, @TempDir)
sleep(80)
_FileWriteToLine(@TempDir & "\testembed.html", 8, $testcode, 1)
sleep(1200)
shellexecute(@TempDir & "\testembed.html")
EndIf
ExitLoop
Case Else

EndSelect
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Button_c
Exit
Case Else

;;;
EndSelect
Sleep(10)
WEnd
exit




example testing autoit script from the autoit forums:






example testing widget in html:





Options: ReplyQuote
Re: code tester
Posted by: desga2
Date: April 03, 2009 03:42PM

Interesant extension, thanks. smiling smiley

K-Meleon in Spanish

Options: ReplyQuote


K-Meleon forum is powered by Phorum.