AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Real time key history

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Laszlo



Joined: 14 Feb 2005
Posts: 4710
Location: Boulder, CO

PostPosted: Tue Jul 11, 2006 11:59 pm    Post subject: Real time key history Reply with quote

Tester posted a simple key-monitor script. Here is another version, which shows the last 25 key events in a tooltip, positioned in the top right corner of the screen. It is activated/deactivated by ScrollLock. The script is based on Corrupt's idea. It is very timing sensitive, so play around with the key delay, timer interval, etc. to get it stable.
Code:
#NoEnv
Process Priority,,High
SetBatchLines -1

#InstallKeybdHook
CoordMode ToolTip, Screen
DetectHiddenWindows On
SetKeyDelay -1,0
#KeyHistory 25       ; max #key events

ScrollLock::
   shown := !shown
   If (!shown) {
      SetTimer RThistory, OFF
      WinHide ahk_id %HidWin%
      DllCall("SetParent", UInt,HidWin, UInt,OldPar)
      ToolTip
      Return
   }
   HidWin := WinExist(A_ScriptFullPath " - AutoHotkey v")
   OldPar := DllCall("GetParent", UInt,HidWin)
   DllCall("SetParent", UInt,HidWin, UInt,WinExist("ahk_class Shell_TrayWnd"))
   WinMenuSelectItem ahk_id %HidWin%,,View, Key
   SetTimer RThistory, 100
Return

RThistory:
   Critical
   WinGet ID, ID, A
   ControlSend,,{F5}, ahk_id %HidWin%
   WinActivate ahk_id %ID%
   ControlGetText Keys, Edit1, ahk_id %HidWin%
   StringGetPos pos, Keys, ----------`r`n
   StringTrimLeft Keys, Keys, pos+12
   StringTrimRight Keys, Keys, 23
   StringSplit Keys, Keys, `n
   keys =
   Loop %Keys0% {
      StringLeft Keys%A_Index%, Keys%A_Index%, 30
      Keys := Keys Keys%A_Index% "`n"
   }
   StringTrimRight Keys, Keys, 1
   ToolTip %Keys%, A_ScreenWidth,0
Return
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4710
Location: Boulder, CO

PostPosted: Wed Jul 12, 2006 4:59 pm    Post subject: Reply with quote

Here is a simpler version. It cuts off the unnecessary parts of the original key history window and moves it to the upper right corner of the screen. Unfortunately, the dimensions depend on the chosen Windows interface fonts, the border width/type, title bar, etc., so you have to experiment with the size constants.

Twice a second we send F5 to the key history, to refresh. It steals the focus, so we have to note the current window and activate it after the refresh, but this constant change of active windows causes some flicker.
Code:
#NoEnv
Process Priority,,High
SetBatchLines -1

#InstallKeybdHook
SetKeyDelay 0,0
#KeyHistory 25       ; max #key events
                     ; Settings depend on the standard font
Width  = 400         ; width of key history list
Height = 550         ; depends on #key events
TopCut = 280         ; removed height from original window, depends on script info

ScrollLock::
   shown := !shown
   If (!shown) {
      SetTimer RThistory, OFF
      WinHide ahk_id %KHID%
      Return
   }
   KeyHistory
   WinGet KHID, ID, %A_ScriptFullPath% - AutoHotkey v
   WinSet AlwaysOnTop, ON, ahk_id %KHID%
   WinSet ExStyle,-0x80, ahk_id %KHID% ; removes window from the alt-tab list
   WinSet Region,% "W" Width " H" Height " 4-" TopCut, ahk_id %KHID%
   WinMove ahk_id %KHID%,,% A_ScreenWidth-Width, -TopCut
   SetTimer RThistory, 500
Return

RThistory:
   WinGet ID, ID, A                    ; current window
   ControlSend,,{F5}, ahk_id %KHID%    ; refresh key history
   WinActivate ahk_id %ID%             ; return to current window
Return
Back to top
View user's profile Send private message
Tester



Joined: 06 Jul 2006
Posts: 48
Location: Poland

PostPosted: Wed Jul 12, 2006 8:29 pm    Post subject: Reply with quote

I use first version - it is great. Smile
But when I test second version it don't log my mouse actions in KeyHistory window. Anyway first version is superb (until OnKeystroke()/OnMouseClick() function will be implemented).
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4710
Location: Boulder, CO

PostPosted: Wed Jul 12, 2006 8:38 pm    Post subject: Reply with quote

Just add "#InstallMouseHook".
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group