FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour track user input
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
track user input
Posted: Mon Sep 23, 2013 06:55 PM

Hello,

Does anyone know of a way to track all user input like button presses, entries etc...
I want to be able to have an optional user debug mode that they can turn on if they are having problems.

The reason I wold like this is that I have the odd customer that will have more problems then other users.
They would be running the same version as other users but generate some errors that I am unable to track down.
I know it's not a permissions issue on their system.

I am never able to reproduce the errors on my test systems.

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: track user input
Posted: Mon Sep 23, 2013 07:25 PM

Jeff,

The method HandleEvent() is probably one of the most called modules in FWH, so if you modify it, then it may be a good place to track the user activity.

Anyhow, please keep in mind that this may slow down your app.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: track user input
Posted: Mon Sep 23, 2013 07:37 PM

Thanks Antonio.
I haven't tried changing any methods before ... Can you point me in the right direction? What file(s) would I need to look at changing?

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: track user input
Posted: Mon Sep 23, 2013 08:52 PM

Jeff,

is your main window MDI ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: track user input
Posted: Mon Sep 23, 2013 10:22 PM

No

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: track user input
Posted: Tue Sep 24, 2013 05:38 AM

Jeff,

Is it a window or a dialog ? thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: track user input
Posted: Tue Sep 24, 2013 12:04 PM

The main screen is a standard window. The area I really would like to track is a dialog.

Thanks.

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: track user input
Posted: Tue Sep 24, 2013 01:08 PM
Jeff,

This may be a good start point:

jeff.prg
Code (fw): Select all Collapse
#include "FiveWin.ch"
#include "xhbcls.ch"

function Main()

   local oDlg

   EXTEND CLASS TDialog WITH Method HandleEvent

   DEFINE DIALOG oDlg

   ACTIVATE DIALOG oDlg CENTERED

   WinExec( "notepad events.txt" )
   FErase( "events.txt" )

return nil

static function HandleEvent( nMsg, nWParam, nLParam )

   local Self := HB_QSelf()

   LogFile( "events.txt", { ProcName( 3 ), nMsg, nWParam, nLParam } )

   if nMsg == WM_INITDIALOG
      return ::Initiate( nWParam, nLParam )
   endif

return ::Super:HandleEvent( nMsg, nWParam, nLParam )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: track user input
Posted: Tue Sep 24, 2013 01:40 PM
You could greatly reduce the size of the log file, filtering the messages that you get from Windows and selecting the most important ones.

In example, WM_COMMAND is sent when a button is pressed, and on other situations. Also you could track WM_KEYDOWN, WM_LBUTTONDOWN, etc.

Code (fw): Select all Collapse
   
   if AScan( { WM_COMMAND, WM_KEYDOWN, WM_LBUTTONDOWN }, nMsg ) != 0   
      LogFile( "events.txt", { ProcName( 3 ), nMsg, nWParam, nLParam } )
   endif


Keep in mind that such code will be executed lots of times, so the more time you consume there, the slower the app will get
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: track user input
Posted: Tue Sep 24, 2013 01:49 PM

Thanks Antonio,

where can I get xhbcls.ch ??

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: track user input
Posted: Tue Sep 24, 2013 02:01 PM

Also, is it possible to get the button assignment (ie: oBtnStart ) to show up in events.txt ?

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: track user input
Posted: Tue Sep 24, 2013 02:10 PM
Jeff Barnes wrote:
where can I get xhbcls.ch ??


https://github.com/harbour/core/blob/master/contrib/xhb/xhbcls.ch
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: track user input
Posted: Tue Sep 24, 2013 02:13 PM
Jeff Barnes wrote:Also, is it possible to get the button assignment (ie: oBtnStart ) to show up in events.txt ?


I am not sure what you mean.

Do you mean when a variable is assigned ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: track user input
Posted: Tue Sep 24, 2013 02:25 PM

I am looking to see exactly what button was clicked. A have about 10 buttons on my dialog.
REDEFINE BUTTON oBtnStart ...
REDEFINE BUTTON oBtnEnd...
etc...

I was wondering how I know which button they actually pressed. In the events.txt file there are a bunch of numbers but it would be very helpful if, when a button was clicked, it could show that button object name (line oBtnStart or oBtnEnd etc....)

I hope I am explaining this right :?

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: track user input
Posted: Tue Sep 24, 2013 02:47 PM
Jeff,

Try this one, closer to what you may want :-)

Code (fw): Select all Collapse
#include "FiveWin.ch"
#include "xhbcls.ch"

function Main()

   local oDlg

   EXTEND CLASS TDialog WITH Method HandleEvent

   DEFINE DIALOG oDlg

   @ 1, 1 BUTTON "Press"

   ACTIVATE DIALOG oDlg CENTERED

   WinExec( "notepad events.txt" )
   FErase( "events.txt" )

return nil

static function HandleEvent( nMsg, nWParam, nLParam )

   local Self := HB_QSelf()

   if nMsg == WM_COMMAND
      LogFile( "events.txt", { If( IsWindow( nLParam ),;
               oWndFromHwnd( nLParam ):cVarName,) } )
   endif   

   if nMsg == WM_INITDIALOG
      return ::Initiate( nWParam, nLParam )
   endif

return ::Super:HandleEvent( nMsg, nWParam, nLParam )


EXTEND CLASS example
regards, saludos

Antonio Linares
www.fivetechsoft.com