AutoIt plugin/brush for WordPress

Here is the AutoIt plugin (brush as it is called) for the Syntax Highlighter for WordPress plugin,  which uses the Alex Gorbatchev’s SyntaxHighlighter Script..

(After completing this post I found that the post was too untidy to

follow…unless you have tried your hands on hacking or modifying

scripts. If you are a newbie, AND MOST IMPORTANTLY IF THIS IS THE FIRST

HACK for your wordpress, syntax-highlighter, follow method ONE described below (download the codes and then paste them in the folders

mentioned) .. And for the rest of you who wanna get your hands dirty

hacking the script, goto Method TWO ..

( Do this AT YOUR OWN RISK. IT WORKED FOR ME THOUGH :P)

METHOD ONE :

Download this zip file. Extract it. It has two files

  • shBrushAutoit.js
  • syntax_highlighter.php

Paste the shBrushAutoit.js file into your js folder located at plugins/syntax-highlighter<latest version number>js ( example plugins/syntax-highlighter3.0.83js )

( Take a BACKUP of the existing syntax_highlighter.php file before you OVERWRITE it ) Paste the syntax_highlighter.php into your pluginssyntax-highlighter folder

Then refresh the page with the Autoit script . The highlighting should be enabled.

METHOD TWO:

Create a new file called shBrushAutoit.js inside the js folder located at plugins/syntax-highlighter<latest version number>js ( example plugins/syntax-highlighter3.0.83js ) of the syntax-highlighter plugin. And paste the following code into it. Or you can Download this zip file and copy paste the contents from it. [javascript]

;(function()

{

// CommonJS

typeof(require) != ‘undefined’ ? SyntaxHighlighter = require(‘shCore’).SyntaxHighlighter : null;

function Brush()

{

var funcs = ‘Abs ACos AdlibRegister AdlibUnRegister Asc AscW ASin Assign ATan AutoItSetOption AutoItWinGetTitle ‘ +

‘AutoItWinSetTitle Beep Binary BinaryLen BinaryMid BinaryToString BitAND BitNOT BitOR BitRotate BitShift ‘ +

‘BitXOR BlockInput Break Call CDTray Ceiling Chr ChrW ClipGet ClipPut ConsoleRead ConsoleWrite ConsoleWriteError ‘ +

‘ControlClick ControlCommand ControlDisable ControlEnable ControlFocus ControlGetFocus ControlGetHandle ‘ +

‘ControlGetPos ControlGetText ControlHide ControlListView ControlMove ControlSend ControlSetText ControlShow ‘ +

‘ControlTreeView Cos Dec DirCopy DirCreate DirGetSize DirMove DirRemove DllCall DllCallbackFree DllCallbackGetPtr ‘ +

‘DllCallbackRegister DllClose DllOpen DllStructCreate DllStructGetData DllStructGetPtr DllStructGetSize ‘ +

‘DllStructSetData DriveGetDrive DriveGetFileSystem DriveGetLabel DriveGetSerial DriveGetType DriveMapAdd ‘ +

‘DriveMapDel DriveMapGet DriveSetLabel DriveSpaceFree DriveSpaceTotal DriveStatus EnvGet EnvSet EnvUpdate Eval ‘ +

‘Execute Exp FileChangeDir FileClose FileCopy FileCreateNTFSLink FileCreateShortcut FileDelete FileExists ‘ +

‘FileFindFirstFile FileFindNextFile FileFlush FileGetAttrib FileGetEncoding FileGetLongName FileGetPos ‘ +

‘FileGetShortcut FileGetShortName FileGetSize FileGetTime FileGetVersion FileInstall FileMove FileOpen ‘ +

‘FileOpenDialog FileRead FileReadLine FileRecycle FileRecycleEmpty FileSaveDialog FileSelectFolder FileSetAttrib ‘ +

‘FileSetPos FileSetTime FileWrite FileWriteLine Floor FtpSetProxy GUICreate GUICtrlCreateAvi GUICtrlCreateButton ‘ +

‘GUICtrlCreateCheckbox GUICtrlCreateCombo GUICtrlCreateContextMenu GUICtrlCreateDate GUICtrlCreateDummy ‘ +

‘GUICtrlCreateEdit GUICtrlCreateGraphic GUICtrlCreateGroup GUICtrlCreateIcon GUICtrlCreateInput GUICtrlCreateLabel ‘ +

‘GUICtrlCreateList GUICtrlCreateListView GUICtrlCreateListViewItem GUICtrlCreateMenu GUICtrlCreateMenuItem ‘ +

‘GUICtrlCreateMonthCal GUICtrlCreateObj GUICtrlCreatePic GUICtrlCreateProgress GUICtrlCreateRadio ‘ +

‘GUICtrlCreateSlider GUICtrlCreateTab GUICtrlCreateTabItem GUICtrlCreateTreeView GUICtrlCreateTreeViewItem ‘ +

‘GUICtrlCreateUpdown GUICtrlDelete GUICtrlGetHandle GUICtrlGetState GUICtrlRead GUICtrlRecvMsg ‘ +

‘GUICtrlRegisterListViewSort GUICtrlSendMsg GUICtrlSendToDummy GUICtrlSetBkColor GUICtrlSetColor GUICtrlSetCursor ‘ +

‘GUICtrlSetData GUICtrlSetDefBkColor GUICtrlSetDefColor GUICtrlSetFont GUICtrlSetGraphic GUICtrlSetImage ‘ +

‘GUICtrlSetLimit GUICtrlSetOnEvent GUICtrlSetPos GUICtrlSetResizing GUICtrlSetState GUICtrlSetStyle GUICtrlSetTip ‘ +

‘GUIDelete GUIGetCursorInfo GUIGetMsg GUIGetStyle GUIRegisterMsg GUISetAccelerators GUISetBkColor GUISetCoord ‘ +

‘GUISetCursor GUISetFont GUISetHelp GUISetIcon GUISetOnEvent GUISetState GUISetStyle GUIStartGroup GUISwitch Hex ‘ +

‘HotKeySet HttpSetProxy HttpSetUserAgent HWnd InetClose InetGet InetGetInfo InetGetSize InetRead IniDelete IniRead ‘ +

‘IniReadSection IniReadSectionNames IniRenameSection IniWrite IniWriteSection InputBox Int IsAdmin IsArray IsBinary ‘ +

‘IsBool IsDeclared IsDllStruct IsFloat IsHWnd IsInt IsKeyword IsNumber IsObj IsPtr IsString Log MemGetStats Mod ‘ +

‘MouseClick MouseClickDrag MouseDown MouseGetCursor MouseGetPos MouseMove MouseUp MouseWheel MsgBox Number ObjCreate ‘ +

‘ObjEvent ObjGet ObjName OnAutoItExitRegister OnAutoItExitUnRegister Ping PixelChecksum PixelGetColor PixelSearch ‘ +

‘PluginClose PluginOpen ProcessClose ProcessExists ProcessGetStats ProcessList ProcessSetPriority ProcessWait ‘ +

‘ProcessWaitClose ProgressOff ProgressOn ProgressSet Ptr Random RegDelete RegEnumKey RegEnumVal RegRead RegWrite ‘ +

‘Round Run RunAs RunAsWait RunWait Send SendKeepActive SetError SetExtended ShellExecute ShellExecuteWait Shutdown ‘ +

‘Sin Sleep SoundPlay SoundSetWaveVolume SplashImageOn SplashOff SplashTextOn Sqrt SRandom StatusbarGetText StderrRead ‘ +

‘StdinWrite StdioClose StdoutRead String StringAddCR StringCompare StringFormat StringFromASCIIArray StringInStr ‘ +

‘StringIsAlNum StringIsAlpha StringIsASCII StringIsDigit StringIsFloat StringIsInt StringIsLower StringIsSpace ‘ +

‘StringIsUpper StringIsXDigit StringLeft StringLen StringLower StringMid StringRegExp StringRegExpReplace ‘ +

‘StringReplace StringRight StringSplit StringStripCR StringStripWS StringToASCIIArray StringToBinary StringTrimLeft ‘ +

‘StringTrimRight StringUpper Tan TCPAccept TCPCloseSocket TCPConnect TCPListen TCPNameToIP TCPRecv TCPSend ‘ +

‘TCPShutdown, UDPShutdown TCPStartup, UDPStartup TimerDiff TimerInit ToolTip TrayCreateItem TrayCreateMenu ‘ +

‘TrayGetMsg TrayItemDelete TrayItemGetHandle TrayItemGetState TrayItemGetText TrayItemSetOnEvent TrayItemSetState ‘ +

‘TrayItemSetText TraySetClick TraySetIcon TraySetOnEvent TraySetPauseIcon TraySetState TraySetToolTip TrayTip UBound ‘ +

‘UDPBind UDPCloseSocket UDPOpen UDPRecv UDPSend VarGetType WinActivate WinActive WinClose WinExists WinFlash ‘ +

‘WinGetCaretPos WinGetClassList WinGetClientSize WinGetHandle WinGetPos WinGetProcess WinGetState WinGetText ‘ +

‘WinGetTitle WinKill WinList WinMenuSelectItem WinMinimizeAll WinMinimizeAllUndo WinMove WinSetOnTop WinSetState ‘ +

‘WinSetTitle WinSetTrans WinWait WinWaitActive WinWaitClose WinWaitNotActive’;

var macros = ‘@AppDataCommonDir @AppDataDir @AutoItExe @AutoItPID @AutoItVersion @AutoItX64 @COM_EventObj @CommonFilesDir ‘ +

‘@Compiled @ComputerName @ComSpec @CPUArch @CR @CRLF @DesktopCommonDir @DesktopDir @DesktopHeight @DesktopWidth ‘ +

‘@DesktopDepth @DesktopRefresh @DocumentsCommonDir @error @exitCode @exitMethod @extended @FavoritesCommonDir ‘ +

‘@FavoritesDir @GUI_CtrlId @GUI_CtrlHandle @GUI_DragId @GUI_DragFile @GUI_DropId @GUI_WinHandle @HomeDrive @HomePath ‘ +

‘@HomeShare @HOUR @HotKeyPressed @IPAddress1 @IPAddress2 @IPAddress3 @IPAddress4 @KBLayout @LF @LogonDNSDomain ‘ +

‘@LogonDomain @LogonServer @MDAY @MIN @MON @MSEC @MUILang @MyDocumentsDir @NumParams @OSArch @OSBuild @OSLang ‘ +

‘@OSServicePack @OSType @OSVersion @ProgramFilesDir @ProgramsCommonDir @ProgramsDir @ScriptDir @ScriptFullPath ‘ +

‘@ScriptLineNumber @ScriptName @SEC @StartMenuCommonDir @StartMenuDir @StartupCommonDir @StartupDir @SW_DISABLE ‘ +

‘@SW_ENABLE @SW_HIDE @SW_LOCK @SW_MAXIMIZE @SW_MINIMIZE @SW_RESTORE @SW_SHOW @SW_SHOWDEFAULT @SW_SHOWMAXIMIZED ‘ +

‘@SW_SHOWMINIMIZED @SW_SHOWMINNOACTIVE @SW_SHOWNA @SW_SHOWNOACTIVATE @SW_SHOWNORMAL @SW_UNLOCK @SystemDir @TAB ‘ +

‘@TempDir @TRAY_ID @TrayIconFlashing @TrayIconVisible @UserProfileDir @UserName @WDAY @WindowsDir @WorkingDir @YDAY @YEAR’;

var keywords =   ‘Func EndFunc ContinueCase ContinueLoop Default Dim

Global Local Const Do Until Enum Exit ExitLoop For To Step Next In If ‘

+

‘Then Else ElseIf EndIf ReDim Select Case EndSelect Static Switch EndSwitch While WEnd With EndWith’;

var r = SyntaxHighlighter.regexLib;

this.regexList = [

{ regex: r.multiLineDoubleQuotedString,        css: ‘string’ },         // double quoted strings

{ regex: r.multiLineSingleQuotedString,        css: ‘string’ },         // single quoted strings

{ regex: r.singleLineCComments,                css: ‘comments’ },         // one line comments

{ regex: r.multiLineCComments,                 css: ‘comments’ },         // multiline comments

{ regex: /^[&nbsp;]*;[^(rn)]+[rn]/gm,

css: ‘comments’ },            // one line comments starting with ;

{ regex: /s*#.*/gm,                           css: ‘comments’ },      // preprocessor tags like #region and #endregion

{ regex: /$w+/g,                              css: ‘variable’ },         // variables

{ regex: new RegExp(this.getKeywords(funcs), ‘gmi’),   css: ‘functions’ },         // documented functions

{ regex: new RegExp(this.getKeywords(keywords), ‘gm’),   css: ‘keyword’ },         // keywords

{ regex: new RegExp(this.getKeywords(macros), ‘gmi’),   css: ‘color1’ }            // documented macros

];

this.forHtmlScript(r.scriptScriptTags);

};

Brush.prototype   = new SyntaxHighlighter.Highlighter();

Brush.aliases   = [‘au3’, ‘autoit’];

SyntaxHighlighter.brushes.Autoit = Brush;

// CommonJS

typeof(exports) != ‘undefined’ ? exports.Brush = Brush : null;

})();

[/javascript]

place it inside the js folder of the syntax-highlighter plugin.

Then goto the “syntax-highlighter” folder inside the “wp-contentplugins” directory. Make the following changes to the “syntax_highlighter.php” file :

Change 1:

Add the following line ,

[javascript]

‘AutoIt’ ,

[/javascript]

after the following line,

[javascript]

var $target = array(

‘AS3’ ,

[/javascript]

Change 2:

add this line

[javascript]

“autoit”  => array(false, ‘AutoIt’, ‘js/shBrushAutoit.js’, ‘shBrushAutoit’) ,

[/javascript] after the following line

[javascript]

$this->languages = array(

“as3”  => array(false, ‘AS3’, ‘js/shBrushAS3.js’, ‘shBrushAS3’) ,

[/javascript]

Change 3:

add this line

[javascript]

// AutoIt

if (isset($this->languages[“autoit”]) && $this->languages[“autoit”][0])

$scripts .= ‘<script type=”text/javascript”

src=”‘.$sh_url.$this->languages[‘autoit’][2].’?ver=’.$this->version.'”></script>’.”n”;

[/javascript] after the following line

[javascript]

// AS3

if (isset($this->languages[“as3”]) && $this->languages[“as3″][0])

$scripts .= ‘<script type=”text/javascript”

src=”‘.$sh_url.$this->languages[‘as3′][2].’?ver=’.$this->version.'”></script>’.”n”;

[/javascript]

Change 4:

add this line

[javascript]

function Shortcode_autoit($atts, $content = null) {return $this->Shortcode_Handler($atts, $content, ‘autoit’);}

[/javascript] before the following line

[javascript]

//**************************************************************************************

// parse shortcodes

//**************************************************************************************

[/javascript]

AutoIT- Simple Timer

A simple Autoit code..

[autoit]

#comments-start
# author : ram
# site      : ramnathbabu.com
# Displays a timer at the TOP LEFT (can be customized)
#         corner of your screen. Displays the time you have spent
# You are free to modify/use/distribute the code.
# Try to retain the site somewhere in the script
#comments-end

; setting HotKey
HotKeySet(“{ESC}” , “fexit”)

;Tray GUI Creation
$aboutitem  = TrayCreateItem(“About”)
TrayCreateItem(“”)
$exit = TrayCreateItem(“Exit”)
TraySetState()

;Timer
$begin = TimerInit()

While 1
; gives seconds
$T = StringLeft( TimerDiff($begin), _
StringInStr(TimerDiff($begin), “.”) -4)

Sleep(20)

; check if the tray has been clicked
$msg = TrayGetMsg()

; tooltip diplay @ top-left corner
ToolTip(“” & Int($T / 60) & “:” & mod($T,60), 0, 0, “Timer”)

Select
Case $msg = $aboutitem
; if the user has clicked “About”
Msgbox(64,”About:”,”November 2010″ & @crlf & @crlf & _
“Instructions:” & @CRLF & “ALT+CTRL+SHIFT+X – Get Progress” _
& @CRLF & “ALT+ESC – Exit Program” & @crlf & @crlf & “Free usage :)”)

Case $msg = $exit
; if the user has clicked “Exit”
Exit
EndSelect
WEnd

func fexit()
; when “Esc” button is pressed – exit
Exit
EndFunc

[/autoit]

Programming Languages

I was recently searching for A GOOD programming language to cling on to.. I have a worked for some time now, looking at various programming languages to get a feel of the available programing paradigms . Considering the fact that one does not generally have the luxury of time, I thought it would be more appropriate to first understand the available tools of trade before u get your hands dirty writing your own piece of code from scratch ( I am no demoralising the ones who are enthusiastic about writing their own code.. It is just that I believe, the (more) important question is what u added to the existing body of knowledge/code).

Being a person willing to hack my way out, in case I need to get something done, I have an ardent fan and I always would vouch for open-source programs

From the point of view of a researcher, I think the choice of a programming language is all the more important. As I write this post ( as the year 2010 draws to end ) I still find that the major programming languages have  a long way to go to reach what I prefer to call intuitive programming. ( Mathematica is a , which is to be released sooner, has implemented free-form input, which I think is a significant step towards this).

Now given the fact that no one is yet there, I would restate the question I posed in the beginning of this blog, about the choice of programming language. I have read some posts on the internet and have summarized some of my personal opinion here with relevant references. I hope this post would come in handy for a person who is wondering about the choice of programming languages.

I am a researcher,and simply put, I am looking for the following features in a GOOD programming language ( designers note …),

  • which can crunch numbers .. and is as fast as it can get (SPEED IS A MUST).. I know that hand-tweaking a C,C++ or FORTRAN code is (currently)  the ONLY solution, considering practicality. (I am not all free to write an OPTIMAL ASSEMBLY code and hand optimize it.  )..I would like the compiler or the interface to do this for me
  • which is intuitive to program, i.e. when I am programming, I want to be thinking in terms of MY ALGORITHM rather than in terms of the control structures or data structures what the program has to offer ( as an example, if I am thinking about an algorithm to determine the similarity of two shapes, I would like to think in terms of intuitive terms such as curvature, norms etc and not in terms of foreach pixel in row , foreach pixel in col , etc..) .  (I know this is a conflicting to the above statement, meaning it is simply too much to expect the performance of a low-level language from such a high level system. But this may be A feasible solution.. give the user low level access as well, and allow the user to hand optimise sections of the code .. Say for example including sections of assembly code in the main code) .. I dont think a black box approach will comply this and hence this practically eliinates almost all closed source programming languages and packages…
  • (Obviously) I expect a LOT of others to use such a language..  this goes without saying. (Being a researcher I would not like to be put to the embarassing position of writing the drivers of whichever hardware I use, JUST because I am the first person in the world who is with this  DEVICE + ProgrammingLanguage combo and even if I am willing to write one, I should not be ALONE in the WORLD who does it  🙂 ).

AutoIt !

I am (actually was) an ardent fan of the Visual Studio programming environment, especially Visual Basic. I found that it reduced the job of creating GUIs to mere click and drag (dint realize it was making me lazy) . Initial codes for my toy-experiments were simple  enough to code. I took a few days to code them when I was in high school.

I was beginning to start automating my computer ( I personally do not like doing robo-jobs). As the complexity of the code started increasing (i.e. , as I wanted to perform larger number of simpler tasks), I realized I was spending more time searching for snippets of code on the internet to perform simple tasks such as displaying the taskbar icon or saving the environment variables to a .ini file and or saving a screenshot into a file (specifically .jpg file). I needed SIMPLE/QUICK-fixes for a relatively small jobs ( all I wanted is that the snippet be reliable ).

This was when I came across this utility called AUTOIT . ( I had earlier visited the page of AutoHotkey..). The syntax of AutoIT was very very close to that of Visual Basic. So I went through the AutoIt tutorial on youtube ( it took a few hours on a weekend to complete this series 🙂 ) . I have started using AutoIT now .. And I have created some cool applications.  And I dint think I will be able to ever assemble so many features into a single small yet powerful code. As a sample, my time-keeper application with automatic logging + .ini file exporter + taskbar icon + context-menus on the taskbar icon + timer + system-wide-hotkeys) application took me 130 lines 🙂 ( & yes this includes the comments too )..  Hoping to uploading the codes soon .. ( You can get my codes/project downloads at the download section of my HOMEPAGE)

THE Creative Commons Licence

Being an ardent fan of open-source software, I think it is one of the revolutionary ideas.. giving away things for free. Put in other words, maintaing a single copy of a thing which is accessible to ANYONE. I believe as it is stated in the Wiki Page, that the sum of human knowledge must be available to ANYONE, anywhere , free of cost 🙂

A nice quote I read ,( I do not I know the Author and I could not Google it up) ..

“A lot can be achieved if it does not matter who takes the credit “

And I JUST LOVE this page .. and have a copy of it ..( Just in case they loose the page 😛 )

Creative Commons Deed

This is a human-readable summary of the full license below.

You are free:

  • to Share—to copy, distribute and transmit the work, and
  • to Remix—to adapt the work

Under the following conditions:

  • Attribution—You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work.)
  • Share Alike—If you alter, transform, or build upon this work, you may distribute the resulting work only under the same, similar or a compatible license.

With the understanding that:

  • Waiver—Any of the above conditions can be waived if you get permission from the copyright holder.
  • Other Rights—In no way are any of the following rights affected by the license:
  • Notice—For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do that is with a link to http://creativecommons.org/licenses/by-sa/3.0/

Just exercising my right as the page says

“Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights “

OBVIOUSLY THE RULES IN THIS POST APPLIES TO THIS POST too

My Blog?

Hello World ..

So this is MY web log .. I will be putting up some wierd thoughts I have had. Thought I have to share it with the world ( I know the probability of this page being read among the estimated 109.5 million websites ( estimated a year back , that is 2009) and 1 Trillion unique URLs ( reported recently by Google ) in the WWW jungle is low..still I would like to give it a try
Some wierd-ities follow…. please bear with me .. 🙂

Broken Link !

Huh.. this is my second installation of WordPress.

The previous one got overwritten ( by me ), guess when I was exploring the files..

This is what I apparently did ..  as this blog puts it , I locked myself out after amending file path setting.

The solution was simple, edit the wp-config.php file and add these two lines of code :

[php]define(‘WP_HOME’,’http://ursite.com/wordpress’);

define(‘WP_SITEURL’,’http://ursite.com/wordpress’);[/php]

and then reload the page.. more about this on this page

Note that this is a hack ( a shortcut so to say ). To realize this goto your General settings in your admin panel , you will find that the WordPress address (URL) and the Site address (URL) are blurred. For a clean fix you will have to modify the database name in the WordPress website as given in this page

Hello world!

Hi .. this is my first post using WordPress . A test post ..

Thank You .. all those who created this fine piece of software..

I wanted to be able to access my codes, wherever I am. I am tired of synchronizing files across various PCs using USBs etc. and at last resorted to uploading them online. This way other ppl  who are interested in the same code can just use it.
I will be sharing my codes here .. Suggestions or Hacks are welcome 🙂