ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

Beginner Autohotkey question(s)

(1/1)

tranglos:
...because where else would I go? :)

1. I am using AHK only for text expansion (hotstrings) right now. Is there a way to add hotstrings to the automatically executed script and have them picked up without manually clicking "Reload" in the tray icon? It would be perfect if AHK were monitoring the script file for changes, I suppose.
[Edit] Never mind, I've found the Edit and Reload commands. Now if only I could tell the Edit command to open the script in TextPad instead of Notepad...

2. Is there a way to trigger a hotstring (or another similar feature) using selected text, rather than typing? E.g. when I encounter a term in a document I am translating, I would like to select the text and have it replaced with a translation, defined in AHK script. (For example, with hotstrings I have to type "Control Panel" to get the translation. I would like to select "Control Panel" instead, press a key and have the translation pasted in.)

Thanks!
.marek

lanux128:
hi marek,

this is how i will do, for the 1st q:
you can either associate .AHK with TextPad with the registry (see the example)


--- ---REGEDIT4

[HKEY_CLASSES_ROOT\.ahk]
@="AutoHotkeyScript"

;Set notepad as the default AutoHotkey editor
[HKEY_CLASSES_ROOT\.ahk\shell\Edit]
@="Edit"

[HKEY_CLASSES_ROOT\.ahk\shell\Edit\command]
@="C:\\WINDOWS\\System32\\notepad.exe \"%1\""
or use the "Run" command like this:
Run, <edit program> "%A_ScriptFullPath%"

2nd q:
you can use SetTimer to monitor if there are any selected text and run a routine from there but normally AHK requires a keyboard or mouse intervention to trigger an action. and also have a look at this script as an example:

• Tool tip dictionary

tranglos:
hi marek,
this is how i will do, for the 1st q:
-lanux128 (November 22, 2007, 06:54 PM)
--- End quote ---

Thanks!

you can use SetTimer to monitor if there are any selected text and run a routine from there but normally AHK requires a keyboard or mouse intervention to trigger an action. and also have a look at this script as an example:
-lanux128 (November 22, 2007, 06:54 PM)
--- End quote ---

Oh, I do want to trigger this manually. I may not have explained it fully. Standard hotstring operation is that you type "btw", and ahk gives you "By the way", as it is monitoring your keypresses. I would like to be able to select the text "btw", press a hotkey, and get "By the way". So the difference is I would not be typing b-t-w myself, since it's already in the document.

Since the operation could go via clipboard (as a last resort, but I could live with that), and I can assign clipboard contents to a variable, the only thing I'm missing is the ability to tell Ahk, in a script, to "expand this variable as if it were a hotstring I've just typed".

marek

lanux128:
Oh, I do want to trigger this manually. I may not have explained it fully. Standard hotstring operation is that you type "btw", and ahk gives you "By the way", as it is monitoring your keypresses. I would like to be able to select the text "btw", press a hotkey, and get "By the way". So the difference is I would not be typing b-t-w myself, since it's already in the document.

Since the operation could go via clipboard (as a last resort, but I could live with that), and I can assign clipboard contents to a variable, the only thing I'm missing is the ability to tell Ahk, in a script, to "expand this variable as if it were a hotstring I've just typed".

marek-tranglos (November 22, 2007, 07:03 PM)
--- End quote ---

ok, i see now.. this would be useful in a "spell-checker" mode, normally in this case, as you mentioned AHK would store the selected text in the clipboard variable and use an array containing an existing list to check against.. it didn't occur to me before & now i'm also looking forward to a solution this other than the clipboard method. :)

here is a link to the Hotstrings and Auto-replace documentation..

Navigation

[0] Message Index

Go to full version