AutoHotkey Community

It is currently May 27th, 2012, 6:35 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: March 30th, 2011, 11:46 pm 
Offline

Joined: August 17th, 2004, 7:05 pm
Posts: 38
by now I have so many key bindings that I sometimes lose track of them. I also have window-specific functions using the #IfWinActive command. The following script helped me a bit.

First, I created an On Screen Display (OSD) for the currently pressed key. Within each assigned hotkey I added
Code:
showOSD("Your Help For The Current Key Goes Here")
. The following code is necessary:
Code:
; ###############################################
; OSD by Thinkstorm
; ###############################################

Gui1:=0

showOSD(text) {
   global Gui1
   Gui, 1: Color, 1A1A1A,FCFCFC
   Gui, 1: +Toolwindow -Resize -SysMenu -Border -Caption +AlwaysOnTop +LastFound
   WinSet, Transparent, 0
   transp := 0
   Gui1 := WinExist()
   Gui, 1: Font,cF9F9F9 s36,Corbel ; preferred font (as it is the last one set, if available)
   Gui, 1: Add, Text,center w600, %text%
   Gui, 1:Show, NoActivate Center AutoSize
   Loop, 5
   {
      transp := transp + 42
      WinSet, Transparent, %transp%
      sleep,20
   }
   SetTimer, hideOSD, 500
}

hideOSD:
   SetTimer, hideOSD, Off
   transp := 211
   Loop, 12
   {
      transp := transp - 10
      WinSet, Transparent, %transp%, ahk_id %Gui1%
      sleep,15
   }
   Loop, 18
   {
      transp := transp - 5
      WinSet, Transparent, %transp%, ahk_id %Gui1%
      sleep,15
   }
   Gui, 1:Hide
   Gui, 1:Destroy
   if (reloadFile) {
      reload ;this is for my script reload key binding
   }
Return

The last (reloadFile) is just for my key binding for reloading the AHK file:
Code:
reloadFile := 0
#^F12::
   reloadFile := 1
   showOSD("Reload Autohotkey Settings File")
Return


Now every key binding got the showOSD() function added somewhere within its code. Once that was done, I added a script that would read the source AHK file, try and ignore all comments, try and ignore all #IfWinActive directives that do not apply with the current app/window, and display the help text for the specific key bindings. The thing is quite dirty but works for my 2000+lines of code. Only problem: you cannot run this script in compiled mode, I guess, as there is no .AHK source text to read...

The help window closes if it loses focus, on ESC, or on ENTER.

Code:
; #######################################
; Collect Current Keybindings by Thinkstorm
; #######################################

removeSpecialModifier(string, modifier) {
   str := Trim(string)
   pos := inStr(str,modifier)
   if (pos=0) {
      return str
   }
   if (pos=1) {
      return substr(str,2)
   }
}

#?::
   mode:=0 ;0 for global bindings, 1 for local bindings
   binding0:= 0
   binding1 := 0
   command := ""
   comment:=false
   notrelevant:=false
   line=""
   l=""
   str=""
   Loop, Read, %A_ScriptFullPath%
   {
      ; --------------- DEAL WITH COMMENTS ---------------
      l := Trim(A_LoopReadLine)
      StringLeft, str, l, 2
      if (str="/*") {
         StringRight, str, l, 2
         if (str<>"*/")   {
            comment:=true ; comment starts
         }
         continue
      }
      if (comment) {
         StringRight, str, l, 2
         if (str="*/") {
            comment:=false ; end of comment
         }
         continue
      }
      ; --------------- DEAL WITH LOCAL KEY BINDINGS ---------------
      if (InStr(l, "#IfWinActive")=1) {
         StringSplit, str, l, `,
         if (str0=1) { ; end of #ifWinActive statement
            mode:=0
            notrelevant := false
            continue
         }
         IfWinActive, %str2%
         {
            mode := 1
            notrelevant := false
         } else {
            mode := 0
            notrelevant := true
         }
         continue
      }
      if (notrelevant) {
         continue ;skip lines that are not meant for the currently active window
      }
      ; --------------- SEARCH FOR KEY BINDINGS ---------------
      StringRight, str, l, 2
      if (str="::") {
         command := ""
         str := Trim(substr(l,1,InStr(l,"::")-1))       ; remove "::"
         if (str="#?") {
            ; this keystroke - ignore
            continue
         }
         str := removeSpecialModifier(str,"~")      ; remove the pass-through modifier
         str := removeSpecialModifier(str,"$")         ; remove the send-to-self modifier
         StringReplace, str, str, `` ; remove first escape character (in case you use ` as a key binding :))
         ; translate key bindings into standard text abbreviations #,CTRL,ALT,SHIFT,ANY
         if (inStr(str,"#")) {
            StringReplace,str,str,#
            command := command . "#+"
         }
         if (inStr(str,"^")) {
            StringReplace,str,str,^
            command := command . "CTRL+"
         }
         if (inStr(str,"!")) {
            StringReplace,str,str,!
            command := command . "ALT+"
         }
         if (inStr(str,"+")) {
            StringReplace,str,str,+
            command := command . "SHIFT+"
         }
         if (inStr(str,"*")) {
            StringReplace,str,str,*
            command := command . "ANY+"
         }
         command := command . str
         continue
      }
      ; --------------- SEARCH FOR OSD HELP TEXT ---------------
      pos := inStr(l,"showOSD(")
      If (pos) {
         if (command="") {
            continue ;UPS - an OSD without any identified command? must be an error in this script... ignore
         }
         startPos := pos + 9
         len := inStr(l, substr(l,StartPos-1,1),false,-1)-StartPos
         str := subStr(l, StartPos, len)
         binding%mode% += 1
         num := binding%mode%
         key%mode%_%num% := command
         description%mode%_%num% := str
         command := ""
         continue
      }
   }
   ; --------------- CONSTRUCT GUI FOR HELP ---------------
   spacing := 14
   Gui,  Color, 1A1A1A,FCFCFC
   Gui,  +Toolwindow -Resize -SysMenu -Border -Caption +AlwaysOnTop +LastFound
   WinSet, Transparent, 0
   HelpGUI := WinExist()
   xstart := 20
   if (binding1 > 0) {
      ystart := 70
      Gui,  Font, c10EE00 s20 w700,Corbel
      Gui,  Add, Text,center w900, Windows+?  :  Current Key Bindings
      Gui,  Font, cFEFEFE s16 w700, Corbel
      Gui,  Add, Text, center w400 y57 x%xstart%, Current Window
      Loop, %binding1%
      {
         key := key1_%A_Index%
         description := description1_%A_Index%
         ypos := ystart+A_Index*spacing
         Gui,  Font, cFEFEFE s10 w700, Corbel
         Gui,  Add, Text, right x%xstart% y%ypos% w150, %key%
         Gui,  Font, w100, Corbel
         Gui,  Add, Text, left xp+170 y%ypos% w300, %description%
      }
      xstart :=xstart+400+20
      Gui,  Font, s16 w700, Corbel
      Gui,  Add, Text, center w400 y57 x%xstart%, Global Hotkeys
   } else {
      ystart := 50
      Gui,  Font,c10EE00 s24 w700,Corbel
      Gui,  Add, Text,center w500, Windows+?  :  Current Key Bindings
   }
   Loop, %binding0%
   {
      key := key0_%A_Index%
      description := description0_%A_Index%
      ypos := ystart+A_Index*spacing
      Gui,  Font, cFEFEFE s10 w700, Corbel
      Gui,  Add, Text, right x%xstart% y%ypos% w150, %key%
      Gui,  Font, w100, Corbel
      Gui,  Add, Text, left xp+170 y%ypos% w300, %description%
   }
   Gui, Add, Button, x-10 y-10 w1 h1 +default hidden gExitGui
   transp := 0
   WinSet, Transparent, 0, ahk_id %HelpGUI%
   Gui, Show, Center AutoSize
   Loop, 8
   {
      transp := transp + 30
      WinSet, Transparent, %transp%, ahk_id %HelpGUI%
      sleep,12
   }
   SetTimer, CloseHelpGUIWindow, 500
Return

; ################################
; Help GUI Labels and Functions
; ################################


CloseHelpGUIWindow: ; close GUI window if it loses focus
   IfWinNotActive, ahk_id %HelpGUI%
   {
      SetTimer, CloseHelpGUIWindow, Off
      HideHelpGUI()
   }
Return

ExitGui:
GuiEscape:
   SetTimer, CloseHelpGUIWindow, Off
   HideHelpGUI()
Return

HideHelpGUI() {
   global HelpGUI
   transp := 240
   Loop, 20
   {
      transp := transp - 12
      WinSet, Transparent, %transp%, ahk_id %HelpGUI%
      sleep,15
   }
   Gui, Hide
   Gui, Destroy
}


Looks like:
ImageAuthotkey Keybinding Help Window by thinkstorm, on Flickr

_________________
Cheers,

Thorsten


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Awesome script
PostPosted: April 28th, 2011, 11:04 pm 
Offline

Joined: April 22nd, 2011, 9:38 pm
Posts: 1
I'm pretty new to AHK and your script really helps me keep track of all the new functionality I am adding to my script.

Only tweak I am working on figuring out how to make is a way to make a hotkey show in the summary list of hotkeys but not pop its definition up when the hotkey itself is pressed (for hotkeys I use a LOT, and repeatedly when I do). Don't think I'll be able to do this by copying and changing the ShowOSD() function and replacing the function calls in those hotkeys with the modified function like I initially thought, though.

Anyway, the main thing I was wondering is if you could post the full script, or email it to me, with all of the hotkeys shown in your screenshot. A lot of them look really useful to me, and I'd like to use them myself! Already implemented some of the easier ones, but copying is much faster... ;o)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 29th, 2011, 5:34 am 
Offline

Joined: August 17th, 2004, 7:05 pm
Posts: 38
You could search for an alternative tag, or you could modify the script to use "showOSD" to show the On-Screen-Display, and move all descriptions into a new tag like ";;;<description here>" and search for the three ";" at the start of the line instead :)

Here is the code of the complete script. Please note that there are a lot of commented-out lines in it - some helpers I might need at some point. Also, I would be surprised if the script actually runs on your machine: some of the hotkeys are workarounds for a German OS, some are for specific applications or fonts, and you probably have to adjust the code a lot. But hey, at least you can :)

Code:
; #############################################################################
;
; CONTROL:   ^
; ALT:      !
; SHIFT:   +
;

#SingleInstance Force
#HotkeyModifierTimeout 100
#HotkeyInterval, 1000  ; This is  the default value (milliseconds).
#MaxHotkeysPerInterval, 100
SetWinDelay 10
SetKeyDelay 0

;C:\Programme\Minefield\firefox.exe
;C:\Programme\Mozilla Firefox\firefox.exe
C_BROWSER="C:\Programme\Mozilla Firefox\firefox.exe"
C_CHROME="D:\Dokumente und Einstellungen\claus.thorsten\Lokale Einstellungen\Anwendungsdaten\Google\Chrome\Application\chrome.exe" --proxy-server=
C_APPDIR=D:\Data\Dropbox\Applications
RegRead, ahk_dir, HKEY_LOCAL_MACHINE, SOFTWARE\AutoHotkey, InstallDir


; #####################################################################
; TRAY MENU SETUP
; #####################################################################

Menu, Tray, Icon, %A_WorkingDir%\thinkstorm_autohotkey.ico

; #############################################################################
; Fun with Linkedin
; #############################################################################
/*
linkedInID :=481
linkedInStart:=0
linkedInMouseX:=0
linkedInMouseY:=0

^#l::
   if (linkedInStart=1) {
      SetTimer, linkedIn, Off
      linkedInStart:=0
   } else {
      MouseGetPos, linkedInMouseX, linkedInMouseY
      PixelGetColor, linkedInColor, %linkedInMouseX%, %linkedInMouseY%
      ToolTip, color under mouse is %linkedInColor% - I will stop once this color changes....
      SetTimer, RemoveToolTip, 2000
      SetTimer, linkedIn, 2200
      linkedInStart:=1
   }
Return

+^#l::
   linkedInID :=481
   ToolTip, stop and reset linkedin Start profile number
   SetTimer, RemoveToolTip, 2000
   linkedInStart:=0
   setTimer, linkedIn, Off
Return
*/
; #############################################################################
; Search
; #############################################################################
/*
C_MILLISECONDS := 250
CtrlKeyDown := 0

~RCtrl Up::
   currentTime := A_TickCount
   elapsedTime := currentTime - CtrlKeyDown
   CtrlKeyDown := currentTime
   if (elapsedTime <= C_MILLISECONDS)
   {
      Process, Exist, searchindexer.exe
      If (ErrorLevel <> 0) {
         SendInput, #+f
      }
   }
Return
*/

RestoreX1Window()
{
   ; title: X1 - ....
   ; class: TApplication
   DetectHiddenWindows, On
   SetTitleMatchMode, 1
   WinGet, hwnd, ID, X1 - ahk_class HwndWrapper
   If hwnd
   {
      WinRestore, ahk_id %hwnd%
      WinActivate, ahk_id %hwnd%
      ;alternative hard-core WinActivate SendMessage, 0x112, 0xf120,,,ahk_id %hwnd%
   } else {
      Run, C:\Programme\X1\X1.exe
   }
}

RestoreExaleadWindow()
{
   global C_CHROME
   SetTitleMatchMode, 2
   WinGet, hwnd, ID, Exalead one:desktop ahk_class Chrome_WidgetWin_0
   ;ahk_class MozillaWindowClass
   if hwnd
   {
      WinRestore, ahk_id %hwnd%
      WinActivate, ahk_id %hwnd%
   } else {
      ;command = %C_CHROME% "http://localhost:17600/search/homepage"
      Run, "D:\Dokumente und Einstellungen\Claus.Thorsten\Lokale Einstellungen\Anwendungsdaten\Google\Chrome\Application\chrome.exe" --app="http://localhost:17600/search/homepage"
   }
}


^!+x::
   showOSD("Restore Exalead Window")
   RestoreExaleadWindow()
Return

^!x::
   showOSD("Restore X1 Window")
   RestoreX1Window()
Return


; #############################################################################
; Documents
; #############################################################################


#LALT:: AppsKey

#1::
   ShowOSD("Start Outlook")
   Run, "C:\Programme\Microsoft Office\OFFICE12\OUTLOOK.EXE" /recycle
Return

#2::
   ShowOSD("Start Picasa")
   Run, C:\Programme\Google\Picasa3\Picasa3.exe
Return


#6::
   ShowOSD("Open user root directory")
   Run, C:\WINDOWS\explorer.exe "D:\Dokumente und Einstellungen\claus.thorsten"
Return
#7::
   ShowOSD("Open Dropbox directory")
   Run, C:\WINDOWS\explorer.exe "D:\data\Dropbox"
Return
#8::
   ShowOSD("Open user data directory")
   Run, C:\WINDOWS\explorer.exe "D:\data"
Return
#9::
   ShowOSD("Open Dropbox documents directory")
   Run, C:\WINDOWS\explorer.exe "D:\data\Dropbox\Documents"
Return
#0::
   ShowOSD("Open documents directory")
   Run, C:\WINDOWS\explorer.exe "D:\data\Documents"
Return

#e::
   ShowOSD("Start windows explorer")
   Run, c:\windows\explorer.exe ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}
Return

; #############################################################################
; Autohotkey Helpers: script editing, help, on/off, etc.
; #############################################################################

#F12::
   showOSD("Edit Autohotkey Settings File")
   Edit                            ; open current script file
Return

reloadFile := 0
#^F12::
   reloadFile := 1
   showOSD("Reload Autohotkey Settings File")
Return

#^+F12::
   ShowOSD("Run Autohotkey window spy")
   Run, %ahk_dir%\AU3_Spy.exe   ; spy window title, class, hidden text,  etc.
Return

#F11::
   ShowOSD("Run AutoScriptWriter")
   Run, %ahk_dir%\AutoScriptWriter\AutoScriptWriter.exe    ; quick record script
Return

#+F12::
   showOSD("Show AutoHotkey Help")
   IfWinNotExist, AutoHotkey Help
   {
      ; Use non-abbreviated root key to support older versions of AHK:
      RegRead, ahk_dir, HKEY_LOCAL_MACHINE, SOFTWARE\AutoHotkey, InstallDir
      If ErrorLevel <> 0
      {
         ; Older versions of AHK might not have the above registry entry,
         ; so use a best guess location instead:
         ahk_dir = %ProgramFiles%\AutoHotkey
      }
      ahk_help_file = %ahk_dir%\AutoHotkey.chm
      IfNotExist, %ahk_help_file%
      {
         MsgBox, Could not find the help file: %ahk_help_file%.
         Return
      }
      Run, %ahk_help_file%
      WinWait, AutoHotkey Help , , 10
   }
   Else
   {
      WinActivate, AutoHotkey Help
   }
Return


; #############################################################################
; WINDOWS SETTINGS
; #############################################################################

#c::
   ShowOSD("Open command line")
   Run, c:\windows\system32\cmd.exe, c:\
Return

#s::
   ShowOSD("Open system control panel")
   Run, control
Return

#i::
   ShowOSD("Open network connections")
   Run, control ncpa.cpl
Return

; #############################################################################
; FONTS
; #############################################################################

#t::
   showOSD("Start Windows Charmap")
   Run, C:\WINDOWS\system32\charmap.exe
Return

#+t::
   showOSD("Show Font List (NexusFont)")
   Run, %C_APPDIR%\NexusFont2.5\NexusFont.exe
Return

; #############################################################################
; Applications
; #############################################################################

#q::
   ShowOSD("Start Microsoft Internet Explorer Browser")
   Run, c:\programme\Internet Explorer\iexplore.exe
Return

#^q::
   ShowOSD("Start Google Chrome Browser")
   Run,%C_CHROME%
Return

#+q::
   ShowOSD("Start Google Chrome Browser")
   Run,%C_CHROME%
Return

#w::
   ShowOSD("Start Mozilla Firefox Browser")
   Run, %C_BROWSER%
Return

#n::
   ShowOSD("Start Scite")
   Run, C:\Programme\Scite\Scite.EXE
Return

#IfWinActive, ahk_class MozillaWindowClass
~!F4::
   ShowOSD("Close Firefox")
   command = nircmd.exe waitprocess "firefox.exe" trayballoon "" "Firefox Closed." "shell32.dll,-1001" 2000
   Run, %command%
Return
#IfWinActive

#IfWinActive, ahk_class Chrome_WidgetWin_0
~!F4::
   ShowOSD("Close Chrome")
   command = nircmd.exe waitprocess "chrome.exe" trayballoon "" "Chrome Closed." "shell32.dll,-1001" 2000
   Run, %command%
Return
#IfWinActive

#IfWinActive, ahk_class IEFrame
~!F4::
   ShowOSD("Close Microsoft Internet Explorer")
   command = nircmd.exe waitprocess "iexplore.exe" trayballoon "" "Internet Explorer Closed." "shell32.dll,-1001" 2000
   Run, %command%
Return
#IfWinActive

; #############################################################################
; MICROSOFT OUTLOOK
; #############################################################################

/*
    * /c ipm.activity creates a Journal entry
    * /c ipm.appointment creates an appointment
    * /c ipm.contact creates a contact
    * /c ipm.note creates an e-mail message
    * /c ipm.stickynote creates a note
    * /c ipm.task creates a task
*/

SetTitleMatchMode, 2
#IfWinActive, ahk_class rctrl_renwnd32

^+R::
   ShowOSD("reply to all")
   SendInput, !al
Return

#IfWinActive


#F5::
   showOSD("Outlook: New Email")
   Run, "C:\Programme\Microsoft Office\OFFICE12\OUTLOOK.EXE" /c ipm.note
Return

#F6::
   showOSD("Outlook: New Task")
   Run, "C:\Programme\Microsoft Office\OFFICE12\OUTLOOK.EXE" /c ipm.task
Return

#F7::
   showOSD("Outlook: New Appointment")
   Run, "C:\Programme\Microsoft Office\OFFICE12\OUTLOOK.EXE" /c ipm.appointment
Return

#F8::
   showOSD("Outlook: New Sticky Note")
   Run, "C:\Programme\Microsoft Office\OFFICE12\OUTLOOK.EXE" /c ipm.stickynote
Return

#F9::
   showOSD("Outlook: New Contact")
   Run, "C:\Programme\Microsoft Office\OFFICE12\OUTLOOK.EXE" /c ipm.contact
Return

#F10::
   showOSD("Outlook: New Journal Entry")
   Run "C:\Programme\Microsoft Office\OFFICE12\OUTLOOK.EXE" /c ipm.activity
Return




; #############################################################################
; Move Windows with Mouse
; #############################################################################

#!F12::
   ShowOSD("Toggle Alt + mouse buttons")
   GoSub, ToggleAltLRButtons
Return

noAltMouseButtons() {
   SetTitleMatchMode, 2
   IfWinActive, ahk_class PSDocC
      Return True
   IfWinActive, ahk_class Photoshop
      Return True
   IfWinActive, Windows Live Photo Gallery
      Return True
   IfWinActive, Picasa 3
      Return True
   IfWinActive, Paint.NET v3.36
      Return True
   Return False
}

;Move Window
$!LButton::
   If (noAltMouseButtons()) {
      SendInput, !{LButton}
   } else {
      Gosub, AltLButton
   }
Return

; Always On Top Window
$!MButton::
   If (noAltMouseButtons()) {
      SendInput, !{MButton}
   } else {
      Gosub, AltMButton
   }
Return

; Resize Window
$!RButton::
   If (noAltMouseButtons()) {
      SendInput, !{RButton}
   } else {
      Gosub, AltRButton
   }
Return


; #############################################################################
; COPY & PASTE HELPER
; #############################################################################


; Trim to one single line with spaces
#^v::
   showOSD("Trim to single line with spaces")
   AutoTrim, On
   clipped = %clipboard%
   clipped := RegExReplace(clipped, "[\s\a\e\f\v]+", " ")
   clipboard = %clipped%
   SendInput, ^{v}
Return

; Paste Special in MSOffice
#^+v::
   showOSD("paste special in MS Office")
   SendInput, !{e}{s}{END}{RETURN}
Return

/*
#=::
   showOSD("Call Using Google Voice")
   ; get clipboard content
   AutoTrim, On
   clipboard = ; Empty the clipboard
   Send, ^c
   ClipWait, 2
   if ErrorLevel
   {
      MsgBox, The attempt to copy text onto the clipboard failed.
      return
   }
   clipped = %clipboard%
   clipped := RegExReplace(clipped, "[^0-9+-]","")
   clipped := RegExReplace(clipped, "\+\++","+")
   clipped := RegExReplace(clipped, "^\+1","")
   If (StrLen(clipped)<7)
   {
      MsgBox, Not a phone number.
      Return
   }
   ; open Google Voice Chrome App
   SetTitleMatchMode, 1
   ifWinNotExist, Google Voice ahk_class Chrome_WindowImpl_0
   {
      Run, "%C_CHROME%" --app=https://www.Google.com/voice
   }
   else
   {
      WinActivate
   }
   wintitle=Google Voice ahk_class Chrome_WindowImpl_0
   WinWaitActive,%wintitle%,,10
   if ErrorLevel
   {
      MsgBox, Could not open Google Voice Chrome Application.
      Return
   }
   ; wait until it is loaded (id'ed by color change), a maximum of 10 seconds
   sec=0
   color=0xffffff
   PixelGetColor, color, 27, 109
   while (color=0xffffff)
   {
      if (sec++ > 10)
      {
         MsgBox, Google Voice Loading Timeout
         Return
      }
      Sleep, 1000
      PixelGetColor, color, 27, 109
   }
   ;see if you need to click the call button
   PixelGetColor, color, 53, 342
   if (color<>0xE3E3E3)
   {
      Click, 51, 113 ;click call button
      Sleep, 300
   }
   PixelGetColor, color, 53, 342
   if (color<>0xE3E3E3)
   {
      MsgBox, Google Voice Call Button Timeout
      Return
   }
   ; fill out call form
   Click, 29,221 ;phone number field
   SendInput, ^a
   SendRaw, %clipped%
   Click, 41, 284 ;select phone to call
   Send, {home}
;   Send, {Down}
   Send, {enter}
   Click, 52, 335 ;press 'connect' button
Return
*/

; #############################################################################
; SEARCH
; #############################################################################

RunInternetSearch(linkStart,linkEnd) {
   AutoTrim, On
   searchTerm = %clipboard%
   If searchTerm =
   {
      MsgBox, 48, Search Internet, No text in clipboard to search., 2
      Return
   }
   searchTerm := RegExReplace(searchTerm, "[\s&]+", "+")
   searchTerm = %linkStart%%searchTerm%%linkEnd%
   Run, %searchTerm%
}

#g::
   showOSD("lookup clipboard text in Google")
   linkStart=%C_BROWSER% "http://www.Google.com/search?complete=1&hl=en&q=
   linkEnd=&btnG=Google+Search"
   RunInternetSearch(linkStart,linkEnd)
Return

#+g::
   showOSD("lookup definition of clipboard text in Google")
   linkStart=%C_BROWSER% "http://www.Google.com/search?sourceid=navclient&ie=UTF-8&oe=UTF-8&q=define:
   linkEnd="
   RunInternetSearch(linkStart,linkEnd)
Return

; THESAURUS
#^+t::
   showOSD("lookup thesaurus of clipboard text in Google")
   linkStart=%C_BROWSER% "http://thesaurus.reference.com/browse/
   linkEnd="
   RunInternetSearch(linkStart,linkEnd)
Return

; TRANSLATION
#^t::
   showOSD("lookup translation of clipboard text in dict.cc")
   linkStart=%C_BROWSER% "http://www.dict.cc/?s=
   linkEnd="
   RunInternetSearch(linkStart,linkEnd)
Return

#IfWinNotActive, ahk_class OpusApp

   ^!+g::
      ShowOSD("lookup thesaurus of clipboard text in reference.com")
      linkStart= %C_BROWSER% "http://thesaurus.reference.com/browse/
      linkEnd="
      RunInternetSearch(linkStart,linkEnd)
   Return

#IfWinNotActive

; #############################################################################
; WinWord Adjust Picture Inline, Width, Border, Paragraph Style
; #############################################################################
; DD  01B       d   0.94   ] 
; DB  01A       u   0.11   [
#IfWinActive, ahk_class OpusApp

   ^,::
      ShowOSD("WinWord: smaller font")
;      KeyWait, Control
      SetKeyDelay, 0
      SendEvent, !hfs{down}{up}{enter}
   Return
   
   ^.::
      ShowOSD("WinWord: larger font")
;      KeyWait, Control
      SetKeyDelay, 0
      SendEvent, !hfs{down}{down}{enter}      
   Return

   ^!+g::
      showOSD("Winword: Synonyms")
      SendInput, {AppsKey}{y}
   Return

   ^!+l::
      showOSD("WinWord: Open 'Advanced Layout' for pictures")
      SendInput, {ALT Down}{p}{p}{o}{l}{ALT UP}
   Return


   #p::
      showOSD("WinWord: format picture")
      SetKeyDelay, 100
      Send, {ALT}o
      Send, i
      WinWaitActive, Format Picture,,5
      If ErrorLevel <> 0
      {
         MsgBox, 48, format pic, cannot open Word format picture dialog!, 3
         Return
      }
      ControlClick, x184 y39, Format Picture
      ControlClick, x51 y102, Format Picture
      ControlClick, x131 y40, Format Picture
      Send, !d
      Send, 5.75
      Send, {ENTER}
      Send, !o
      Send, b
      WinWaitActive, Borders,,5
      If ErrorLevel <> 0
      {
         MsgBox, 48, format pic, cannot open Word borders dialog!, 3
         Return
      }
      Send, !a
      Send, {ENTER}
      Send, {Right}
      Send, ^+s
      Send, Picture
      Send, {ENTER}
   Return

#IfWinActive
;end of conditional WinWord Hotkey

; #############################################################################
; Uppercase, Lowercase
; #############################################################################

#-::
   showOSD("copy current selection and make lowercase")
   AutoTrim, On
   clipboard = ; Empty the clipboard
   SendInput, ^c
   ClipWait, 2
   if ErrorLevel
   {
      MsgBox, The attempt to copy text onto the clipboard failed.
      return
   }
   txt = %clipboard%
   StringLower, clipboard, txt
   SendInput, ^v
Return
   
#_::
   showOSD("Copy Current Selection And Start Words Uppercase")
   KeyWait, Shift
   AutoTrim, On
   clipboard = ; Empty the clipboard
   SendInput, ^c
   ClipWait, 2
   if ErrorLevel
   {
      MsgBox, The attempt to copy text onto the clipboard failed.
      return
   }
   txt = %clipboard%
   StringUpper, clipboard, txt, T
   SendInput, ^v
Return

; #############################################################################
; Microsoft Powerpoint Common Features
; #############################################################################

SetTitleMatchMode, 1
#IfWinActive, Microsoft PowerPoint

   ;Excel-like editing of  Auto-Shape Properties
   ^1::
      showOSD("PowerPoint: auto-shape properties")
      KeyWait, Control
      Send, {AppsKey}{o}
   Return

   ;Bottom Layer
   ^m::
      showOSD("PowerPoint: make bottom layer")
      KeyWait, Control
      KeyWait, Shift
      SetKeyDelay, 150
      Send, !h
      Send, g
      Send, k
   Return

   ;Lower Layer
   ^,::
      showOSD("PowerPoint: move to lower layer")
      KeyWait, Control
      SetKeyDelay, 150
      Send, !h
      Send, g
      Send, b
   Return

   ;Higher Layer
   ^.::
      showOSD("PowerPoint: move to higher layer")
      KeyWait, Control
      SetKeyDelay, 150
      Send, !h
      Send, g
      Send, f
   Return

   ;Top Layer
   ^-::
      showOSD("PowerPoint: make top-most layer")
      KeyWait, Control
      KeyWait, Shift
      SetKeyDelay, 150
      Send, !h
      Send, g
      Send, r
   Return

/*
   ;Zoom Out
   ^9::
      showOSD("PowerPoint: zoom out")
      KeyWait, Control
      SetKeyDelay, 150
      Send, !{w}{q}!{p}{PgDn}{Enter}
   Return

   ;Zoom In
   ^0::
      showOSD("PowerPoint: zoom in")
      KeyWait, Control
      SetKeyDelay, 150
      Send, !{w}{q}!{p}{PgUp}{Enter}
   Return

   ;Zoom 100%
   ^+!9::
      showOSD("PowerPoint: zoom 100%")
      KeyWait, Control
      KeyWait, Shift
      KeyWait, Alt
      BlockInput, On   
      SetKeyDelay, 150
      Send, !w
      Send, q
      Send, !1
      Send, {Enter}
      BlockInput, Off
   Return

   ;Zoom Fit
   ^+!0::
      showOSD("PowerPoint: zoom to fit")
      KeyWait, Control
      KeyWait, Shift
      KeyWait, Alt
      BlockINput, On
      SetKeyDelay, 150
      Send, !v
      Send, z
      Send, !f
      Send, {Enter}
      BlockInput, Off
   Return

   ;Zoom Dialog
   ^+!_::
      showOSD("PowerPoint: show zoom dialog")
      KeyWait, Control
      KeyWait, Shift
      KeyWait, Alt
      BlockInput, On
      SetKeyDelay, 150
      Send, !w
      Send, q
      BlockInput, Off
   Return

*/

   ^_::
      showOSD("PowerPoint: insert non-breaking dash")
      KeyWait, Control
      KeyWait, Shift
      SendInput, {U+00AD}
   Return
   
   ^+space::
      showOSD("PowerPoint: insert non-braking space")
      KeyWait, Control
      KeyWait, Shift
      Send, {U+00A0}
   Return

/*
   ;Line Space Dialog
   ^+!l::
      showOSD("PowerPoint: open line height and space dialog")
      KeyWait, Control
      KeyWait, Shift
      KeyWait, Alt
      BlockInput, On
      SetKeyDelay, 150
      Send, !h
      Send, k
      Send, l
      BlockInput, Off
   Return

   ;Narrower Line Space
   ^`;::
      showOSD("PowerPoint: narrower line space")
      KeyWait, Control
      BlockInput, On
      SetKeyDelay, 50
      Send, !h
      Send, k
      Send, l
      WinWaitActive, Paragraph,,5
      If ErrorLevel <> 0
      {
         BlockInput, Off
         Return
      }
      Send, !n
      Send, e
      Send, {enter}
      Send, !a
      Send, {down}
      Send, {enter}
      BlockInput, Off
   Return

   ;Wider Line Space
   ^'::
      showOSD("PowerPoint: wider line space")
      KeyWait, Control
      BlockInput, On
      SetKeyDelay, 50
      Send, !h
      Send, k
      Send, l
      WinWaitActive, Paragraph,,5
      If ErrorLevel <> 0
      {
         BlockInput, Off
         Return
      }
      Send, !n
      Send, e
      Send, {enter}
      Send, !a
      Send, {up}
      Send, {enter}
      BlockInput, Off
   Return

   ;decrease Space Before Paragraph
   ^+`;::
      showOSD("PowerPoint: decrease space before paragraph")
      KeyWait, Control
      KeyWait, Shift
      BlockInput, On
      SetKeyDelay, 150
      Send, !hkl
      WinWaitActive, Paragraph,,5
      If ErrorLevel <> 0
      {
         BlockInput, Off
         Return
      }
      Send, !b{down}{enter}
      BlockInput, Off
   Return

   ;increase Space Before Paragraph
   ^+'::
      showOSD("PowerPoint: increase space before paragraph")
      KeyWait, Control
      KeyWait, Shift
      BlockInput, On
      SetKeyDelay, 150
      Send, !hkl
      WinWaitActive, Paragraph,,5
      If ErrorLevel <> 0
      {
         BlockInput, Off
         Return
      }
      Send, !b{up}{enter}
      BlockInput, Off
   Return

   ;decrease Space After Paragraph
   ^+!`;::
      showOSD("PowerPoint: decrease space after paragraph")
      KeyWait, Control
      KeyWait, Shift
      KeyWait, Alt
      BlockInput, On
      SetKeyDelay, 150
      Send, !hkl
      WinWaitActive, Paragraph,,5
      If ErrorLevel <> 0
      {
         BlockInput, Off
         Return
      }
         Send, !e{down}{enter}
      BlockInput, Off
   Return

   ;increase Space After Paragraph
   ^+!'::
      showOSD("PowerPoint: increase space after paragraph")
      KeyWait, Control
      KeyWait, Shift
      KeyWait, Alt
      BlockInput, On
      SetKeyDelay, 150
      Send, !hkl
      WinWaitActive, Paragraph,,5
      If ErrorLevel <> 0
      {
         BlockInput, Off
         Return
      }
      Send, !e{up}{enter}
      BlockInput, Off
   Return

*/

   ^+!h::
      showOSD("PowerPoint: evenly space selected shapes horizontally")
      KeyWait, Control
      KeyWait, Shift
      KeyWait, Alt
      BlockInput, On
      SetKeyDelay, 150
      Send, {alt}
      Send, jdaah
      BlockInput, Off
   Return

   ^+!v::
      showOSD("PowerPoint: evenly space selected shapes vertically")
      KeyWait, Control
      KeyWait, Shift
      KeyWait, Alt
      BlockInput, On
      SetKeyDelay, 150
      Send, {alt}
      Send, jdaav
      BlockInput, Off
   Return

/*
   ^!e::
      ShowOSD("PowerPoint: input EURO sign")
      SendInput, €
   Return

*/
   ^!+e::
      showOSD("PowerPoint: set language to 'English'")
      KeyWait, Control
      KeyWait, Shift
      KeyWait, Alt
      BlockInput, On
      SendInput,!ru
      WinWaitActive,Language,,5
      If Errorlevel <> 0
      {
         BlockInput, Off
         Return
      }
      SendInput,{Home}e{enter}
      BlockInput, Off
   Return

#IfWinActive

; #############################################################################
; Microsoft Powerpoint DTAG Features
; #############################################################################

SetTitleMatchMode, 1
#IfWinActive, XYZMicrosoft PowerPoint

   ;Line Space Dialog, fill with presets
   ^l::
      showOSD("PowerPoint: set default line height and spaces")
      KeyWait, Control
      BlockInput, On
      SetKeyDelay, 150
      Send, !h
      Send, k
      Send, l
      WinWaitActive, Paragraph,,5
      If ErrorLevel <> 0
      {
         BlockInput, Off
         Return
      }
      Send, !b
      Send, 5.5pt
      Send, !e
      Send, 0
      Send, !n
      Send, {pgdn}
      Send, {enter}
      Send, !a
      Send, 0.87
      Send, {enter}
      BlockInput, Off
   Return

   ^b::
      showOSD("PowerPoint: Set Font Tele-GroteskFet")
      KeyWait, Control
      BlockInput, On
      SetKeyDelay, 150
      Send, ^+f
      WinWaitActive, Font,,5
      If ErrorLevel <> 0
      {
         BlockInput, Off
         Return
      }
      Send, !yr{enter}!f
      SendInput, Tele-GroteskFet
      Send, {enter}
      BlockInput, Off
   Return
   
   ^n::
      showOSD("PowerPoint: Set Font Tele-GroteskNor")
      KeyWait, Control
      BlockInput On
      SetKeyDelay, 150
      Send, ^+f
      WinWaitActive, Font,,5
      If ErrorLevel <> 0
      {
         BlockInput, Off
         Return
      }
      Send, !yr{enter}!f
      SendInput, Tele-GroteskNor
      Send, {enter}
      BlockInput, Off
   Return

   ^+n::
      showOSD("PowerPoint: Set Font Tele-GroteskHal")
      KeyWait, Control
      KeyWait, Shift
      BlockInput On
      SetKeyDelay, 150
      Send, ^+f
      WinWaitActive, Font,,5
      If ErrorLevel <> 0
      {
         BlockInput, Off
         Return
      }
      Send, !yr{enter}!f
      SendInput, Tele-GroteskHal
      Send, {enter}
      BlockInput, Off
   Return

#IfWinActive
;End Of Conditional PowerPoint Hotkey

; #############################################################################
; Excel Hotkeys
; #############################################################################

SetTitleMatchMode, 1

#IfWinActive,Microsoft Excel

   ^?::
      ;Evaluate Formula
      KeyWait, Control
      showOSD("Excel: evaluate formula")
      SendInput, !tuf
   Return

   ^,::
      ; Trace Preceeding Cells
      KeyWait, Control
      showOSD("Excel: trace preceeding cells")
      SendInput, !mp
   Return

   ^.::
      ; Trace Dependents Cells
      KeyWait, Control
      showOSD("Excel: trace dependent cells")
      SendInput, !md
   Return

   ^m::
      ; Clear Tracing
      KeyWait, Control
      showOSD("Excel: clear tracing of cells")
      SendInput, !maa
   Return

   ^+)::
      ;Workaround to hide cells...
      KeyWait, Control
      KeyWait, Shift
      ShowOSD("Excel: hide cells")
      SetTitleMatchMode, 1
      ControlSend,,^+),Microsoft Excel
   Return

/*
#z::
      Loop, 7 ; Rows
      {
         Loop, 4 ; Colums
         {
            Send, {F2}
            SendInput, {)}{Home}{Right}Zero({Tab}
         }
         SendInput, {Return}
      }   
   Return
*/

#IfWinActive

;End Of Conditional Excel Hotkey


; #############################################################################
; Internet Explorer Hotkeys
; #############################################################################

SetTitleMatchMode, 2
#IfWinActive, ahk_class IEFrame

!^+i:: ;toggle proxy settings
   showOSD("Internet Explorer: toggle proxy settings")
   RootKey = HKEY_CURRENT_USER
   SubKey  = Software\Microsoft\Windows\CurrentVersion\Internet Settings
   RegRead, proxyEnable, % RootKey, % SubKey, ProxyEnable
   If (proxyEnable = 0)
   {
      RegWrite, REG_DWORD, % RootKey, % SubKey, ProxyEnable, 1
;      RegWrite, REG_SZ, % RootKey, % SubKey, ProxyServer, proxy.detecon.biz:80
      MsgBox, 0, Set Internet Explorer Proxy, Internet Explorer Proxy is -->ON<--,2
   } else {
      RegWrite, REG_DWORD, % RootKey, % SubKey, ProxyEnable, 0
      MsgBox, 0, Set Internet Explorer Proxy, Internet Explorer Proxy is OFF.,2
   }
   dllcall("wininet\InternetSetOptionW","int","0","int","39","int","0","int","0")
   dllcall("wininet\InternetSetOptionW","int","0","int","37","int","0","int","0")
Return

#IfWinActive
;End Of Conditional Internet Explorer Hotkeys

; #############################################################################
; Windows Explorer
; #############################################################################

SetTitleMatchMode, 1
#IfWinActive, ahk_class CabinetWClass

hiddenFiles:=0
#h::
   SetKeyDelay, 75
   KeyWait, LWin
   BlockInput, On
   Send, !xo
   WinWaitActive, Ordneroptionen,,2
   If (ErrorLevel <> 0)
      Return
   Click, 90, 38
   Send, {tab 2}
   Send, {down 19}
   if (hiddenFiles = 0)
   {
      hiddenFiles := 1
      showOSD("Explorer: SHOW hidden files")
   } else {
      Send, {down}
      hiddenFiles := 0
      showOSD("Explorer: HIDE hidden files")
   }
   Send, {Space}{tab 2}{Enter}
   BlockInput, Off
Return

^#h::
   SetKeyDelay, 75
   KeyWait, Control
   KeyWait, LWin
   showOSD("Explorer: Toggle Filename Extensions")
   BlockInput, On
   Send, !xo
   WinWaitActive, Ordneroptionen,,2
   If (ErrorLevel <> 0)
      Return
   Click, 90, 38
   Send, {tab 2}
   Send, {down 6}
   Send, {Space}{tab 2}{Enter}
   BlockInput, Off
Return

^t::
      KeyWait, Control
      BlockInput, On
      ShowOSD("Explorer: Open new window")
      SendInput, !s
      Sleep, 250
      clipboard =
      SendInput, ^c
      ClipWait, 1
      if ErrorLevel = 0
      {
         clip = "%clipboard%"
         Run, explorer.exe %clip%
      } else {
         MsgBox,,Autohotkey,Can't start explorer,2
      }
      BlockInput, Off
Return

!d::
   ShowOSD("Explorer: Select 'Adresse' path")
   sendInput, !s
Return

!f::
   ShowOSD("Explorer: select 'Datei' menu")
   Click, 24, 40
Return

^+v::
   ShowOSD("Explorer: Move file to folder ...")
   SendInput,!bv
   WinWaitActive, Elemente Verschieben,,1
   If (ErrorLevel<>0) Return
   Sendinput, ^+{tab}^+{tab}
Return

#IfWinActive

; #############################################################################
; Desktop
; #############################################################################

SetTitleMatchMode, 1
#IfWinActive, ahk_class Progman
^t::
   ShowOSD("Explorer: open new window")
   Run, Explorer.exe "D:\data"
Return
#IfWinActive

SetTitleMatchMode, 1
#IfWinActive, ahk_class WorkerW
^t::
   ShowOSD("Explorer: open new window")
   Run, Explorer.exe "D:\data"
Return
#IfWinActive

; #############################################################################
; Windows Media Player
; #############################################################################

SetTitleMatchMode, 1
#IfWinActive, Windows Media Player
^1::
   showOSD("Media Player: track properties")
   SendInput, {AppsKey}{v}
Return
#IfWinActive

; #############################################################################
; Windows Live Writer
; #############################################################################

SetTitleMatchMode, 2
#IfWinActive, ahk_class WindowsForms10.Window.8.app.0.33c0d9d

^!f::
   CoordMode, Mouse, Relative
   MouseGetPos, mxpos, mypos
   Click, 113, 95
   MouseMove, mxpos, mypos
Return

^!q::
   CoordMode, Mouse, Relative
   MouseGetPos, mxpos, mypos
   Click, 367, 99
   MouseMove, mxpos, mypos
Return

^!1::
   CoordMode, Mouse, Relative
   MouseGetPos, mxpos, mypos
   Click, 113, 95
   SendInput, {home}{Return}
   MouseMove, mxpos, mypos
Return

^!2::
   CoordMode, Mouse, Relative
   MouseGetPos, mxpos, mypos
   Click, 113, 95
   SendInput, {home}{down}{Return}
   MouseMove, mxpos, mypos
Return

^!3::
   CoordMode, Mouse, Relative
   MouseGetPos, mxpos, mypos
   Click, 113, 95
   SendInput, {home}{down}{down}{Return}
   MouseMove, mxpos, mypos
Return

^+n::
   CoordMode, Mouse, Relative
   MouseGetPos, mxpos, mypos
   Click, 113, 95
   SendInput, {end}{Return}
   MouseMove, mxpos, mypos
Return


#IfWinActive

; #######################################
; Collect Current Keybindings by Thinkstorm
; #######################################

removeSpecialModifier(string, modifier) {
   str := Trim(string)
   pos := inStr(str,modifier)
   if (pos=0) {
      return str
   }
   if (pos=1) {
      return substr(str,2)
   }
}

#?::
   SetTitleMatchMode, 2
   mode:=0 ;0 for global bindings, 1 for local bindings
   binding0:= 0
   binding1 := 0
   command := ""
   comment:=false
   notrelevant:=false
   line=""
   l=""
   str=""
   Loop, Read, %A_ScriptFullPath%
   {
      ; --------------- DEAL WITH COMMENTS ---------------
      l := Trim(A_LoopReadLine)
      StringLeft, str, l, 2
      if (str="/*") {
         StringRight, str, l, 2
         if (str<>"*/")   {
            comment:=true ; comment starts
         }
         continue
      }
      if (comment) {
         StringRight, str, l, 2
         if (str="*/") {
            comment:=false ; end of comment
         }
         continue
      }
      ; --------------- DEAL WITH LOCAL KEY BINDINGS ---------------
      if (InStr(l, "#IfWinActive")=1) {
         StringSplit, str, l, `,
         if (str0=1) { ; end of #ifWinActive statement
            ;debug MsgBox,,#ifWinActive,end of #ifWinActive block,1
            mode:=0
            notrelevant := false
            continue
         }
         tmp = %str2%
         IfWinActive, %tmp%
         {
            ;MsgBox,,#ifWinActive relevant,#ifWinActive block for "%tmp%"
            mode := 1
            notrelevant := false
         } else {
            ;MsgBox,,#ifWinActive not relevant,#ifWinActive block for "%tmp%",1
            mode := 0
            notrelevant := true
         }
         continue
      }
      if (notrelevant) {
         continue ;skip lines that are not meant for the currently active window
      }
      ; --------------- SEARCH FOR KEY BINDINGS ---------------
      StringRight, str, l, 2
      if (str="::") {
         command := ""
         str := Trim(substr(l,1,InStr(l,"::")-1))       ; remove "::"
         if (str="#?") {
            ; this keystroke - ignore
            continue
         }
         str := removeSpecialModifier(str,"~")      ; remove the pass-through modifier
         str := removeSpecialModifier(str,"$")         ; remove the send-to-self modifier
         StringReplace, str, str, `` ; remove first escape character (in case you use ` as a key binding :))
         ; translate key bindings into standard text abbreviations #,CTRL,ALT,SHIFT,ANY
         if (inStr(str,"#")) {
            StringReplace,str,str,#
            command := command . "#+"
         }
         if (inStr(str,"^")) {
            StringReplace,str,str,^
            command := command . "CTRL+"
         }
         if (inStr(str,"!")) {
            StringReplace,str,str,!
            command := command . "ALT+"
         }
         if (inStr(str,"+")) {
            StringReplace,str,str,+
            command := command . "SHIFT+"
         }
         if (inStr(str,"*")) {
            StringReplace,str,str,*
            command := command . "ANY+"
         }
         command := command . str
         continue
      }
      ; --------------- SEARCH FOR OSD HELP TEXT ---------------
      pos := inStr(l,"showOSD(")
      If (pos) {
         if (command="") {
            continue ;UPS - an OSD without any identified command? must be an error in this script... ignore
         }
         startPos := pos + 9
         len := inStr(l, substr(l,StartPos-1,1),false,-1)-StartPos
         str := subStr(l, StartPos, len)
         binding%mode% += 1
         num := binding%mode%
         key%mode%_%num% := command
         description%mode%_%num% := str
         command := ""
         continue
      }
   }
   ; --------------- CONSTRUCT GUI FOR HELP ---------------
   spacing := 14
   Gui,  Color, 1A1A1A,FCFCFC
   Gui,  +Toolwindow -Resize -SysMenu -Border -Caption +AlwaysOnTop +LastFound
   WinSet, Transparent, 0
   HelpGUI := WinExist()
   xstart := 20
   if (binding1 > 0) {
      ystart := 70
      Gui,  Font, c10EE00 s20 w700,Corbel
      Gui,  Add, Text,center w900, Windows+?  :  Current Key Bindings
      Gui,  Font, cFEFEFE s16 w700, Corbel
      Gui,  Add, Text, center w400 y57 x%xstart%, Current Window
      Loop, %binding1%
      {
         key := key1_%A_Index%
         description := description1_%A_Index%
         ypos := ystart+A_Index*spacing
         Gui,  Font, cFEFEFE s10 w700, Corbel
         Gui,  Add, Text, right x%xstart% y%ypos% w150, %key%
         Gui,  Font, w100, Corbel
         Gui,  Add, Text, left xp+170 y%ypos% w300, %description%
      }
      xstart :=xstart+400+20
      Gui,  Font, s16 w700, Corbel
      Gui,  Add, Text, center w400 y57 x%xstart%, Global Hotkeys
   } else {
      ystart := 50
      Gui,  Font,c10EE00 s24 w700,Corbel
      Gui,  Add, Text,center w500, Windows+?  :  Current Key Bindings
   }
   Loop, %binding0%
   {
      key := key0_%A_Index%
      description := description0_%A_Index%
      ypos := ystart+A_Index*spacing
      Gui,  Font, cFEFEFE s10 w700, Corbel
      Gui,  Add, Text, right x%xstart% y%ypos% w150, %key%
      Gui,  Font, w100, Corbel
      Gui,  Add, Text, left xp+170 y%ypos% w300, %description%
   }
   Gui, Add, Button, x-10 y-10 w1 h1 +default hidden gExitGui
   transp := 0
   WinSet, Transparent, 0, ahk_id %HelpGUI%
   Gui, Show, Center AutoSize
   Loop, 8
   {
      transp := transp + 30
      WinSet, Transparent, %transp%, ahk_id %HelpGUI%
      sleep,12
   }
   SetTimer, CloseHelpGUIWindow, 500
Return

; #############################################################################
; End Of KeyCodes - EXIT HERE
; #############################################################################

Return

; ################################
; Help GUI Labels and Functions
; ################################


CloseHelpGUIWindow: ; close GUI window of it looses focus
   IfWinNotActive, ahk_id %HelpGUI%
   {
      SetTimer, CloseHelpGUIWindow, Off
      HideHelpGUI()
   }
Return

ExitGui:
GuiEscape:
   SetTimer, CloseHelpGUIWindow, Off
   HideHelpGUI()
Return

HideHelpGUI() {
   global HelpGUI
   transp := 240
   Loop, 20
   {
      transp := transp - 12
      WinSet, Transparent, %transp%, ahk_id %HelpGUI%
      sleep,15
   }
   Gui, Hide
   Gui, Destroy
}

; #############################################################################
; Labels from here on
; #############################################################################

; ----------------- LINKEDIN
/* 
linkedIn:
   IfWinActive, ahk_class MozillaWindowClass
   {
      PixelGetColor, lcolor, %LinkedInMouseX%, %LinkedInMouseY%
      If (lcolor <> linkedInColor) {
         SetTimer, linkedIn, Off
         linkedInStart:=0
      } else {
         SendInput,!d{Delete}
         searchURL=http://www.linkedin.com/profile/view?id=%linkedInID%&trk=tab_pro
         SendInput, %searchURL%{Return}
         ToolTip, profile ID# %linkedInID%
         linkedInID:=linkedInID+1
      }
   }
Return
*/

; --------------- Moving and Resizing Application Windows

ToggleAltLRButtons:
   Hotkey, !LButton, Toggle, % ( Toggle := !Toggle ) ? "on" : "off"
   Hotkey, !RButton, Toggle, % ( Toggle ) ? "on" : "off"
   If (Toggle) {
      text = 'Alt' + mouse button functions are *ON*
      showOSD(text)
      SoundBeep, 1200, 50
      SoundBeep, 1800, 100
   } else {
      text = ToolTip, 'Alt' + mouse button functions are off
      showOSD(text)
      SoundBeep, 1800, 50
      SoundBeep, 1200, 100
   }
   SetTimer, RemoveToolTip, 2000
Return

AltLButton:
   CoordMode, Mouse, Screen
   SetWinDelay, 0
   MouseGetPos, OLDmouseX, OLDmouseY, WindowID
   If WindowID =
      Return
   WinGet, maximized, MinMax, ahk_id %WindowID%
   If maximized=1
      Return
   WinGetPos, winX, winY, winW, winH ,ahk_id %WindowID%
   WinRestore, ahk_id %WindowID%
   WinMove, ahk_id %WindowID%,,%winX%,%winY%,%winW%,%winH%
   Loop
   {
      GetKeyState, state, Alt, P
      If state = U ; key has been released
         break
      GetKeyState, state, LButton, P
      If state = U
         break
      MouseGetPos, newMouseX, newMouseY
      If newMouseX < %OLDmouseX%
      {
         Xdistance = %OLDmouseX%
         EnvSub, Xdistance, %newMouseX%
         EnvSub, winX, %Xdistance%
      }
      Else If newMouseX > %OLDmouseX%
      {
         ; mouse was moved to the right
         Xdistance = %newMouseX%
         EnvSub, Xdistance, %OLDmouseX%
         EnvAdd, winX, %Xdistance%
      }
      OLDmouseX = %newMouseX%
      If newMouseY < %OLDmouseY%
      {
         Ydistance = %OLDmouseY%
         EnvSub, Ydistance, %newMouseY%
         EnvSub, winY, %Ydistance%
      }
      Else If newMouseY > %OLDmouseY%
      {
         Ydistance = %newMouseY%
         EnvSub, Ydistance, %OLDmouseY%
         EnvAdd, winY, %Ydistance%
      }
      OLDmouseY = %newMouseY%
      WinMove, ahk_id %WindowID%,,%winX%,%winY%
   }
Return

AltRButton:
   CoordMode, Mouse, Relative
   MouseGetPos, inWinX, inWinY, WinId
   If WinId =
      Return
   WinGet, maximized, MinMax, ahk_id %WinID%
   If maximized=1
      Return
   WinGetPos, winX, winY, winW, winH, ahk_id %WinId%
   halfWinW = %winW%
   EnvDiv, halfWinW, 2
   halfWinH = %winH%
   EnvDiv, halfWinH, 2
   If inWinX < %halfWinW%
      MousePosX = left
   Else
      MousePosX = right
   If inWinY < %halfWinH%
      MousePosY = up
   Else
      MousePosY = down
   CoordMode, Mouse, Screen
   MouseGetPos, OLDmouseX, OLDmouseY, WinId
   SetWinDelay, 0
   Loop
   {
      GetKeyState, state, ALT, P
      If state = U
         break
      GetKeyState, state, RButton, P
      If state = U
         break
      MouseGetPos, newMouseX, newMouseY
      If newMouseX < %OLDmouseX%
      {
         Xdistance = %OLDmouseX%
         EnvSub, Xdistance, %newMouseX%
         If MousePosX = left ; mouse is on left side of window
         {
            EnvSub, winX, %Xdistance%
            EnvAdd, winW, %Xdistance%
         }
         Else
         {
            EnvSub, winW, %Xdistance%
         }
      }
      Else If newMouseX > %OLDmouseX%
      {
         ; mouse was moved to the right
         Xdistance = %newMouseX%
         EnvSub, Xdistance, %OLDmouseX%
         If MousePosX = left ; mouse is on left side of window
         {
            EnvSub, winW, %Xdistance%
            EnvAdd, winX, %Xdistance%
         }
         Else
         {
            EnvAdd, winW, %Xdistance%
         }
      }
      OLDmouseX = %newMouseX%
      If newMouseY < %OLDmouseY%
      {
         Ydistance = %OLDmouseY%
         EnvSub, Ydistance, %newMouseY%
         If MousePosY = up ; mouse is on upper side of windows
         {
            EnvSub, winY, %Ydistance%
            EnvAdd, winH, %Ydistance%
         }
         Else
         {
            EnvSub, winH, %Ydistance%
         }
      }
      Else If newMouseY > %OLDmouseY%
      {
         Ydistance = %newMouseY%
         EnvSub, Ydistance, %OLDmouseY%
         If MousePosY = up ; mouse is on upper side of windows
         {
            EnvAdd, winY, %Ydistance%
            EnvSub, winH, %Ydistance%
         }
         Else
         {
            EnvAdd, winH, %Ydistance%
         }
      }
      OLDmouseY = %newMouseY%
      WinMove, ahk_id %WinID%,,%winX%,%winY%,%winW%,%winH%
   }
Return

AltMButton:
   showOSD("Toggle 'Always on Top' for this window")
   MouseGetPos,,,mouseOverWin
   WinSet, AlwaysOnTop, Toggle, ahk_id %mouseOverWin%
Return

; #############################################################################
; OSD
; #############################################################################

Gui1:=0

showOSD(text) {
   global Gui1
   Gui, 1: Color, 1A1A1A,FCFCFC
   Gui, 1: +Toolwindow -Resize -SysMenu -Border -Caption +AlwaysOnTop +LastFound
   WinSet, Transparent, 0
   transp := 0
   Gui1 := WinExist()
   Gui, 1: Font,cF9F9F9 s36,Corbel ; preferred font (as it is the last one set, if available)
   Gui, 1: Add, Text,center w600, %text%
   Gui, 1:Show, NoActivate Center AutoSize
   Loop, 5
   {
      transp := transp + 42
      WinSet, Transparent, %transp%
      sleep,20
   }
   SetTimer, hideOSD, 500
}

hideOSD:
   SetTimer, hideOSD, Off
   transp := 211
   Loop, 12
   {
      transp := transp - 10
      WinSet, Transparent, %transp%, ahk_id %Gui1%
      sleep,15
   }
   Loop, 18
   {
      transp := transp - 5
      WinSet, Transparent, %transp%, ahk_id %Gui1%
      sleep,15
   }
   Gui, 1:Hide
   Gui, 1:Destroy
   if (reloadFile) {
      reload   
   }
Return

RemoveToolTip:
   SetTimer, RemoveToolTip, Off
   ToolTip
Return


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, Yahoo [Bot] and 21 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