Welcome Guest.   Make a donation to an author on the site September 02, 2014, 01:57:05 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Read the Practical Guide to DonationCoder.com Forum Search Features
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: Beginner Autohotkey question(s)  (Read 2268 times)
tranglos
Supporting Member
**
Posts: 1,079



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« on: November 22, 2007, 08:15:01 AM »

...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
« Last Edit: November 22, 2007, 11:33:38 AM by tranglos » Logged

lanux128
Global Moderator
*****
Posts: 6,088



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #1 on: November 22, 2007, 06:54:57 PM »

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)

[copy or print]
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

Logged

tranglos
Supporting Member
**
Posts: 1,079



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #2 on: November 22, 2007, 07:03:18 PM »

hi marek,
this is how i will do, for the 1st q:

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:

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
Logged

lanux128
Global Moderator
*****
Posts: 6,088



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #3 on: November 22, 2007, 09:38:10 PM »

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

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. smiley

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

Logged

Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.036s | Server load: 0.14 ]