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 

Variable based Hotstring

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



Joined: 11 Aug 2004
Posts: 5390
Location: /b/

PostPosted: Sat Apr 23, 2005 4:50 pm    Post subject: Variable based Hotstring Reply with quote

The below code wouldn't make 'btw' a hotstring only '%var%'. Is it possible to make dynamic hotstrings with variables (hotkey isn't an option for what I'm doing).
Code:
var = btw
:*:%var%::by the way

_________________

Back to top
View user's profile Send private message Visit poster's website
jonny



Joined: 13 Nov 2004
Posts: 3004
Location: Minnesota

PostPosted: Sat Apr 23, 2005 7:33 pm    Post subject: Reply with quote

That's not possible yet but I understand that dynamic variables are a high priority. Expect it soon. Cool
Back to top
View user's profile Send private message
Titan



Joined: 11 Aug 2004
Posts: 5390
Location: /b/

PostPosted: Sat Apr 23, 2005 8:21 pm    Post subject: Reply with quote

Oh right, so it's a planned thing...

It would be useful to me because of a script I half made that makes ahk command hotstrings.
Script:
Code:
#Hotstring k-1
SetBatchLines -1
SetKeyDelay -1

IfNotExist, HotStrings.ini
{
   FileRead, CommandsList, %ProgramFiles%\AutoHotkey\Extras\Editors\Syntax\Commands.txt
   Loop, Parse, CommandsList, `n
      Count++
   IniWrite, %Count%, Hotstrings.ini, Main, Count
   Loop, Parse, CommandsList, `n
   {
      strc++
      IniWrite, %A_LoopField%, Hotstrings.ini, Strings, str%strc%
   }
}

IniRead, Count, Hotstrings.ini, Main, Count
Loop, %Count%
{
   strc++
   IniRead, curop, Hotstrings.ini, Strings, str%strcc%
   StringGetPos, defcharNum, %curop%, ~
   defcharNum++
   StringLen, curopLen, curop
   StringLeft, defchar, %curop%, (curopLen-defcharNum)
   ; THIS IS WHERE DYNAMIC HOTSTRINGS WOULD COME HANDY --->
   :*:%defchar%::%curop%
}

Example:
Hotstrings.ini wrote:
str155=SendMessage, Msg [, wParam, lParam, Control, WinTitle, WinText, ExcludeTitle, ExcludeText]~smg

In the above example, typing smg would abbreviate the full command. Yeah Rajat's IntelliSense is also fantastic for the job but i planned to add a few more features to make a lazymans life a whole lot easier.
_________________

Back to top
View user's profile Send private message Visit poster's website
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Sat Apr 23, 2005 11:44 pm    Post subject: Reply with quote

jonny wrote:
That's not possible yet but I understand that dynamic variables are a high priority.
Well, dynamic commands are on the to-do list. But making things like labels, hotstrings, and function names dynamic tends to add a lot of complexity to the code, and takes a long time to design properly.

The best bet for now is to have the script create a second script (via FileAppend) containing the dynamic hotstrings, and then have the first script launch the second.
Back to top
View user's profile Send private message Send e-mail
skrommel



Joined: 30 Jul 2004
Posts: 181

PostPosted: Sun May 08, 2005 12:26 am    Post subject: A possible solution? Reply with quote

How about this solution?

http://www.autohotkey.com/forum/viewtopic.php?t=3476

Skrommel
Back to top
View user's profile Send private message Visit poster's website
valenfor



Joined: 26 Feb 2005
Posts: 20

PostPosted: Mon Jul 25, 2005 5:21 am    Post subject: Dynamic hotstrings.... Reply with quote

OK, I have followed all the threads on this subject, but just want to confirm plainly for my own stupidity that the only way to do this with a distributed EXE program is to include the compiler and have it recompile a second script?

Meaning, I compile my main script as an EXE.

Let the person create their hotstrings with that first EXE, and save it to a file properly formatted as a AHK script.

Then recompile that AHK script (or my main program with new hotstrings) in place.

---- OR ----

If I have a compiled AHK script, can it call a non-compiled script even if AHK isn't installed on the machine? I do understand that when you compile the script it does copy in some of the machine code, but again....

Further, if I do want to recompile the script, do I need just whats in the compiler directory or do I need the base Autohotkey.exe as well as the psapi.dll?

Just want to make sure I have this right before I finish this next feature I am doing.

Thanks,

V
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Mon Jul 25, 2005 11:18 am    Post subject: Re: Dynamic hotstrings.... Reply with quote

valenfor wrote:
Further, if I do want to recompile the script, do I need just whats in the compiler directory or do I need the base Autohotkey.exe as well as the psapi.dll?
I think you need only the compiler directory, but you should test it first to be sure. The psapi.dll file is needed only when running scripts on NT4 (it supports the Process command).

One thing that might be of use is that there is generally no need to compile a hotstring script. Instead (when the target machine doesn't have AutoHotkey installed), it would probably be easier just to copy AutoHotkey.exe into the same directory as the script and run it the .ahk file with it:

SetWorkingDir C:\Hotstring Scripts
Run AutoHotkey.exe "Hotstring Script.ahk"
Back to top
View user's profile Send private message Send e-mail
Guest






PostPosted: Sun Apr 08, 2007 5:17 pm    Post subject: Re: Dynamic hotstrings.... Reply with quote

Chris wrote:
it would probably be easier just to copy AutoHotkey.exe into the same directory as the script and run it the .ahk file with it


I think this is a problem when you want to distribute your compiled script under a non-GPL license.

Would it be possible to include dynamic hotstrings (not entirely dynamic code) just like dynamic hotkeys? With a HotString command similar to the HotKey command, one could define labels containing the hotstring action.

Chris, this would be a great feature and I think many of us would actually use it (given the popularity of this thread an all the AutoReplace scripts).
Back to top
engunneer



Joined: 30 Aug 2005
Posts: 6847
Location: Pacific Northwest, US

PostPosted: Sun Apr 08, 2007 6:12 pm    Post subject: Re: Dynamic hotstrings.... Reply with quote

Anonymous wrote:

I think this is a problem when you want to distribute your compiled script under a non-GPL license.


This is not a problem as long as the non-GPL code says it is using a GPL component (without modifications) and where to get the GPL component. At a minimum it's the least that should be done when sharing Chris' awesome work to point people to it.

Chris,
correct me if I am misinterpreting the GPL here, but I think that's all I need to do to distribute Autohotkey.exe with my non-GPL script?
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Wed Apr 11, 2007 3:46 pm    Post subject: Reply with quote

I think that's fine, though I'm not an expert on the fine points of the GPL. Actually, it doesn't bother me if AutoHotkey is distributed without attribution/credit. But since it might matter to the other authors whose GPL code is used in AutoHotkey, it's best to make a reasonable effort to conform to the GPL when distributing AutoHotkey.exe.

As for dynamic hotstrings, I'd like to see that feature too. I don't know exactly how much work is involved, but hopefully I or someone else will get to it eventually.
Back to top
View user's profile Send private message Send e-mail
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