Here's a new version (SearchInterface V3.ahk) that includes features requested by Shem: removal of leading and trailing white space; and by RZ: support for translation dictionary QuickDic (hold Alt and do a triple-tap on Right Shift).
It also includes a new labour-saving feature that's useful when researching something. Highlight the text you want in a document or browser and do Ctrl-Alt-F7 (or triple-tap Right-Shift). The text is copied to clipboard, but formatted neatly, and with date and time, title of the source window, and the url (if it's a web-page and if using Opera or IE7). You can then paste it into a document.
Here's an extract from the first post in the thread which I copied automatically from Opera using the new feature:
--------------
Date copied: 24-02-2010 at 16:10.
Source: "Multiple Key-Taps Send Selected Text to 3 Search Programs".
Website:
http://www.autohotkey.com/forum/post-33 ... 262e939994.
"Now I just highlight what I want to search for and then either:
1. Double-tap the right-hand Shift key to search Google.
2. Double-tap the right-hand Control key to search the computer using 'Everything'."
--------------
I've also changed the script so that double-tap on Right Shift now sends the search term to Run instead of directly to Google. If Run doesn't recognise it, the Google search goes ahead. So you can highlight a url or a path in any document and activate it with a double-tap on RSHift. Now, to get the original behaviour, you have to hold down Alt while doing the double-tap on Right Shift.
The actual assignments of functions to hot keys are defined in the section 'Multiple-Tap Assignments'. Just swap them around to suit your own preference.
Code:
;;;;;;;;;;;;;;;;;;
; Title: SearchInterface V3.ahk
; Author: DAT 05-12-2008
; AutoHotkey Version: 1.0.48.03
; Platform: Tested on XP and Vista
/*
23-02-2010 Changes from V2
New feature 1: Copy Text When Researching:
Triple-tap Right Shift (or do Ctrl-Alt-F7) to copy highlighted text. The text is formatted
neatly, combined with date and time, title of the source window, and url (if it's a web-page
and if using Opera or IE7). The result goes into the clipboard ready for pasting into a
document when you're researching something.
New feature 2: Support for QuickDic dictionary software:
Triple-tap on RightShift while holding down Alt sends a highlighted word to
the dictionary which translates it. Repeat to close the dictionary window.
Improvements over V2:
1. Search terms are processed to remove leading and trailing spaces and multiple empty
lines, and to replace multiple spaces with single spaces. Also spaces surrounding
a backslash are removed (as with a path split between two lines).
2. Double-tap on Right Shift now sends the search term to Run instead of directly
to Google. If Run doesn't recognise it, it goes into a Google search. Thus a
url, path, executable file, or system verb, will be executed directly but
anything else will go into the search. (See Autohotkey Help for details of
the Run command).
3. To go directly to a Google search, do the same as (2) while holding down Left Alt.
4. The script now uses the false alarm-resistant version of Rapidhotkey published
on 19-09-2009 by Hotkeyit (http://www.autohotkey.com/forum/viewtopic.php?t=38795).
*/
; 15-09-2009 Modified as follows:
;
; 1. Added anti-false alarm modifications for RapidHotkey() to as described by DAT at
; http://www.autohotkey.com/forum/viewtopic.php?t=38795&highlight= in 15-09-2009 post.
; 2. Added support for Locate32 via triple-tap on Right-Control key.
; 3. Single value for all multi-tap keys stored in ClickDelay.
; 28-08-2009 Modified as follows:
; 1. Rapid double-tap on RControl activates Everything to search on highlighted text.
; Do it again without changing the highlighting, and Everything minimises to tray.
; 2. Rapid double-tap on LControl activates Copernic to search on highlighted text. Do
; it again without changing the highlighting, and Copernic minimises to Task Bar.
; Rapid triple-tap on LControl minimises Copernic to tray and clears search box.
; 3. Uses 24.02.2009 version of RapidHotkey by HotKeyIt
; (http://www.autohotkey.com/forum/viewtopic.php?t=38795)
; Double-tapping right-hand Shift key searches for highlighted text using Google.
; If nothing was selected, the search windows open up ready for typed input.
; Note 1. 'Everything' does lightning fast searches of paths and filenames on the host
; computer, see http://www.voidtools.com for download and details. (I've no connection,
; I just find it extremely useful).
; Note 2. I use Copernic Desktop Search ver 2.3 Build 30. Several useful features
; were removed from later free versions and now are only in the paid version.
; Note 3: Set Copernic to open on your choice of hotkey (via /Tools/Options/Integration).
; Default is Windows Key + c. Enter the same hotkey into subroutine 'SearchCopSelected'
; below. (In AutoHotKey 'Win+c' is entered as '#c').
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
#SingleInstance , Force
SetBatchLines, 10ms
ClickDelay = 0.4 ; Max delay between each key-press. Adjust this to suit typing speed.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Multiple-Tap Assignments.
;
; Edit this section to alter the command assignments to what you prefer.
;
; Key::RapidHotkey("keystrokes" ;Enter keystrokes here. E.g.: "^o"
; , times ;optional. How often the key must be pressed to execute. E.g.: 3
; , delay ;optional. How quick the key must be pressed to execute. E.g.: 0.2
; , IsLabel) ;optional. specify 1 to indicate that parameter 1 is a label.
~LControl::RapidHotkey("SearchCopSelected""CloseCop",2,ClickDelay,1)
; 2 clicks = Searches Copernic for selected text. Repeat to minimise to Task Bar
; 3 clicks = Closes Copernic if minimised, and starts it minimised if not running.
~RControl::RapidHotkey("SearchEverything""SearchLocate32",2,ClickDelay,1)
~LControl & RShift::RapidHotkey("SearchEverything""SearchLocate32",2,ClickDelay,1) ; useful if no RControl key (eg Toshiba Libretto U100).
; 2 clicks = Searches Everything for selected text. Repeat to minimise to Task Bar
; 3 clicks = Searches Locate32 for selected text. Repeat to minimise.
~RShift::RapidHotkey("GoogleSelectedText""CopyToClipBoard" ,2,ClickDelay,1)
; 2 clicks = Searches Google for selected text, but tries Run command first.
; 3 clicks = Sends selected text to clipboard with source and date
~!RShift::RapidHotkey("ForceGoogle""QuickDic",2,ClickDelay,1)
; 2 clicks = Does Google search without trying Run command first.
; 3 clicks = Sends selected text to QuickDic translation program
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;
ProgressBox(Message)
{
xloc := A_ScreenWidth - 600 ;Calculate x coordinate of Progress window
yloc := A_ScreenHeight - 200 ;Calculate y coordinate of Progress window
Progress, B1 x%xloc% Y%yloc% M zh0 w300 h25 c00, %Message% , ; Defines Progress window
Return
}
;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;
; Search for selected text using Google. URLs are looked up directly, local paths
; are opened, anything that RUN doesn't recognise is used in a Google search.
; If nothing selected, it opens Google News.
GoogleSelectedText:
SearchG := Reformat_String(Get_Selected_Text())
StringLeft , SearchG , SearchG , 100 ; reduce to <= 100 characters
If SearchG is space
{
Run , http://news.google.co.uk/ ; or whatever you want.
Return
}
Run, %SearchG%, , UseErrorLevel
If (ErrorLevel) ; Do Google search if search string not recognised by Run
Run , http://www.google.com/search?q=%SearchG%&ie=utf-8&oe=utf-8
Return
; This subroutine does a Google search directly immediately without trying Run first.
; If nothing selected, it opens Google main page.
ForceGoogle:
SearchG := Reformat_String(Get_Selected_Text())
StringLeft , SearchG , SearchG , 100 ; reduce to <= 100 characters
If SearchG is space
{
Run , http://www.google.com/ ; or whatever you want.
Return
}
Run , http://www.google.com/search?q=%SearchG%&ie=utf-8&oe=utf-8
Return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;
; Send highlighted text to QuickDic translation dictionary.
; (Download it from http://quickdic.org/index_e.html)
; Needs no special settings for QD (can set QD to minimize to Tray or TaskBar).
QuickDic:
SearchQD := Reformat_String(Get_Selected_Text())
StringLeft , SearchL , SearchL , 100 ; reduce to <= 100 characters
IfWinActive , QuickDic
SearchQD = ; so doesn't repeat same search
If SearchQD ; Do this if text exists
{
Gosub , RunQD
Return
}
Else ; Do this if no text exists
{
IfWinExist , QuickDic ; If QD window active, minimise it.
PostMessage, 0x112, 0xF020,,, QuickDic ; WinMinimize doesn't work properly here
Else
Gosub , RunQD
}
Return
RunQD:
IfWinExist , QuickDic
{
WinRestore , QuickDic
WinActivate
}
Else
Run , "C:\Program Files\QuickDic\QuickDic.exe", "C:\Program Files\QuickDic"
WinWait , QuickDic , , 5
ControlClick , TTntEdit.UnicodeClass1, QuickDic ; activate input box
ControlSetText, TTntEdit.UnicodeClass1, %SearchQD% , QuickDic ; Enter the search text
ControlSend, TTntEdit.UnicodeClass1, {Enter}, QuickDic ; Start the search
return
;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;
; Added 15-09-2009. Searches computer using Locate32.
SearchLocate32:
SearchL := Reformat_String(Get_Selected_Text())
StringLeft , SearchL , SearchL , 100 ; reduce to <= 100 characters
IfWinActive , Locate:
SearchL = ; so doesn't repeat same search
If SearchL ; Do this if text exists
{
Gosub , RunL
Return
}
Else ; Do this if no text exists
{
IfWinExist , Locate:
WinClose, Locate:
Else
Gosub , RunL
}
Return
RunL:
Run , "C:\Program Files\Locate\Locate32.exe" , C:\Program Files\Locate\
WinWait , Locate: , , 5
sleep , 100
ControlClick , Edit6, Locate:
ControlSetText, Edit6, %SearchL% , Locate: ; Enter the search text
sleep , 100
ControlSend, Edit6, {Enter}, Locate: ; Start the search
Return
;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;
; Searches computer using Everything.
; (http://www.voidtools.com/)
; Opens Everything with highlighted text in search box. If Everything is running already,
; and no change to highlighted text, Everything toggles between minimises and restored.
;
; The logic is a bit counterintuitive because of the way the search box entry gets
; highlighted by Everything when it launches.
SearchEverything:
SearchE := Reformat_String(Get_Selected_Text())
StringLeft , SearchE , SearchE , 100 ; reduce to <= 100 characters
If SearchE ; Do this if text exists
{
Gosub , RunE
Return
}
Else ; Do this if no text exists
{
IfWinExist , ahk_class EVERYTHING
WinClose, ahk_class EVERYTHING
Else
Gosub , RunE
}
Return
RunE:
Run , "C:\Program Files\Everything\Everything.exe" -search "%SearchE%", C:\Program Files\Everything\
Return
;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Searches Copernic for selected text. If Cop is running, it toggles cop between
; minimised and restored.
;
SearchCopSelected:
SearchCopOld := SearchCop ; Save old value to see if it changes
SearchCop := Reformat_String(Get_Selected_Text())
StringLeft , SearchCop , SearchCop , 100 ; reduce to <= 100 characters
IfWinNotExist , ahk_class TCdsMainFrm
;Process , Exist , DesktopSearch.exe
;If !ErrorLevel
{
Run , C:\Program Files\Copernic Desktop Search 2\DesktopSearch.exe
ProgressBox("Loading Copernic - could take 15s")
WinWait , ahk_class TCdsMainFrm ,, 30
Progress , Off
Do_Search("ahk_class TCdsMainFrm", "" , "Edit1" , SearchCop, "#c")
Return
}
If SearchCop ; Do this if text exists
{
Do_Search("ahk_class TCdsMainFrm", "" , "Edit1" , SearchCop, "#c")
Return
}
Else ; Do this if no text exists
{
IfWinExist , ahk_class TCdsMainFrm
PostMessage, 0x112, 0xF020,,, ahk_class TCdsMainFrm, ; Used this because WinMinimize didn't do the right thing. See WinMinimize Help.
Else
PostMessage, 0x112, 0xF120,,, ahk_class TCdsMainFrm, ; Restore
;WinRestore , ahk_class TCdsMainFrm
}
Return
; Closes Copernic when minimised, and starts it minimised if not running already.
CloseCop:
PostMessage, 0x112, 0xF120,,, ahk_class TCdsMainFrm, ; Restore
WinWait , ahk_class TCdsMainFrm ,, 1
IfWinNotExist , ahk_class TCdsMainFrm ; do this if previous bit fails to work
{
Run , C:\Program Files\Copernic Desktop Search 2\DesktopSearch.exe ,, Min
WinWait , ahk_class TCdsMainFrm ,, 10
}
WinClose , ahk_class TCdsMainFrm
Return
;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;
; Added 24-02-2010.
; Puts highlighted text, date and time, title, and URL into clipboard for pasting into another document.
; (Inspired by AHK CopyPassage at http://www.autohotkey.com/forum/viewtopic.php?t=7914).
^!F7::
CopyToClipBoard:
Note := Get_Selected_Text() ; store highlighted text
If Note is space
Return ; do nothing if no item selected
; Neaten up the captured text.
Note := RegExReplace(Note, "\R$") ; Remove any newline from end of string.
Note := RegExReplace(Note, "^\s+|\s+$") ; Remove leading or trailing spaces.
Note := RegExReplace(Note, "\R{2,20}", "`r`n`r`n") ; Replace >=2 newlines with just two.
; Note := RegExReplace(Note, "\s{2,20}"," ") ; Replace multiple spaces with single space
; Check what sort of browser or document window we're copying from and get url if any.
WinGetTitle, Temp1, A
If Temp1 contains Opera ; Get url from Opera
{
Send , {F8} ; set focus to URL window in Opera
sleep , 100
Temp2 := Get_Selected_Text() ; Get the URL
Send , {F9} ; set focus back to web page in Opera
}
Else If Temp1 contains Windows Internet Explorer ; Get url from IE7
{
ControlGetText , Temp2, Edit1, ahk_class IEFrame
}
;
; *****NB. Insert extra 'ELSE IF' sections here to handle other browsers if required****
;
Else Temp2 = ; To reach here it must be a file or an unrecognised browser,
; so there'll be no URL to display.
; Edit Title Bar message by removing program name.
; (ie., remove all after the right-most hyphen, or asterisk as in Scite4).
Temp1 := RegExReplace(Temp1,"i)(\s(-|\*)\s)",">", OutputCount) ; Replace " - " or " * " with ">"
StringLen , length , Temp1
StringGetPos , Position , Temp1 , > , R ; Locate first > in string, going right to left.
; Sets Errorlevel if none found.
If !(Errorlevel)
{
Position := length - Position ; Number of chars to delete from right of string.
StringTrimRight , Temp1 , Temp1, %Position% ;
Temp1 := RegExReplace(Temp1,">"," - ") ; Replace remaining ">" with " - ".
}
; Assemble the output into the clipboard.
Clipboard = Date copied: %A_DD%-%A_MM%-%A_YYYY% at %A_Hour%:%A_Min%.`r`nSource: "%Temp1%".`r`n
; Append the url, if any.
If Temp2
Clipboard = %Clipboard%Website: %Temp2%.`r`n
; Append the captured text.
Clipboard = %Clipboard%`r`n"%Note%"
MsgBox, 0, Text shown below now on clipboard, %Clipboard%, 5
Return
;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;
; Copernic window balks unless data sent slowly so uses SendEvent
; 30-12-2008 Added trap to avoid accidental corruption of selected text
Do_Search(Class, Title, EditBox , Term, HKey)
{
IfWinNotExist , %Class% , %Title% ; re-use window if already exists
{
SendEvent , %HKey% ; open the Search window
WinWait , %Class% , %Title% ,2 ; Vista window often takes 15s to open
if ErrorLevel ; avoids sending {del} to search term if Search window fails to appear
{
MsgBox, 48, Search Request, Search program not ready, 2
Exit
}
}
StringLeft , Term , Term , 256 ; added 16-07-2009
WinActivate , %Class% , %Title%
Sleep ,10
ControlFocus , %EditBox%
Sleep ,10
SendInput , ^a{del}%Term% ;{Enter}
}
;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;
; Function puts selected text into output variable: eg Text := Get_Search_Term()
;
Get_Selected_Text()
{
WinGetActiveTitle, OutputVar
If OutputVar is space ; detects if TLB input box is active
{
Sterm =
Goto , GSTEnd
}
ClipSaved := ClipboardAll ; Save clipboard content for later restore
sleep , 60 ; These delays seem to be required else it can be unreliable
Clipboard = ;Flush clipboard
Sleep, 100
SendEvent, ^c ;Save highlighted text to clipboard.
sleep , 100
STerm := Clipboard
Sleep, 100
Clipboard := ClipSaved ;Restore Clipboard content
ClipSaved = ;and free the memory
GSTEnd:
Return , STerm ; Search term now stored and ready
}
;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;
; Function reformats text string prior to sending to a search program.
;
; 22-02-2010 DAT.
;
Reformat_String(Text)
{
Text := RegExReplace(Text, "\r?\n", " ") ; Replace any `n or `r with space
Text := RegExReplace(Text, "^\s+|\s+$") ; Remove leading or trailing spaces.
Text := RegExReplace(Text, "\s+"," ") ; Replace multiple spaces with single space
Text := RegExReplace(Text, "\s*\\\s*","\") ; Remove spaces surrounding a backslash.
Return , Text ; Search term now stored and ready
}
;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;
; Latest version by HotKeyIt on 19-09-2009 http://www.autohotkey.com/forum/viewtopic.php?t=38795.
; This seems free of false alarms yet doesn't need to use Input or to make lots of dummy hotkeys.
; So this is now the preferred version.
/*
Syntax
Key::RapidHotkey("keystrokes" ;Enter keystrokes here. E.g.: "^o"
, times ;optional. How often the key must be pressed to execute. E.g.: 3
, delay ;optional. How quick the key must be pressed to execute. E.g.: 0.2
, IsLabel) ;optional. specify 1 to indicate that parameter 1 is a label.
;E.g.
~o::RapidHotkey("^o") ;open file dialog if o pressed twice
;To specify several actions , use " as separator and leave times parameter empty.
If press times parameter is omitted, first action would be triggered on 2 presses.
~e::RapidHotkey("#r""#e""#f") ; #r if pressed twice, #e 3 times and so on
;You can specify also one (can be also 1) or separated value for times
~s::RapidHotkey("^s""{F12}""^+s", 5) ;so pressing 5 times = ^s, 6 times = {F12} and so on
;You can also specify separated times value
$x::RapidHotkey("x""#r""#e", "1""5""3")
;use same separator for delay and islabel parameter
~+::RapidHotkey("Plus")
~h::RapidHotkey("{Raw}Hello World!", 3) ;Press h 3 times rapidly to send Hello World!
~o::RapidHotkey("^o", 4, 0.2) ;be careful, if you use this hotkey, above will not work properly
~Esc::RapidHotkey("exit", 4, 0.2, 1) ;Press Esc 4 times rapidly to exit this script
~LControl::RapidHotkey("!{TAB}",2) ;Press LControl rapidly twice to AltTab
~RControl::RapidHotkey("+!{TAB}",2) ;Press RControl rapidly twice to ShiftAltTab
~LShift::RapidHotkey("^{TAB}", 2) ;Switch back in internal windows
~RShift::RapidHotkey("^+{TAB}", 2) ;Switch between internal windows
~e::RapidHotkey("#e""#r",3) ;Run Windows Explorer
~^!7::RapidHotkey("{{}{}}{Left}", 2)
~a::RapidHotkey("test", 2, 0.3, 1) ;You can also specify a Label to be launched
test:
MsgBox, Test
Return
Exit:
ExitApp
~LButton & RButton::RapidHotkey("Menu1""Menu2""Menu3",1,0.3,1)
Menu1:
Menu2:
Menu3:
MsgBox % A_ThisLabel
Return
*/
;;;;;;;;;;;;;;;;;;;;;
RapidHotkey(keystroke, times="2", delay=0.2, IsLabel=0)
{
Pattern := Morse(delay*1000)
If (StrLen(Pattern) < 2 and Chr(Asc(times)) != "1")
Return
If (times = "" and InStr(keystroke, """"))
{
Loop, Parse, keystroke,""
If (StrLen(Pattern) = A_Index+1)
continue := A_Index, times := StrLen(Pattern)
}
Else if (RegExMatch(times, "^\d+$") and InStr(keystroke, """"))
{
Loop, Parse, keystroke,""
If (StrLen(Pattern) = A_Index+times-1)
times := StrLen(Pattern), continue := A_Index
}
Else if InStr(times, """")
{
Loop, Parse, times,""
If (StrLen(Pattern) = A_LoopField)
continue := A_Index, times := A_LoopField
}
Else if (times = "")
continue = 1, times = 2
Else if (times = StrLen(Pattern))
continue = 1
If !continue
Return
Loop, Parse, keystroke,""
If (continue = A_Index)
keystr := A_LoopField
Loop, Parse, IsLabel,""
If (continue = A_Index)
IsLabel := A_LoopField
hotkey := RegExReplace(A_ThisHotkey, "[\*\~\$\#\+\!\^]")
IfInString, hotkey, %A_Space%
StringTrimLeft, hotkey,hotkey,% InStr(hotkey,A_Space,1,0)
Loop % times
backspace .= "{Backspace}"
keywait = Ctrl|Alt|Shift|LWin|RWin
Loop, Parse, keywait, |
KeyWait, %A_LoopField%
If ((!IsLabel or (IsLabel and IsLabel(keystr))) and InStr(A_ThisHotkey, "~") and !RegExMatch(A_ThisHotkey
, "i)\^[^\!\d]|![^\d]|#|Control|Ctrl|LCtrl|RCtrl|Shift|RShift|LShift|RWin|LWin|Escape|BackSpace|F\d\d?|"
. "Insert|Esc|Escape|BS|Delete|Home|End|PgDn|PgUp|Up|Down|Left|Right|ScrollLock|CapsLock|NumLock|AppsKey|"
. "PrintScreen|CtrlDown|Pause|Break|Help|Sleep|Browser_Back|Browser_Forward|Browser_Refresh|Browser_Stop|"
. "Browser_Search|Browser_Favorites|Browser_Home|Volume_Mute|Volume_Down|Volume_Up|MButton|RButton|LButton|"
. "Media_Next|Media_Prev|Media_Stop|Media_Play_Pause|Launch_Mail|Launch_Media|Launch_App1|Launch_App2"))
SendInput % backspace
If (WinExist("AHK_class #32768") and hotkey = "RButton")
WinClose, AHK_class #32768
If !IsLabel
SendInput % keystr
else if IsLabel(keystr)
Gosub, %keystr%
Return
}
Morse(timeout = 400) { ;by Laszo -> http://www.autohotkey.com/forum/viewtopic.php?t=16951 + Modifications by HotKeyIt
static running
If running
Return
running=1
k:="+AppsKey+Lwin+Rwin+LControl+RControl+LAlt+RAlt+LShift+RShift+Tab+Backspace+Enter+Left+Right"
. "+Up+Down+Delete+Insert+Escape+Home+End+PgUp+PgDn+Numpad0+Numpad1+Numpad2+Numpad3"
. "+Numpad4+Numpad5+Numpad6+Numpad7+Numpad8+Numpad9+NumpadDot+NumpadDiv+NumpadMult+NumpadAdd"
. "+NumpadSub+NumpadEnter+NumpadIns+NumpadEnd+NumpadDown+NumpadPgDn+NumpadLeft+NumpadClear+NumpadRight"
. "+NumpadHome+NumpadUp+NumpadPgUp+NumpadDel+NumpadDiv+NumpadMult+NumpadAdd+NumpadSub+NumpadEnter"
. "+F1+F2+F3+F4+F5+F6+F7+F8+F9+F10+F11+F12+F13+F14+F15+F16+F17+F18+F19"
. "+F20+F21+F22+F23+F24+Pause+Break+PrintScreen+a+b"
. "+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+w+x+y+z+0+1"
. "+2+3+4+5+6+7+8+9+Space+´+,+-+."
. "+>+^+RButton+LButton+MButton+Capslock+Scrolllock+Numlock+"
key := RegExReplace(A_ThisHotKey,"[\*\~\$\#\+\!\^]")
If key=
key:=SubStr(A_ThisHotkey,0)
IfInString, key, %A_Space%
{
StringReplace,k,k,% "+" SubStr(key,1,InStr(key, " ")-1) "+", +
StringTrimLeft, key, key,% InStr(key,A_Space,1,0)
}
If key=BS
key=BackSpace
else if key=Esc
key=Escape
else if key=Return
key=Enter
else if key=Ins
key=Insert
else if key=Del
key=Delete
else if key=LCtrl
key=LControl
else if key=RCtrl
key=RControl
If (key="Alt" or InStr(A_ThisHotkey,"!"))
StringReplace,k,k,+LAlt+RAlt+,+
If (key="Ctrl" or key="Control" or InStr(A_ThisHotkey,"^"))
StringReplace,k,k,+LControl+RControl+,+
If (key="Shift" or (InStr(A_ThisHotkey,"+") and key!="+"))
StringReplace,k,k,+LShift+RShift+,+
StringReplace,k,k,+%key%+,+
If (SubStr(k,1,1)="+")
StringTrimLeft,k,k,1
If (SubStr(k,0)="+")
StringTrimRight,k,k,1
StringReplace,k,k,+,% Chr(1),A
If (key!="+")
k.=Chr(1) "+"
Loop {
t := A_TickCount
While % (GetKeyState(key,"P") and A_TickCount-t < timeout){
Sleep, 10
Loop,parse,k,% Chr(1)
If (GetKeyState(A_LoopField,"P") && A_LoopField!=key && running:=0)
Return
}
If (GetKeyState(key,"P") && !running:=0)
Return Pattern . "1"
else
Pattern.=A_TickCount-t > timeout
t := A_TickCount
While % (!GetKeyState(key,"P") and A_TickCount-t < timeout){
Sleep, 10
Loop,parse,k,% Chr(1)
If GetKeyState(A_LoopField,"P")
If (A_LoopField!=key && !running:=0)
Return
else
Break
}
If (!GetKeyState(key,"P") && !running:=0)
Return Pattern
}
}
;;;;;;;;;;;;;;;