track user input

track user input

Postby Jeff Barnes » Mon Sep 23, 2013 6: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)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: track user input

Postby Antonio Linares » Mon Sep 23, 2013 7: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: track user input

Postby Jeff Barnes » Mon Sep 23, 2013 7: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)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: track user input

Postby Antonio Linares » Mon Sep 23, 2013 8:52 pm

Jeff,

is your main window MDI ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: track user input

Postby Jeff Barnes » Mon Sep 23, 2013 10:22 pm

No
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: track user input

Postby Antonio Linares » Tue Sep 24, 2013 5:38 am

Jeff,

Is it a window or a dialog ? thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: track user input

Postby Jeff Barnes » 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)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: track user input

Postby Antonio Linares » Tue Sep 24, 2013 1:08 pm

Jeff,

This may be a good start point:

jeff.prg
Code: Select all  Expand view
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: track user input

Postby Antonio Linares » Tue Sep 24, 2013 1: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: Select all  Expand view
 
   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
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: track user input

Postby Jeff Barnes » Tue Sep 24, 2013 1:49 pm

Thanks Antonio,

where can I get xhbcls.ch ??
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: track user input

Postby Jeff Barnes » Tue Sep 24, 2013 2: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)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: track user input

Postby Antonio Linares » Tue Sep 24, 2013 2: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: track user input

Postby Antonio Linares » Tue Sep 24, 2013 2: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: track user input

Postby Jeff Barnes » Tue Sep 24, 2013 2: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)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: track user input

Postby Antonio Linares » Tue Sep 24, 2013 2:47 pm

Jeff,

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

Code: Select all  Expand view
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 86 guests