AutoHotkey scripts for developers

来源:互联网 发布:为啥mac叫热辣的塔希提 编辑:程序博客网 时间:2024/04/27 03:08

0

http://codeimpossible.com/2010/11/01/autohotkey-scripts-for-developers/
Posted November 1st, 2010 in Blahg and tagged autohotkey, tools by Jared

This week I’ll post some useful AutoHotKey scripts that I use to make every-day coding easier.


If you’re not familiar with AutoHotKey yet, I’ve blogged about it before and I would recommend giving that post a read. For the rest of you I thought I would post some useful AHK scripts that I have come across.

The most important AHK script ever. 
Disabling Caps-lock. I constantly fat-finger the caps-lock button. With this script, I never have to worry about it again.

SetCapsLockState, AlwaysOff

 

Generate a “safe” jQuery code block
This script will generate a self-calling anonymous function that scopes jQuery and protects your code from other possible interference from other javascript frameworks. You can read more about it here.

;insert a self-calling anonymous method to scope jQuery calls:*R0:{jqsafe}::((function($) {{}    $(function() {{}    // ...code to run on dom ready{Left}{Left}{Left}{Left}{}});`n{}})(jQuery);)return

 

Include jQuery from the Google CDN
This script will turn {jqgoog#.#.#} into a <script> tag pointing to that version of jquery, specified by the #.#.#, hosted on googles cdn.

{jqgoog1.4.2} will become: Line breaks added for readability


<script
type=”text/javascript”
src=http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js></script>

{jqgoog1} will become: Line breaks added for readability


<script
type=”text/javascript”
src=http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js></script>
; Include jQuery from google cdn~{::Input, UserInput, I V L13 C, {}}, jqgoog*,if ErrorLevel = NewInput    returnTest := InStr( UserInput, "jqgoog" )Len := StrLen( UserInput ) + 2if Test > 0:{jqVer := RegExReplace( UserInput, "jqgoog", "" )SetKeyDelay, -1  ; Most editors can handle the fastest speed.Loop %Len%{Send, {backspace}}Send, <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/%jqVer%/jquery.min.js"></script>    return}return

Automate writing simple database connection code in C#
This script will turn {atwood} into a block of C# that can connect to a database and issue a query.

:*R0:{atwood}::(var connString = ConfigurationManager.ConnectionStrings["connection"].ConnectionString;var query = @"";using(var conn = new SqlConnection(connString)){{}    conn.Open();using( var cmd = new SqlCommand( query, conn ) ){{}{}}{Left}{}})return

Here’s the output:


var connString = ConfigurationManager.ConnectionStrings["connection"].ConnectionString;
var query = @"";
using(var conn = new SqlConnection(connString))
{
    conn
.Open();
   
using( var cmd = new SqlCommand( query, conn ) )
   
{

   
}
}