AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Can you identify this script?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
TheNewGuy



Joined: 13 Nov 2009
Posts: 3

PostPosted: Fri Nov 13, 2009 2:47 pm    Post subject: Can you identify this script? Reply with quote

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
Back to top
View user's profile Send private message
doyle



Joined: 14 Nov 2007
Posts: 279
Location: London, England

PostPosted: Fri Nov 13, 2009 2:54 pm    Post subject: Reply with quote

Looks like this:

http://michalk.id.au/dox/soft/autotxt-1a-by-MichaelChalk-july08.ahk
Back to top
View user's profile Send private message Visit poster's website
hugov



Joined: 27 May 2007
Posts: 2181

PostPosted: Fri Nov 13, 2009 2:55 pm    Post subject: Reply with quote

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
_________________
Tut 4 Newbies
TF : Text file & string lib, TF Forum
Back to top
View user's profile Send private message Visit poster's website
doyle



Joined: 14 Nov 2007
Posts: 279
Location: London, England

PostPosted: Fri Nov 13, 2009 2:59 pm    Post subject: Reply with quote

doyle wrote:
Looks like this:

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


Maybe not.

BUt he has copied a large chunk of it. Laughing

I just googled.
Back to top
View user's profile Send private message Visit poster's website
TheNewGuy



Joined: 13 Nov 2009
Posts: 3

PostPosted: Fri Nov 13, 2009 4:18 pm    Post subject: Re: Can you identify this script? Reply with quote

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
Back to top
View user's profile Send private message
TheNewGuy



Joined: 13 Nov 2009
Posts: 3

PostPosted: Fri Nov 13, 2009 4:50 pm    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group