Hi,
Just installed AutoHotkey a few days ago and like it a lot. Thanks Chris!
There are several questions that I haven't been able to find an answer to.
Perhaps someone here or Chris can help?
I've written two scripts so far:
1) GUI interface for SC.EXE to install an executable as a service
2) Hotkey-Mapping script for my Desktop Icons as Win2K's icon "Shortcut Keys" often do not work reliably. I'm launching the shortcuts and not the executables because that way I can control some things from the Icon Properties box and I like to have these icons on my Desktop anyway and have them work the same way whether I hotkey them or double-click them.
The code for both is included after the questions.
------------------------------------------------------------------
1) Passing Double-Quotes to Programs
This may be more of a Windows problem than AutoHotkey, but I've had a devil of a time passing quotation marks (standard double-quote) to windows programs, particularly 16 bit programs that run in the command prompt window. Seems windows strips them all out. The cmd /c option works if the passed argument is an executable and the command is part of the native cmd environment, otherwise not.
I found this in the case of my script for the "Run As a Service" GUI. When I passed the path to the executable for the service enclosed in double-quotes (because the path contains spaces) to instsrv.exe or sc .exe (MS Resource Kit Utils to Add Services), the quotes would invariable get stripped out leaving a registry entry without the quotes and which would not run.
I tried using two-double-quotes, single-quotes around double-quotes, and all failed. Even using the command shell with cmd /c failed to resolve this.
So my GUI only handles service names and paths to executables with no spaces in them, which works cause most should reside in \winnt\syustem32 or the equivalent anyway.
As the AutoHotkey compiler does not treat quotes as special characters, I'm assuming that this isn't really a problem with the scripting language, but any ideas would certainly help!
Any Ideas?
2) Run <> Windows Run for Special Shortcuts
The AutoHotkey "Run" command does not seem to be exactly equivalent to the Windows Run box in at least this way:
MS Office-creates special "Windows Installer" shortcuts which are the preferred method of running Excel, Word, Outlook, etc. The problem is that these are not standard shortcuts but actually calls to a Microsoft component. See:
http://support.microsoft.com/default.as ... -us;243630
I can put the \path\shortcut.lnk to these special shortcuts into the Start Menu/Run box or a Command box (which I eventually did in my script) and they launch the program without problem.
The AutoHotkey "Run" command, however, will not launch them. I think I tried RunWait also, but not sure.
Any Ideas?
3) Running a Compiled Script as a Service
After I was able to successfully install my compiled hotkeys script as a service, I was still not able to get it to run from the "Services" MMC or on Reboot. It comes back with a timeout message that the service did not respond.
Any ideas?
4) No String Manipulation Commands?
In an effort to fix the double-quotes problem mentioned earlier, I searched for commands, either in AutoHotkey or the Windows cmd environment to operate on strings so that I could add the double-quotes inside the variables I was passing, instead of on the outside. Something like "Concatenate(X,Y,Z...)" etc.. But while I found logical operators for strings, I could not find any for text manipulation.
Any Ideas?
5) No Variable "Assignment" Operator?
In searching for String Commands I was also not able to find any kind of "Variable Assignment" operator such as: Service_Name := "Hotkeys" where := loads the string “Hotkeys” into the variable Service_Name
Any Ideas?
6) Hotkeys "Sticking"
Biggest problem with my current hotkeys script is that, at times, the modifiers for my Hotkeys seem to "stick" in that after I run one of my hotkeys, specifically the one that is “<Left Ctrl><Left Alt>-“ which launches a Saved Search, the <Ctrl> and <Alt> buttons seems to "stick" in that as I next type letters into the search box, all of my Hotkeys that correspond to those letters begin to launch, as if I still had the <Ctrl> and <Alt> keys held down.
If I close the original Hotkey that caused the problem I run it again later, the problem does not recur.
BTW that's a "minus sign" as the hotkey that's modified above and, I did check to make sure that Windows Accessibility "Sticky Keys" weren’t enabled.
Any Ideas?
------------------------------------------------------------------
HERE ARE THE TWO SCRIPTS REFERRED TO:ABOVE:
1) HOTKEYS.AHK
;Hotkeys Mapping of Desktop Icons
<^<!-::Run, "C:\Documents and Settings\user\Desktop\Find Favorites.lnk"
<^<!.::Run, "C:\Documents and Settings\user\Desktop\Show Desktop.lnk"
<^<!/::Run, "C:\Documents and Settings\user\Desktop\Programs.lnk"
<^<!c::Run, "C:\Documents and Settings\user\Desktop\Close All Open Windows.lnk"
<^<!d::Run, "C:\Documents and Settings\user\Desktop\Downloads.lnk"
<^<!e::Run, cmd /c "C:\Documents and Settings\user\Desktop\Microsoft Excel.lnk", , Hide
<^<!f::Run, "C:\Documents and Settings\user\Desktop\Find Documents.lnk"
<^<!g::Run, "C:\Documents and Settings\user\Desktop\Genealogy Files.lnk"
<^<!i::Run, "C:\Documents and Settings\user\Desktop\Internet Explorer.lnk"
<^<!l::Run, "C:\Documents and Settings\user\Desktop\Legacy 4.0.lnk"
<^<!m::Run, "C:\Documents and Settings\user\Desktop\My Documents.lnk"
<^<!n::Run, "C:\Documents and Settings\user\Desktop\New Project.lnk"
<^<!o::Run, cmd /c "C:\Documents and Settings\user\Desktop\Microsoft Outlook.lnk", , Hide
<^<!p::Run, "C:\Documents and Settings\user\Desktop\Psion Manager.lnk"
<^<!q::Run, "C:\Documents and Settings\user\Desktop\Quicken 2004.lnk"
<^<!s::Run, "C:\Documents and Settings\user\Desktop\Find Downloads.lnk"
<^<!v::Run, "C:\Documents and Settings\user\Desktop\Favorites.lnk"
<^<!w::Run, cmd /c "C:\Documents and Settings\user\Desktop\Microsoft Word.lnk", , Hide
2) RUN AS A SERVICE.AHK
;Install an Executable as a Service.
;This Script Requires the Windows Resource Kit utility SC.EXE to be in your path, preferably the C:\winnt\system32 directory or equivalent.
MsgBox, 1, , This Utility Does Not Support Installing Service Names or Paths with Spaces in Them. Do You Want to Continue?
IfMsgBox, Cancel, Exit
InputBox, Service_Name, , Please Enter The Service Name
If ErrorLevel=1, Exit
FileSelectFile, Service_Executable, , C:\WINNT\System32, Please Select The Service Executable, *.exe
If ErrorLevel=1, Exit
Run, SC create %Service_Name% type= interact Start= Auto binpath= %Service_Executable% DisplayName= %Service_Name%