AutoHotkey Community

It is currently May 26th, 2012, 10:44 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: July 6th, 2009, 4:13 pm 
Offline

Joined: December 1st, 2008, 12:34 pm
Posts: 49
Location: UK
I realised I was wasting lot's of time copying and pasting text from application windows to search windows, so I wrote the first script to streamline the process. 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'.
3. Triple-tap the right-hand Control key to search the computer using Copernic Desktop Search.
4. With nothing selected, the relevant search window opens ready for typed input

Code:
;;;;;;;;;;;;;;;;;;
;
; Title: SearchInterface.ahk
; Author:         DAT 05-12-2008
; AutoHotkey Version: 1.0.47.05
; Language:       English
; Platform:       Win9x/NT
;
; Double-clicking right-hand Ctrl key searches for highlighted text using 'Everything'.
; Triple-clicking right-hand Ctrl key does the same but using 'Copernic Desktop Search'.
; Double-clicking right-hand Shift key does the same but 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 to open on your choice of hotkey (/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

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

~RControl::RapidHotkey("SearchEverything" Chr(4) "SearchCopSelected" ,2,0.2,1)    
; 2 clicks = Searches Everything for selected text
; 3 clicks = Searches Copernic for selected text

~RShift::RapidHotkey("GoogleSelectedText" ,2,0.2,1)    
; 2 clicks = Searches Google for selected text

GoogleSelectedText:   ; Search Internet for selected text using Google
SearchTerm := Get_Selected_Text()
If SearchTerm is space
{
   Run , http://www.google.com/
   Return      
}
Run , http://www.google.com/search?q=%SearchTerm%&ie=utf-8&oe=utf-8
Return

SearchEverything:   ; Search computer for selected text using 'Everything'
SearchTerm := Get_Selected_Text()
Run , "C:\Program Files\Everything\Everything.exe" -search "%SearchTerm%"
Return

SearchCopSelected:   ; Search computer for selected text using Copernic
SearchTerm := Get_Selected_Text()
Process , Exist , DesktopSearch.exe
If !ErrorLevel
{
   Run , C:\Program Files\Copernic Desktop Search 2\DesktopSearch.exe
   WinWait , ahk_class  TCdsMainFrm
}
Do_Search("ahk_class TCdsMainFrm", "" , "Edit1" , SearchTerm, "#c")  ; Change Win+c as needed
Return

;;;;;;;;;;;;;
;
; Stores the selected text into a variable: eg Text := Get_Selected_Text()

Get_Selected_Text() 
{
   WinGetActiveTitle, OutputVar
   If OutputVar is space   
   {
      Sterm =
      Goto , End
   }
   ClipSaved := ClipboardAll   ; Save clipboard content for later restore
   sleep , 100      ; Delays 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
   End:
   Return , STerm      ; Search term now stored and ready
}
;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;
;
; 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 ; In Vista, Cop window may take 15s to open
      if ErrorLevel ; avoids corrupting selected text if Search window fails to appear
      {
         MsgBox, 48, Search Request, Search program not ready, 2
         Exit
      }
   }
   WinActivate , %Class% , %Title%
   Sleep ,10    ; reduced from 100 on 03-01-2009
   ControlFocus , %EditBox%
   Sleep ,10
   SendEvent , ^a{del}%Term%   
}
;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;
;
; This function written by HotKeyIt. I copied it from his posting at
; http://www.autohotkey.com/forum/viewtopic.php?t=38795 on 27-12-2008.
; Please check the link for details and examples.

RapidHotkey(keystroke, times="", delay=0.1, IsLabel=0)
{
   ;Suspend, On
   Pattern := Morse(delay*1000)
   If (StrLen(Pattern) < 2 and Chr(Asc(times)) != "1")
      Return
   If (times = "" and InStr(keystroke, Chr(4)))
   {
      Loop, Parse, keystroke,% Chr(4)   
         If (StrLen(Pattern) = A_Index+1)
            continue := A_Index, times := StrLen(Pattern)
   }
   Else if (RegExMatch(times, "^\d+$") and InStr(keystroke, Chr(4)))
   {
      Loop, Parse, keystroke,% Chr(4)   
         If (StrLen(Pattern) = A_Index+times-1)
            times := StrLen(Pattern), continue := A_Index
   }
   Else if InStr(times, Chr(4))
   {
      Loop, Parse, times,% Chr(4)
         If (StrLen(Pattern) = A_LoopField)
            continue := A_Index, times := A_LoopField
   }
   Else if (times = "")
      continue := 1, times := 1
   Else if (times = StrLen(Pattern))
      continue := 1
   If !continue
      Return
   Loop, Parse, keystroke,% Chr(4)
      If (continue = A_Index)
         keystr := A_LoopField
   Loop, Parse, IsLabel,% Chr(4)
      If (continue = A_Index)
         IsLabel := A_LoopField
   hotkey := RegExReplace(A_ThisHotkey, "[\*\~\$\#\+\!\^]")
   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
   , "\^[^\!\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"))
      Send % backspace
   If (WinExist("AHK_class #32768") and hotkey = "RButton")
      WinClose, AHK_class #32768
   If !IsLabel
      Send % keystr
   else if IsLabel(keystr)
      Gosub, %keystr%
   Return
}   
Morse(timeout = 400) { ;by Laszo -> http://www.autohotkey.com/forum/viewtopic.php?t=16951
   tout := timeout/1000
   key := RegExReplace(A_ThisHotKey,"[\*\~\$\#\+\!\^]")
   Loop {
      t := A_TickCount
      KeyWait %key%
      Pattern .= A_TickCount-t > timeout
      KeyWait %key%,DT%tout%
      If (ErrorLevel)
         Return Pattern
   }
}
;;;;;;;;;;;;;;;;;;;;;;;;;


'Everything' (http://www.voidtools.com) has been a wonderful recent 'discovery'. The more I use it the more I like it. It's extremely fast with low system overhead and searches 'as you type' within paths and filenames. On the other hand Copernic indexes the data and can search within the body of files and emails, so both are useful in their different ways.

I use Copernic 2.3 Build 30, which was the last fully-featured free version. It works very well but keeps offering to update to the newer cut-down version. This annoyance is the reason for the second script. Just leave it running and it cancels the update window as soon as it appears.

Code:
;;;;;;;;;;;;;;;;;
;31-12-2008 From http://www.autohotkey.com/forum/viewtopic.php?t=35659
#NoTrayIcon
#SingleInstance , Force
#Persistent
SetBatchLines,-1
HookProcAdr := RegisterCallback( "HookProc", "F" )
hWinEventHook := SetWinEventHook( 0x3, 0x3, 0, HookProcAdr, 0, 0, 0 )
OnExit, HandleExit
Return

HookProc( hWinEventHook, Event, hWnd, idObject, idChild, dwEventThread, dwmsEventTime )
{
   if Event ; EVENT_SYSTEM_FOREGROUND = 0x3
   {   
      WinGetClass, class, ahk_id %hWnd%
      If class = TSoftwareUpdateFrm     ; name of window to dispose of
      {
         WinClose, ahk_class TSoftwareUpdateFrm
         xloc := A_ScreenWidth - 600       ;Calculate x coordinate of Progress window
         yloc := A_ScreenHeight - 100   ;Calculate y coordinate of Progress window
         Progress, B2 x%xloc% Y%yloc% M zh0 w300 h30 , , Update for Copernic2 declined,    
         #Persistent
         SetTimer, RemoveMessage, 2000
      }
   }
}

SetWinEventHook(eventMin, eventMax, hmodWinEventProc, lpfnWinEventProc, idProcess, idThread, dwFlags)
{
   DllCall("CoInitialize", Uint, 0)
   return DllCall("SetWinEventHook"
   , Uint,eventMin   
   , Uint,eventMax   
   , Uint,hmodWinEventProc
   , Uint,lpfnWinEventProc
   , Uint,idProcess
   , Uint,idThread
   , Uint,dwFlags)   
}

UnhookWinEvent()
{
   Global
   DllCall( "UnhookWinEvent", Uint,hWinEventHook )
   DllCall( "GlobalFree", UInt,&HookProcAdr ) ; free up allocated memory for RegisterCallback
}

RemoveMessage:
SetTimer, RemoveMessage, Off
Progress , Off
return

HandleExit:
UnhookWinEvent()
ExitApp
Return


Acknowledgements:
Thanks to HotKeyIt for RapidHotkey (http://www.autohotkey.com/forum/viewtopic.php?t=38795) and Serenity for WinEventHook Messages (http://www.autohotkey.com/forum/viewtopic.php?t=35659). Luckily I could use them despite not fully understanding how they work :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 10th, 2009, 2:07 pm 
I see you haven't had any replies yet, I just wanted to say this is very cool. Thank you for your contributions.

- Entropic


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 11th, 2009, 10:07 am 
Offline

Joined: December 1st, 2008, 12:34 pm
Posts: 49
Location: UK
Entropic,

Thanks for the kind words. Much appreciated.

DAT.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: August 28th, 2009, 4:52 pm 
Offline

Joined: December 1st, 2008, 12:34 pm
Posts: 49
Location: UK
This enhanced version lets you toggle the local search windows on and off so there's no need to use the mouse to close the search windows. I've also changed to HotKeyIt's latest version of RapidHotkey.

This new version works as follows:

1. Rapid double-click on RControl activates Everything to search on highlighted text. Repeated activation with no change to highlighted text toggles Everything between minimised-to-tray and restored.

2. Rapid double-click on LControl activates Copernic to search on highlighted text. Repeated activation with no change to highlighted text toggles Copernic between minimised-to-Task Bar and restored. Rapid triple-click on LControl minimises Copernic to tray and clears its search box.

3. Rapid double-click on RShift searches for highlighted text using Google (as before).

Code:
;;;;;;;;;;;;;;;;;;
;
; Title: SearchInterfaceV2.ahk
; Author:         DAT 05-12-2008
; AutoHotkey Version: 1.0.47.05
; Language:       English
; Platform:       Win9x/NT

; 28-08-2009 Modified as follows:
;   1.  Rapid double-click on RControl activates Everything to search on highlighted text. 
;       Do it again without changing the highlighting, and Everything minimises to tray. 
;   2.  Rapid double-click on LControl activates Copernic to search on highlighted text. Do
;       it again without changing the highlighting, and Copernic minimises to Task Bar.
;       Rapid triple-click 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-clicking 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

; 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,0.2,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",2,0.2,1)
~RShift::RapidHotkey("GoogleSelectedText" ,2,0.2,1)    
; 2 clicks = Searches Google for selected text

GoogleSelectedText:   ; Search Internet for selected text using Google
SearchTerm := Get_Selected_Text()
If SearchTerm is space
{
   Run , http://www.google.com/
   Return      
}
Run , http://www.google.com/search?q=%SearchTerm%&ie=utf-8&oe=utf-8
Return

;;;;;;;;;;;;;;;;;;;;;;;
; 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 := 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 := 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
   tooltip , Loading Copernic - could take 15s
   WinWait , ahk_class  TCdsMainFrm ,, 30
   ToolTip
   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
}
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
;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;
; Stores the selected text into a variable: eg Text := Get_Selected_Text()

Get_Selected_Text() 
{
   WinGetActiveTitle, OutputVar
   If OutputVar is space   
   {
      Sterm =
      Goto , End
   }
   ClipSaved := ClipboardAll   ; Save clipboard content for later restore
   sleep , 100      ; Delays 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
   End:
   Return , STerm      ; Search term now stored and ready
}
;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;
; 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 ; In Vista, Cop window may take 15s to open
      if ErrorLevel ; avoids corrupting selected text if Search window fails to appear
      {
         MsgBox, 48, Search Request, Search program not ready, 2
         Exit
      }
   }
   WinActivate , %Class% , %Title%
   Sleep ,10    ; reduced from 100 on 03-01-2009
   ControlFocus , %EditBox%
   Sleep ,10
   SendEvent , ^a{del}%Term%   
}
;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;
;
; This function written by HotKeyIt.
/*
Version dated 24.02.2009, copied from http://www.autohotkey.com/forum/viewtopic.php?t=38795
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

Examples:
~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

~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"))
      Send % backspace
   If (WinExist("AHK_class #32768") and hotkey = "RButton")
      WinClose, AHK_class #32768
   If !IsLabel
      Send % keystr
   else if IsLabel(keystr)
      Gosub, %keystr%
   Return
}   
Morse(timeout = 400) { ;by Laszo -> http://www.autohotkey.com/forum/viewtopic.php?t=16951 (Modified to return: KeyWait %key%, T%tout%)
   tout := timeout/1000
   key := RegExReplace(A_ThisHotKey,"[\*\~\$\#\+\!\^]")
   IfInString, key, %A_Space%
   StringTrimLeft, key, key,% InStr(key,A_Space,1,0)
   Loop {
      t := A_TickCount
      KeyWait %key%, T%tout%
     Pattern .= A_TickCount-t > timeout
     If(ErrorLevel)
      Return Pattern
     KeyWait %key%,DT%tout%
      If (ErrorLevel)
         Return Pattern
   }
}
;;;;;;;;;;;;;;;


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Great script
PostPosted: September 12th, 2009, 4:32 pm 
Google, Everything and Copernic is my combination too. (Although I switched to CD3-Pro last year). The little customisation of the paths worked like a charm, the compiler fired off as well, and I now have a 50% rise in productivity when searching. Thanks !!

Shem


Report this post
Top
  
Reply with quote  
PostPosted: September 14th, 2009, 12:14 pm 
I recently noticed a major problem Everything has with indexing MS Live Mesh folders (http://forum.voidtools.com/viewtopic.ph ... hilit=Mesh) . I have switched with some of my searches from Everything to Locate32 for that reason.

Any chance of the script being expanded to include a Locate32 search hot key combination .. ?

Thanks for this great tool!

Shem


Report this post
Top
  
Reply with quote  
PostPosted: September 16th, 2009, 10:21 am 
Offline

Joined: December 1st, 2008, 12:34 pm
Posts: 49
Location: UK
Shem,

Thanks for the tip-off about Locate32, which I'd not seen before. I've been trying it out since yesterday, but for me Everything seems faster and more intuitive to set up and use.

Anyway I've added support for Locate32 to the script. You triple-click on Right-Ctrl to open and close it but it's easy to change the button assignments to suit your preference.

The previous script was prone to occasional spurious multi-clicks while typing. I've now found a solution to this (see my 16-09-2009 post at http://www.autohotkey.com/forum/viewtopic.php?t=38795&highlight=). It's not elegant but works fine. Without false alarms the inter-click delay limit is not so critical and I've increased it to 0.3s. Alter ClickDelay to change it.

Happy searching :-)

Code:
;;;;;;;;;;;;;;;;;;
;
; Title: SearchInterfaceV2.ahk
; Author:         DAT 05-12-2008
; AutoHotkey Version: 1.0.47.05
; Language:       English
; Platform:       Win9x/NT

; 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 click on Right-Control key.
;   3.  Since no false alarms, delay between clicks relaxed to 0.3s. Single value
;       for all multi-tap keys stored in ClickDelay.

; 28-08-2009 Modified as follows:
;   1.  Rapid double-click on RControl activates Everything to search on highlighted text. 
;       Do it again without changing the highlighting, and Everything minimises to tray. 
;   2.  Rapid double-click on LControl activates Copernic to search on highlighted text. Do
;       it again without changing the highlighting, and Copernic minimises to Task Bar.
;       Rapid triple-click 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-clicking 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

Gosub , DefHotkeys   ; added 15-09-2009 for false-alarm-free version of RapidHotkey.

ClickDelay = 0.3    ; Max delay between each key-press. Adjust this to suit typing speed.

; 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)  ; SL32 added 15-09-2009
   ; 2 clicks = Searches Everything for selected text. Repeat to close.
   ; 3 clicks = Searches SearchLocate32 for selected text. Repeat to close.

~RShift::RapidHotkey("GoogleSelectedText" ,2, ClickDelay,1)    
   ; 2 clicks = Searches Google for selected text

GoogleSelectedText:   ; Search Internet for selected text using Google
SearchTerm := Get_Selected_Text()
If SearchTerm is space
{
   Run , http://www.google.com/
   Return      
}
Run , http://www.google.com/search?q=%SearchTerm%&ie=utf-8&oe=utf-8
Return

;;;;;;;;;;;;;;;;
;  Added 15-09-2009.  Searches computer using Locate32.
;  Command line options not as suitable as they are in Everything,
;  so script sends search text straight to search window.
;
SearchLocate32:   
SearchL := Get_Selected_Text()
StringLeft , SearchL , SearchL , 100 ; reduce to <= 100 characters

;  After activation the input box remains highlighted. Next 2 lines
;  clear the input data so SL32 will close on second activation
;  attempt instead of repeating previous search.
   IfWinActive , Locate:
   SearchL =   

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
;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;
; 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 := 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 := 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
   tooltip , Loading Copernic - could take 15s
   WinWait , ahk_class  TCdsMainFrm ,, 30
   ToolTip
   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
}
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
;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;
; Stores the selected text into a variable: eg Text := Get_Selected_Text()

Get_Selected_Text() 
{
   WinGetActiveTitle, OutputVar
   If OutputVar is space   
   {
      Sterm =
      Goto , End
   }
   ClipSaved := ClipboardAll   ; Save clipboard content for later restore
   sleep , 100      ; Delays 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
   End:
   Return , STerm      ; Search term now stored and ready
}
;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;
; 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 ; In Vista, Cop window may take 15s to open
      if ErrorLevel ; avoids corrupting selected text if Search window fails to appear
      {
         MsgBox, 48, Search Request, Search program not ready, 2
         Exit
      }
   }
   WinActivate , %Class% , %Title%
   Sleep ,10    ; reduced from 100 on 03-01-2009
   ControlFocus , %EditBox%
   Sleep ,10
   SendEvent , ^a{del}%Term%   
}
;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;
; Subroutine to define lots of keys as 'do-nothing' hotkeys.
; As described by Laszlo's at http://www.autohotkey.com/forum/topic17614.html
; and http://www.autohotkey.com/forum/topic7081.html.
;
DefHotkeys:
keys = ``1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./
Loop Parse, keys
   HotKey , ~*%A_LoopField%, DoNothing
SpecialKeys =LShift RShift LCtrl RCtrl LAlt RAlt LWin RWin  ; Add as required
Loop Parse, SpecialKeys , %A_Space%
   HotKey , ~*%A_LoopField%, DoNothing
Return

DoNothing:
; SoundBeep , 3000, 10
Return
;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;
;
; This function written by HotKeyIt. This is version dated 24.02.2009,
; copied from http://www.autohotkey.com/forum/viewtopic.php?t=38795
; Morse() altered by DAT 15-09-2009.
/*
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

Examples:
~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

~LButton & RButton::RapidHotkey("Menu1""Menu2""Menu3",1,0.3,1)
Menu1:
Menu2:
Menu3:
MsgBox % A_ThisLabel
Return

*/

RapidHotkey(keystroke, times="2", delay=4, 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"))
      Send % backspace
   If (WinExist("AHK_class #32768") and hotkey = "RButton")
      WinClose, AHK_class #32768
   If !IsLabel
      Send % keystr
   else if IsLabel(keystr)
      Gosub, %keystr%
   Return
}   

;;;;
; Based on Morse by Laszlo at http://www.autohotkey.com/forum/viewtopic.php?t=16951. 
; Slightly modified by DAT 14-09-2009 to avoid false alarms (Mods marked 'DAT').
;
Morse(timeout = 400)

   tout := timeout/1000
   CurrentKey = %A_ThisHotKey%  ; DAT: Stored so can trap wrong hotkey within the loop
   key := RegExReplace(A_ThisHotKey,"[\*\~\$\#\+\!\^]")
   IfInString, key, %A_Space%
   StringTrimLeft, key, key,% InStr(key,A_Space,1,0)
   Loop
   {                         ; Loops until KeyWait test fails, or 'alien' hotkey spotted.
      KeyWait %key%, T%tout%                ; Wait for key to be released.
      Pattern .= 0                          ; DAT: 'Morse' aspect not being used anyway...
      If(ErrorLevel)                       
         Return Pattern                     ; It timed out, so finish.
      KeyWait %key%,DT%tout%                ; Wait for next key-down...
      If (ErrorLevel)                       ; and allow to loop if key repeats,
         Return Pattern                     ; otherwise finish if it times out.
      IfNotEqual, A_ThisHotkey, %CurrentKey%  ; DAT: Abort if another key has intervened
      {
         Pattern =
         Return Pattern
      }
   }
}
;;;;;;;;;;;;;;;


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 17th, 2009, 12:13 pm 
Great !! Many, many thanks. The triple R-Ctrl tap is a good choice for me, since I can intuitively alternate between Locate and Everything if need be.

I agree Everything is more intuitive and responsive, but the Mesh problem refuses to go at the moment. Also, what I like about Locate is that it remembers the default sort I set (eg. Date modified), so I don't have to re-sort manually. Maybe the List tab in Everything's options will offer customisation soon. But I agree with I read in one post on the voidtools forum - Everything's main priority should be speed.

Great to have both tools now. Many thanks again. :D

Shem


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 18th, 2009, 3:44 am 
Offline

Joined: April 29th, 2009, 12:08 pm
Posts: 45
sweet script, this will come in handy, tx

_________________
frosty the snowman

Ex-AutoIt user

class: intermediate


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 2nd, 2010, 11:58 pm 
Offline

Joined: February 2nd, 2010, 11:21 pm
Posts: 3
I have recently adapted your script for use with my online learning tool IFAConc (http://ifa.amu.edu.pl/~ifaconc). I basically took the bit for triggering Google searches in a default browser, and replicated it to start my own search engines. I also removed the unneeded fragments for Locate32, Everything and Copernic. The IFAConc tool is, for the most part, restricted to our school, so there is little use in my pasting "my" script here. I'll be happy to say more, if needed; there are also a couple of YouTube videos available from the "ifaconc" channel.

I would be very, very grateful to be allowed to distribute the modified script (and the exe file created from it), with due acknowledgements to the source(s) of course, as a free download for students. Their searches could now become fantastically integrated with writing tasks - something I have long been seeking to provide.

I hope I can use your great work this way. Many thanks, once again, for sharing the script - it has been serving me very well!

Kind regards,

Shem


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 12:21 pm 
Offline

Joined: December 1st, 2008, 12:34 pm
Posts: 49
Location: UK
Shem,

Please go ahead and use it all you want and I'm pleased to know someone else finds it as useful as I do.

Much of the credit for the script belongs to the many experts on the forum whose code fragments I copied or learned from, and especially to Hotkeyit for his RapidHotkey function.

Regards,
DAT.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 3rd, 2010, 10:49 pm 
Offline

Joined: February 2nd, 2010, 11:21 pm
Posts: 3
Great, thanks, DAT! Oh, yes, this script is very much alive :)

While the topic is fresh again, I wonder if you, or anyone reading this thread, would have answers to such two questions:

1) How does the script perform in Win 7 and Vista, especially on non-admin accounts ? I've only been using it on XP SP3 so far.

2) Is there a way of controlling a trailing space when passing the search pattern? In most applications, when you double-click on a word, the highlight will also capture the following space, which is unfortunately meaningful for my online app. This probably is a question that does goes beyond the script itself, but I was wondering if anyone might have advice or tips.

Many thanks again!

Shem


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Request
PostPosted: February 10th, 2010, 6:34 pm 
Offline

Joined: February 10th, 2010, 5:06 pm
Posts: 2
Hello DAT,

first, thank you for this very nice script, use it every day and I love it.

Now I have a request, maybe you or some one else can tell me how to make it search with Lingopad:
http://www.ego4u.com/en/lingopad

or, as an alternative with quickdic:
http://quickdic.org/

when I double-tap the right-hand Shift key.

Try it on many ways, but I have not the knowledge to make it run, the Program starts, but then it will not read(?) the clipboard Content. "Watch Clipboard" in the Programsettings is on.

Many thanks R Z

English is not my native language, and that makes it not easier :-)


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 24th, 2010, 7:07 pm 
Offline

Joined: December 1st, 2008, 12:34 pm
Posts: 49
Location: UK
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
   }
}
;;;;;;;;;;;;;;;


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Thanks!
PostPosted: March 1st, 2010, 8:45 am 
Offline

Joined: February 10th, 2010, 5:06 pm
Posts: 2
Hello DAT,

this is really great, it works like a charm, I'm very thankful.
And the Text saving feature is excellent. I think I'll use it often.

Thank you for your good work, I'm happy.

Greetings R Z


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: jrav and 15 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group