New AutoHotKey script to popup/move Fitaly

Posted by JudH ® , 02/05/2006, 17:55:23 Post Reply   Forum

Okay, here's my contribution to the cause. I'm calling it FitaTrak to distinguish it from Robert's. I've tested it fairly well but please feel free to post bug fixes and changes.

I went at it a different way. Instead of looking at just the edit caret I look for the floating TIP icon (not the full TIP keyboard). When the script detects that it sees if the user is holding the stylus over it BUT NOT CLICKING it--if so it treats it as a request to unhide Fitaly and move it close to the icon. It does look at the current screen size and shift left or right to make Fitaly fit. Once up it will stay in place horizontally but move up or down if the icon moves--I find that works better for me than constantly shifting based on the caret. If you want it to move horizontally rehover the stylus over the icon--or move Fitaly manually. To rehide Fitaly just move the stylus away--when the TIP icon goes away the script will hide Fitaly. If you want the full TIP keyboard--well if you must--just click the icon--the script will then hide Fitaly until the icon reappears. Also there is support to start Fitaly if it's not running, i.e. if Fitaly is closed it will restart it when it needs to display it again. Comments are imbedded. All Fitaly sizes are supported. I can't see any speed problems on my Motion M1400.

I'm using tabs in the source and I'm not sure how this is going to look so I'm also sticking it somewhere else and posting the URL below. Open it from there if alignment gets screwed up.

By the way, I see why Robert likes AutoHotKey. I normally use WinBatch for this kind of thing but it's probably going to start taking a backseat to AHK.

Jud
Dallas Tx

-------------------------------------------------------------
; "Fitatrak.ahk"
; Author: Jud Hardcastle
; Written: Jan 2006
; Updated: 2006/2/4

/*
Script Function:
Popsup the Fitaly on-screen keyboard whenever mouse hovers over TIP icon.
Hides the Fitaly keyboard when the TIP icon leaves.OR if the user brings
up the full TIP keyboard. Moves the Fitaly keyboard as close to the TIP
icon as possible, either above or below as needed. Once up, Fitaly will
stay stationary horizontally until the TIP icon leaves the screen--user
can force the Fitaly window to shift closer to caret by re-hovering mouse
over TIP icon. If the TIP icon moves up or down, such as when the caret
moves to a new line in an edited document, then move Fitaly vertically.
*/

CoordMode, Caret, Screen
#SingleInstance Force
OnExit, ExitSub
Menu, Tray, Icon, %A_WinDir%\system32\Shell32.dll, 134

GoSub RunFitaly
WinHide, ahk_class FitalyMainWindow
X_FitUp := 0

Save_CaretX := A_CaretX

Loop
{
; Check if a TIP icon or window is being displayed, ie text input
; field selected and stylus is near screen
If WinExist("ahk_class IPTip_Main_Window")
{
WinGetPos, TipX, TipY, TipW, TipH, ahk_class IPTip_Main_Window

; Main TIP keyboard is up, dont put up Fitaly
IfGreater, TipH, 50
{
WinHide, ahk_class FitalyMainWindow
X_FitUp := 0
Sleep, 1000
Continue
}

; If Mouse is over TIP then user either wants Fitaly to come up
; Or wants Fitaly to shift closer to caret
; If Mouse isnt over TIP icon user doesnt want Fitaly
; Or Fitaly is already up
MouseGetPos, ,,MouseWID
WinGetClass, MouseWCL, ahk_id %MouseWID%
IfEqual,MouseWCL,IPTip_Main_Window
X_FitUp := 0 ;need new horizontal position
Else
{
IfEqual,X_FitUp,0
{
Sleep, 1000
Continue
}
Else
{
; Fitaly up, only if Tip moved up or down then move Fitaly
IfEqual,TipY,%Save_TipY%
{
; Location ok, faster loop to force on top of dropdowns
WinSet, AlwaysOnTop, ON, ahk_class FitalyMainWindow
Sleep, 30
Continue
}
}
}

; Fitaly not up (or mouse over tip), calculate new horizontal position
; If Fitaly is up, use current horizontal position
IfEqual,X_FitUp,0
{

; Start Fitaly a bit left of current caret
Save_CaretX := A_CaretX - 100

; If caret is off screen left force it to zero
IfLess,Save_CaretX,0
Save_CaretX := 0

; If off right side of screen shift left as needed
SysGet, Mon1, MonitorWorkArea
NewRight := Save_CaretX + FitW
IfGreater,NewRight,%Mon1Right%
Save_CaretX := Mon1Right - FitW - 5
New_CaretX := Save_CaretX
}
Else
{
WinGetPos, FitX, FitY, FitW, FitH, ahk_class FitalyMainWindow
New_CaretX := FitX
}

; Fitaly up or down, base vertical position on TIP icon
; Put Fitaly just below Tip if Tip below Cursor else just above Tip
Save_TipY := TipY
IfGreater,TipY,%A_CaretY%
New_CaretY := (TipY + TipH + 5)
Else
New_CaretY := (TipY - FitH - 5)

; Display Fitaly and move to new position
GoSub RunFitaly
WinMove, ahk_class FitalyMainWindow, ,New_CaretX, New_CaretY
WinSet, AlwaysOnTop, ON, ahk_class FitalyMainWindow
}
Else
{
; Tip not up, hide Fitaly until needed
IfEqual,X_FitUp,1
{
WinHide, ahk_class FitalyMainWindow
X_FitUp := 0
}
}
; Wait for change
sleep, 1000
}
Exit

ExitSub:
; unhide Fitaly before leaving, wont be usable otherwise
WinShow, ahk_class FitalyMainWindow
ExitApp

RunFitaly:
; Display Fitaly keyboard, Start Fitaly if not running
DetectHiddenWindows, On
IfWinNotExist, ahk_class FitalyMainWindow
{
RegRead, FitDir, HKEY_CURRENT_USER, SOFTWARE\Textware Solutions\Fitaly, Installation directory
if ErrorLevel
{
MsgBox, Error locating Fitaly Installation directory, Terminating script.
ExitApp
}
else
{
Run, Fitaly2005.exe, %FitDir%
Loop
{
Sleep, 1000
IfWinExist, ahk_class FitalyMainWindow
Break
IfGreater, A_Index, 60
{
MsgBox, Error starting Fitaly, Terminating script
ExitApp
}
}
}
}
DetectHiddenWindows, Off
WinRestore, ahk_class FitalyMainWindow
WinShow, ahk_class FitalyMainWindow
WinGetPos, FitX, FitY, FitW, FitH, ahk_class FitalyMainWindow
X_FitUp := 1
Return


Related link: FitaTrak.ahk

Edit | Post Reply | | View All | |   | Current page | Author Profile
Followups