; HotSpotKnockoff -- copy right by nobody, modify and use as desired. ; file version 3 ; Instructions: ; Put the mouse somewhere and press alt+shift+A to label and store the location ; To move the mouse to a spot, press alt+shift+f1 and choose a location from the list. ; You should do any clicking that is necessary manually. ; If the color it finds is new, it will ask you what you want spoken for that color. ; To have that color recognized, tyep a string you want spoken. ; To ignore that color, press escape. ; if you change your mind, edit the .ini file for this application, and remove that color. ; if the color is recognized, the stored string is spoken. ; the msgBox with timeout is used to speak until we figure out a good speech API. ; Data is stored in c:\ahk\ in a .INI file named after your application. ; ; to make a single hot key to run a spot, define the spot first. ; then add a macro to this file which calls the RunSpot function with the name of your hotSpot. ; AHK uses Special symbols to represent key modifiers as follows: ; + = shift ; ! = alt ; ^ = control\ ; # = windows key ; for example, to run spot fuzzy in response to alt+control+shift+x, d aline like this: ; !^+x::RunSpot("fuzzy") ; **macro: experimental speak coordinates and color at current mouse position ; PixelGetColor seems to be off by one pixel in both directions ^+1:: MouseGetPos, x, y, hwnd, ctl xp := x+1 yP := y+1 PixelGetColor, actualColor, %xp%, %yP%, RGB outBuf = %x% %y%`, %actualColor% ; PixelSearch, foundX, foundY, x-10, y-10, x+10, y+10, 0x000000, 0, RGB ; outBuf = %foundX% %foundY% msgBox, , mouse, %outBuf%, 1 return ; **macro alt_shift_A ; generate a hotspot, place the mouse first !+a:: WinGetActiveTitle, title MouseGetPos, x, y, hwnd, ctl ; build the data record for the .INI file outbuf = WinCol=%x%`nWinRow=%y%`nclass=%ctl%`n inputBox, spotName, , Enter hotspot name if %spotName% { ; they entered a spopt name HSFile := GetHSFilePath(title) iniWrite, %outBuf%, %HSFile%, %spotName% return } else { ; they canceled out msgBox, , , operation canceled, 0.5 return } ; **macro alt+shift+f1 ; select and move to a hotspot !+f1:: WinGetActiveTitle, title HSFile := GetHSFilePath(title) iniRead, fileSections, %HSFile% if strlen(fileSections) < 2 { ; no spots defined MsgBox, , , no hotspots defined, 1.0 return } ; translate from newLine delimited list, to vertical bar delimited Loop, parse, fileSections, `n spotList = %spotList%%a_loopField%| gui, add, Listbox, vSelect, %spotList% Gui, Add, Button, default, OK Gui, Add, Button, , Cancel gui, show return ; user action will now activate one of the labels below ; **label ButtonOK: ; when they click OK on the list of spots gui, submit ; get their results GUI, destroy ; focus back in the application ; wait for window to reappear WinWait %title% RunSpot(select) return ; **label ButtonCancel: ; when they cancel out of a hotspot selection GUI, destroy msgBox, , , input canceled, 0.5 return ; **function: runs a particular hotSpot ; provide: name of the hotSpot to run ; returns; nothing RunSpot(spotName) { WinGetActiveTitle, title HSFile := GetHSFilePath(title) iniRead, x, %HSFile%, %spotName%, WinCol, 0 iniRead, y, %HSFile%, %spotName%, WinRow, 0 iniRead, ExpectedClass, %HSFile%, %spotName%, class, MouseMove, %x%, %y% MouseGetPos, dummyX, dummyY, hwnd, ctl ; pixelGetColor seems to be off by one pixel xP := x+1 yP := y+1 PixelGetColor, actualColor, %xP%, %yP%, RGB if (%ctl% != %expectedClass%) { MsgBox HotSpot class: expected %expectedClass% but found %ctl% return } else { ; class is correct ; valid class, check on the color label iniRead, colorLabel, %HSFile%, %spotName%, %actualColor%, $NotDefined if (colorLabel != "$NotDefined") { ; color recognized, or should be ignored if (colorLabel != "$Ignore") { ; a label exists and should be spoken msgBox , , , %colorLabel%, 1 } } ; color recognized else { ; new color found ; color not recognized InputBox, colorLabel, , What would you like spoken when color %actualColor% is found? if %colorLabel% { ; color label has been entered IniWrite, %colorLabel%, %HSFile%, %spotName%, %actualColor% } else { ; they chose not to label this color msgbox , , ok then`, this color will be ignored, 1 IniWrite, %colorLabel%, %HSFile%, %spotName%, $Ignore } } ; new color found return } ; class is correct return } ; end of function RunSpot ; **function: to centralize the location of the .ini file ; provide: window title ; returns: path to the .ini file for this owning application GetHSFilePath(title) { WinGet, name, ProcessName, %title% StringTrimRight, name, name, 4 path = c:\ahk\%name%.ini return path }