 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Hantra
Joined: 16 Aug 2006 Posts: 5
|
Posted: Wed Aug 16, 2006 2:24 pm Post subject: How many hotkeys per script? |
|
|
All:
Do you guys use multiple hotkeys per script? I'd like to have a single script for all my hotkeys if possible. Right now I'm doing that, and it's executing the next hotkey right after the one I use. Is it better to use a script for each key?
Thanks!
B |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Wed Aug 16, 2006 2:32 pm Post subject: |
|
|
I have a script, __Permanent.ahk, which is always active. It is not gigantic, but it has a good number of hotkeys and hotstrings, without problem.
I believe a good policy is to group the hotkeys by task: have a script from general tasks, like mine, perhaps one to play, one for work, whatever. Or just put everything there, if you don't want to remember to start each script. _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
Hantra
Joined: 16 Aug 2006 Posts: 5
|
Posted: Wed Aug 16, 2006 3:21 pm Post subject: |
|
|
So, is the key to running multiples, using the Return command at the end of each section?
This one tries to execute all of the ones below it when one is run:
| Quote: | #g::
Run www.google.com
#p::
Run iexplore.exe
Sleep, 2000
WinActivate, Home - Microsoft Internet Explorer
Click 731,48
#T::
Send Please open a ticket on this, and we'll take a look at it as soon as
possible.{Enter}{Enter}Thanks a lot!,{Enter}{Enter}
return
#s::
Run C:\SMSADMIN\bin\i386\sms.msc
Sleep, 9000
WinActivate, sms - [Systems Management Server]
Click 434,127,2
Sleep, 2000
Click 343,143,2
Sleep, 8500
Click 410,125,2
|
|
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Wed Aug 16, 2006 3:30 pm Post subject: |
|
|
| Hantra wrote: | | So, is the key to running multiples, using the Return command at the end of each section? | Exactly! Return marks the end of a hotkey script. _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
Hantra
Joined: 16 Aug 2006 Posts: 5
|
Posted: Wed Aug 16, 2006 3:41 pm Post subject: |
|
|
| Thanks Phil! I just started working on this today. |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Wed Aug 16, 2006 4:16 pm Post subject: |
|
|
OK, and actually, with the auto-execute section rule, it was not so obvious that code running falls through from hotkey to the next.
Another way, for one-line hotkeys, is to put the code on the same line as the hotkey:
| Code: | #g::Run http://www.google.com
#p::
Run iexplore.exe
Sleep, 2000
WinActivate, Home - Microsoft Internet Explorer
Click 731,48
Return
#T::Send Please open a ticket on this, and we'll take a look at it as soon as possible.{Enter 2}Thanks a lot!,{Enter 2}
#s::
Run C:\SMSADMIN\bin\i386\sms.msc
Sleep, 9000
WinActivate, sms - [Systems Management Server]
Click 434,127,2
Sleep, 2000
Click 343,143,2
Sleep, 8500
Click 410,125,2
Return | The last Return isn't really needed, but it is always a good idea to put it, to avoid forgetting it if you add a new hotkey...
Note: you might want to use WinWaitActive instead of Sleep. And if possible, avoid using Click, try using accelerators or keyboard shortcut instead, it is more reliable. _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
krunkosaurus
Joined: 25 Jul 2006 Posts: 15 Location: New York, New York
|
Posted: Wed Aug 16, 2006 6:03 pm Post subject: |
|
|
Here is a copy of my script that's always on. The beginning is just a quick reference. A few hotkeys like "#h::WinMinimize, A" and "#q::WinClose, A" are great because I work cross-platform and I can use the same shortcut keys to minimize, close, and hide windows:
| Code: | /*=================== List of Commands =========================
WinKey+d = Run Dreamweaver
WinKey+f = Run Firefox
WinKey+i = Run Internet Explorer
WinKey+l = Run Illustrator
WinKey+p = Run Photoshop
WinKey+s = Run starcarft
WinKey+w = Run Word
WinKey+t = Run Notepad
WinKey+h = Minimize active window
WinKey+q = Close active window
WinKey+1 = Open X:\
WinKey+2 = Open X:\[removed folder]
WinKey+3 = Open X:\[removed folder]
WinKey+4 = Open X:\[removed folder]
WinKey+0 = Open C:\[removed my script folder]
Searches (highlight word and...)
ctrl+shift+w = Seach word at wikipedia.com
ctrl+shift+d = Seach word at dictionary.com
ctrl+shift+g = Seach word at google.com
ctrl+shift+r = Seach word at thesaurus.com
Word shortcuts:
ml = [shortcut to my name]
dd = [shortcut to today's date]
*/ ;============================================================
;=================== LAUNCH SHORTCUTS ==========================
#s::Run %A_ProgramFiles%\Starcraft\StarCraft.exe
#f::Run %A_ProgramFiles%\Mozilla Firefox\firefox.exe
#i::Run %A_ProgramFiles%\Internet Explorer\IEXPLORE.EXE
#d::Run %A_ProgramFiles%\Macromedia\Dreamweaver 8\Dreamweaver.exe
#p::Run %A_ProgramFiles%\Adobe\Adobe Photoshop CS2\Photoshop.exe
#l::Run %A_ProgramFiles%\Adobe\Adobe Illustrator CS2\Support Files\Contents\Windows\Illustrator.exe
#w::Run %A_ProgramFiles%\Microsoft Office\OFFICE11\winword.exe
#t::Run %SystemRoot%\system32\notepad.exe
#h::WinMinimize, A
#q::WinClose, A
#1::Run X:\
#2::Run X:\[link removed here]
#3::Run X:\[link removed here]
#4::Run X:\[link removed here]
#0::Run C:\[my script folder link removed here]
; SHORTCUT TO OPEN SCRIPT
^8::
Edit, C:\Documents and Settings\User\Desktop\scripts\shortcuts.ahk
Return
; SHORTCUT TO SAVE AND RUN SCRIPT CHANGES
^9::
WinWait, shortcuts.ahk - Notepad,
IfWinNotActive, shortcuts.ahk - Notepad,
WinWaitActive, shortcuts.ahk - Notepad,
WinMenuSelectItem, shortcuts.ahk - Notepad, , File, Save
WinClose shortcuts.ahk - Notepad,
Run C:\Documents and Settings\User\Desktop\scripts\shortcuts.ahk
WinWait, shortcuts.ahk
WinWaitActive,shortcuts.ahk
ControlClick, &Yes, shortcuts.ahk
Return
;=================== LOOKUP SHORTCUTS ========================
; CTRL+SHIFT+w SELECTED TEXT TO SEACH IN WIKIPEDIA.COM
^+w::
Send, {CTRLDOWN}c{CTRLUP}
Run, http://en.wikipedia.org/wiki/Special:Search?search=%Clipboard%
Return
; CTRL+SHIFT+w SELECTED TEXT TO SEACH IN DICTIONARY.COM
^+d::
Send, {CTRLDOWN}c{CTRLUP}
Run, http://dictionary.reference.com/browse/%Clipboard%
Return
; CTRL+SHIFT+g SELECTED TEXT TO SEACH IN DICTIONARY.COM
^+g::
Send, {CTRLDOWN}c{CTRLUP}
Run, http://www.google.com/search?hl=en&lr=&q=%Clipboard%&btnG=Search
Return
; CTRL+SHIFT+r SELECTED TEXT TO SEACH IN THESAURUS.COM
^+r::
Send, {CTRLDOWN}c{CTRLUP}
Run, http://thesaurus.reference.com/search?q=%Clipboard%
Return
;========================= MISC ===============================
;==================== KEYBOARD SHORTCUTS ========================
::dd::
FormatTime, CurrentDateTime,, yyyy_M_d
SendInput %CurrentDateTime%
Return
; [My name] SHORTCUT
::ml::[My Name removed here]
; AUTO DATE AND TIME FOR NEW RARS
#IfWinActive Archive name and parameters
::aa::
FormatTime, CurrentDateTime,, yyyy_M_d
SendInput aa %CurrentDateTime%.rar
SendInput {END}{LEFT}{LEFT}{LEFT}{LEFT}
#IfWinActive
Return
; AUTO DATE
::$d::
FormatTime, CurrentDateTime,, yyyy_M_d
SendInput %CurrentDateTime%
Return
|
|
|
| Back to top |
|
 |
Guest
|
Posted: Wed Apr 16, 2008 5:47 pm Post subject: Re: How many hotkeys per script? |
|
|
| Hantra wrote: | | Do you guys use multiple hotkeys per script? |
We have a script that is always running with more than a hundred hotkeys linked to often-used tasks. The script file size ranges from 25 to 30K and we use it with XP and Vista. |
|
| Back to top |
|
 |
epconfig
Joined: 10 Oct 2007 Posts: 19 Location: Montreal, Canada
|
|
| Back to top |
|
 |
Hasso
Joined: 23 Mar 2005 Posts: 155 Location: Germany
|
Posted: Thu Apr 17, 2008 11:17 am Post subject: |
|
|
I have a main script with timers and some basic stuff and include the hotkeys written in separate scripts depending on purposes. So it's easier for me to maintain them. _________________ Hasso
Programmers don't die, they GOSUB without RETURN |
|
| Back to top |
|
 |
jak
Joined: 28 Feb 2006 Posts: 116
|
Posted: Thu Sep 25, 2008 9:16 pm Post subject: |
|
|
| my ahk file is 54 kb (with winxp) and probably about 60 hotkeys (no timers i think). It sometimes misses a hotkey when I type and i have to re-type. I'm thinking of breaking it into two files and running them simultaneously. dont know if that would improve performance or not. |
|
| Back to top |
|
 |
tkeoki
Joined: 07 Sep 2008 Posts: 6
|
Posted: Fri Sep 26, 2008 4:55 am Post subject: |
|
|
| The number of Hotkeys shouldn't affect performance much. I believe the hardcoded max is 700 hotkeys. I actually recompiled Autohotkey and made the limit 2000 for a test script and besides using a bit more memory, performance was just as good. |
|
| Back to top |
|
 |
hutch@edge.net
Joined: 16 Sep 2008 Posts: 40
|
Posted: Sat Sep 27, 2008 8:29 pm Post subject: |
|
|
If using multiple hotkeys in a script, this is a nice little utility. Just add it to the top of your script, and it will give you a ^z hotkey that shows all hotkeys and hotstrings in your script. It also give you a menu option when you right click on the AHK icon in the toolbar to show hotkeys.
| Code: |
;*******************************************************************************
; Extract a list of Hotstrings and Hotkeys from this script and display them
;*******************************************************************************
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
KeyList:
AutoTrim,off
Loop,Read,%A_ScriptFullPath%
{
Line=%A_LoopReadLine%
; Only show lines that contain double semicolons
IfInString,Line,`;`;
{
StringLeft,C2,Line,2
; Insert blank or comment lines (start with double semicolon)
IfEqual,C2,`;`;
{
StringTrimLeft,Desc,Line,2
KeyList=%KeyList%%Desc%`n
Continue
}
; Insert Hotkeys and Hotstrings (must contain double colon)
IfInString,Line,`:`:
{
; Extract description (after last semicolon)
StringSplit,Desc,Line,`;`:
StringTrimLeft,Desc,Desc%Desc0%,0
; If description is blank, use command or hotstring text instead
If Desc=
{
EnvSub,Desc0,2
StringTrimLeft,Desc,Desc%Desc0%,0
}
; Extract keys
StringSplit,Keys,Line,`:
; Hotstrings (start with double colon)
IfEqual,C2,`:`:
{
Keys=%Keys3%
IfEqual,Desc,,SetEnv,Desc,%Keys5%
}
; Hotkeys (start with anything else)
Else
{
StringReplace,Keys,Keys1,#,Win-
StringReplace,Keys,Keys,!,Alt-
StringReplace,Keys,Keys,^,Ctrl-
StringReplace,Keys,Keys,+,Shift-
StringReplace,Keys,Keys,`;,
}
; Add to the list
; Make keys 15 long with trailing spaces to keep the list neatly formatted
Keys=%Keys% !
StringLeft,Keys,Keys,15
Desc=%Keys% %Desc%
KeyList=%KeyList%%Desc%`n
; Keep track of longest line to set window width later
StringLen,Len,Desc
If Len > %MaxLen%
MaxLen = %Len%
}
}
}
; Now show the list
EnvMult,MaxLen,8.0 ; pixel width of 1 character
EnvAdd,MaxLen,20 ; + 2 x 10 pixel margins
StringTrimRight,KeyList,KeyList,1
; Sort, KeyList, P16 ; sort the comments
Progress, M2 C00 ZH0 FS10 W%MaxLen%,%KeyList%,,Hotkeys and Hotstrings list,courier new
KeyList=
MaxLen=
;****************************************************
;Add the List to the AHK Menu
;****************************************************
Menu,Tray,Add,Hot&keys list,KeyList
Menu,Tray,Default,Hot&keys list
Return
;****************************************************
;Add Hotkeys and Hotstrings Below
;****************************************************
;; HotKeys
^Z:: ;;Show This List
GoSub KeyList
KeyWait, z
Progress, off
return
^G:: ;;Launch Google
run IEXPLORE.exe http://www.google.com
Exit
^O:: ;;Launch MS Outlook
run outlook.exe
Exit
^X:: ;;Launch Excel
run Excel.exe
Exit
^W:: ;;Launch Word
run WINWORD.exe
Exit
^A:: ;;Launch AHK Forum
run IEXPLORE.exe http://www.autohotkey.com/forum/viewforum.php?f=1
Exit
^D:: ;;Toggle Desktop
Send, #d
Exit
^H:: ;;Clear Internet History (MSIE Active)
Run, RunDll32.exe InetCpl.cpl`,ClearMyTracksByProcess 1
Exit
^T:: ;;Clear Temp Files (MSIE Active)
Run, RunDll32.exe InetCpl.cpl`,ClearMyTracksByProcess 8
Exit
;;
;; HotStrings
::ed:: ;;Edit MM/DD by Jerry H.
Send, Edit %A_MM%/%A_DD% by Jerry H.
Exit
|
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|