trids Posted April 26, 2006 Share Posted April 26, 2006 Here is a simple scriptlet that has proven quite popular with my colleagues, which takes an arithmetic expression and returns the answer. It needs the Beta as it rdepends entirely on the new Execute() function ..expandcollapse popup;TridsCalc.au3 - a calculator addin for text editors ; ;Only works with betas after 3.1.1 ;Only works with betas after 3.1.1 ;Only works with betas after 3.1.1 ; ;Run options ; 1. Call this EXE ; 2. Call this EXE with an exp[b][/b]ression in the clipboard. ; 3. Setup a tool in Textpad to call the EXE, passing the selection as an exp[b][/b]ression in the commandline ; ;Sample exp[b][/b]ressions ; 2 + 3 * 5 ; 2+3*5 ; (2+3)*5 ; 2 ^ 3 ; 2 ^ 0.5 ; 1.23 ; random() * 10000 ; abs(8-23) ; Mod(22,8) ; Log(1000) / Log(10) ; 0x1A ; hex(2006) If $CmdLineRaw = "" Then ;No commandline, so try the clipboard $sX = ClipGet() Else $sX = $CmdLineRaw Endif While 1 $sX = InputBox( @SCRIPTNAME & " - 1.1", "Exp[b][/b]ression:", $sX, "", 300,120 ) If @ERROR Then EXITLOOP $asX = StringSplit( $sX, "=" ) $sX = StringStripWS( $asX[1], 3 ) $nX = Execute( $sX ) ;<--- this is only available in betas after 3.1.1 $sx = $sX & " = " & $nX WendTo integrate with TextPad..Compile the script and save the resulting EXE to somewhere like your C:\Winnt\System32\ folder.Create a TextPad tool that executes the EXE, and pass along a commandline parameter of $Sel (which TextPad replaces with the text that you have selected at runtime).Assign a keyboard shortcut to the tool .. we use CTRL-/.Now you can select a formula / expression in a TextPad document, and press your shortcut combination to evaluate it.Have fun Link to comment Share on other sites More sharing options...
ptrex Posted April 26, 2006 Share Posted April 26, 2006 @TridsThis looks a lot to my Dynamic Functions Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
trids Posted April 26, 2006 Author Share Posted April 26, 2006 Yes, there are similarities .. but I'd say the main difference is that this one is aimed at being a minimalistic addin for TextPad: no GUI stuff, except for the InputBox. Thanks for the feedback. I must take a closer look at Au3's GUI features sometime when time allows. Link to comment Share on other sites More sharing options...
Simucal Posted May 8, 2006 Share Posted May 8, 2006 A feature I think you should have is a hotkey that will Copy whatever text you have selected and replace it with the calculated answer. So lets say I'm in some application and I have "1+1" highlighted, have it do a Ctrl-C, ClipGet, execute it, then replace the text. That way people could run the script.. and as they were in various documents they could highlight an equation and hit a hotkey and viola.. instant answer. AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc) Link to comment Share on other sites More sharing options...
trids Posted May 23, 2006 Author Share Posted May 23, 2006 Nice idea Simucal .. but it might be better to leave the answer in the InputBox display. The CTrL+C and execute is cool, but pasting it back is not always possible: imagine that you select text from a browser window, for example -- you can't paste the answer back into it! Still, the Copy-Execute is a nice idea .. give it a go Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now