AutoHotkey Community

It is currently May 27th, 2012, 11:38 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: November 13th, 2009, 3:47 pm 
Offline

Joined: November 13th, 2009, 3:13 pm
Posts: 3
Hi,

I'm new and stupid. I cut and pasted some code into the AutoHotkey.ahk file and have no idea what the name of the original script was. I like it and wanted to ask questions about modifying it, but, don't know the name. I almost think I grabbed it out of the help file. Here it is:

Code:
#h::  ; Win+H hotkey
; Get the text currently selected. The clipboard is used instead of
; "ControlGet Selected" because it works in a greater variety of editors
; (namely word processors).  Save the current clipboard contents to be
; restored later. Although this handles only plain text, it seems better
; than nothing:
AutoTrim Off  ; Retain any leading and trailing whitespace on the clipboard.
ClipboardOld = %ClipboardAll%
Clipboard =  ; Must start off blank for detection to work.
Send ^c
ClipWait 1
if ErrorLevel  ; ClipWait timed out.
    return
; Replace CRLF and/or LF with `n for use in a "send-raw" hotstring:
; The same is done for any other characters that might otherwise
; be a problem in raw mode:
StringReplace, Hotstring, Clipboard, ``, ````, All  ; Do this replacement first to avoid interfering with the others below.
StringReplace, Hotstring, Hotstring, `r`n, ``r, All  ; Using `r works better than `n in MS Word, etc.
StringReplace, Hotstring, Hotstring, `n, ``r, All
StringReplace, Hotstring, Hotstring, %A_Tab%, ``t, All
StringReplace, Hotstring, Hotstring, `;, ```;, All
Clipboard = %ClipboardOld%  ; Restore previous contents of clipboard.
; This will move the InputBox's caret to a more friendly position:
SetTimer, MoveCaret, 10
; Show the InputBox, providing the default hotstring:
InputBox, Hotstring, New Hotstring, Type your abreviation at the indicated insertion point. You can also edit the replacement text if you wish.`n`nExample entry: :R:btw`::by the way,,,,,,,, :R:`::%Hotstring%
if ErrorLevel  ; The user pressed Cancel.
    return
IfInString, Hotstring, :R`:::
{
    MsgBox You didn't provide an abbreviation. The hotstring has not been added.
    return
}
; Otherwise, add the hotstring and reload the script:
FileAppend, `n%Hotstring%, %A_ScriptFullPath%  ; Put a `n at the beginning in case file lacks a blank line at its end.
Reload
Sleep 200 ; If successful, the reload will close this instance during the Sleep, so the line below will never be reached.
MsgBox, 4,, The hotstring just added appears to be improperly formatted.  Would you like to open the script for editing? Note that the bad hotstring is at the bottom of the script.
IfMsgBox, Yes, Edit
return

MoveCaret:
IfWinNotActive, New Hotstring
    return
; Otherwise, move the InputBox's insertion point to where the user will type the abbreviation.
Send {Home}{Right 3}
SetTimer, MoveCaret, Off
return


; Note: From now on whenever you run AutoHotkey directly, this script
; will be loaded.  So feel free to customize it to suit your needs.

; Please read the QUICK-START TUTORIAL near the top of the help file.
; It explains how to perform common automation tasks such as sending
; keystrokes and mouse clicks.  It also explains more about hotkeys.
:R:btw::by the way
:R:admin::Administrator
:R:stu::Student
:R:db::Database


Once it is identified, I want to know if there is a way to put the shortcuts in a separate file so that the script can be compiled into an exe, but the "configuration" can be in a plain text file.

Sorry for the stupidity, but Thanks!!

Bill


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2009, 3:54 pm 
Offline

Joined: November 14th, 2007, 2:47 pm
Posts: 335
Location: London, England
Looks like this:

http://michalk.id.au/dox/soft/autotxt-1a-by-MichaelChalk-july08.ahk


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2009, 3:55 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
Yes, this comes from the help file. What you want has been done already.

Use shortcut text realtime
http://www.autohotkey.com/forum/topic86.html

Also look at Normands' script which reads abbreviations from
an ini file which can be edited via a nice gui (catena) for some
inspiration http://normandlamoureux.com/catena/telechargement.html
It is french but you can download English INI

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2009, 3:59 pm 
Offline

Joined: November 14th, 2007, 2:47 pm
Posts: 335
Location: London, England
doyle wrote:


Maybe not.

BUt he has copied a large chunk of it. :lol:

I just googled.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: November 13th, 2009, 5:18 pm 
Offline

Joined: November 13th, 2009, 3:13 pm
Posts: 3
OK, Thanks everyone... found it. It's the "Hotstrings Helper" code:


http://www.autohotkey.com/docs/Hotstrings.htm


I'll look at the other links that you all posted. Thanks for the quick reply!

- Bill


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2009, 5:50 pm 
Offline

Joined: November 13th, 2009, 3:13 pm
Posts: 3
HugoV wrote:
Also look at Normands' script which reads abbreviations from
an ini file which can be edited via a nice gui (catena) for some
inspiration http://normandlamoureux.com/catena/telechargement.html
It is french but you can download English INI


This was what I really needed. Thank you HugoV!


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: MSN [Bot] and 16 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group