1. Gastón Clara
  2. PowerBuilder
  3. Wednesday, 18 November 2020 16:20 PM UTC

Hi,

I nedd to track las time user interacts with an application.  Does anybody knows if there is an "easy" way to do that?

The only idea that I have is to track all user interactive envents on all visual objects (tricky solution).

Thanks fo your help!!

Gastón Clara Accepted Answer Pending Moderation
  1. Friday, 27 November 2020 14:36 PM UTC
  2. PowerBuilder
  3. # 1

Finally I coded all key, mousemouve, clicked and selection changed events for all princpal master visual objects. IT works fine and i seems that performance is not affected.

 

Thank you everyone for your help!

Comment
  1. Miguel Leeuwe
  2. Saturday, 28 November 2020 18:51 PM UTC
Well.. if it works for you ... I'm glad!
  1. Helpful
There are no comments made yet.
Ivan Mesarc Accepted Answer Pending Moderation
  1. Friday, 27 November 2020 13:02 PM UTC
  2. PowerBuilder
  3. # 2

SetWindowsHookEx

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Wednesday, 25 November 2020 19:50 PM UTC
  2. PowerBuilder
  3. # 3

What if your PB app kept track of the "last user interaction" timestamp internally, such as a global datetime variable, but only recorded/updated that timestamp in the database on a slightly more leisurely interval, say, every five minutes?

I think you need to clearly define what "last user interaction" means. IMHO, a mouse move event sent to a DataWindow doesn't signify user interaction, but a keystroke or mouse click handled by any object within the app does. What is your definition of the term and is it a reasonable definition that makes sense?

If your app has been constructed using a framework, then it should not be overly difficult to put code in the ancestor objects to update a global datetime variable on an as-needed basis. If it were me, I'd consider not even updating the global timestamp unless 15 seconds (or more) had passed since it was last recorded, because you have to ask if any finer granularity really makes a difference? If you do not have/use a framework, then yes, you have a non-trivial amount of work ahead of you.

Your app could utilize a timer object to update the database every so often, say, five minutes, for example. I would use an additional, separate transaction object to accomplish this, so as to not adversely affect anything the user may be doing. The timer object could keep an instance copy of the global timestamp it last sent to the database so it could determine if the timestamp has changed since the last timer "pop" and bypass recording the same timestamp in the database if it has not changed.

Comment
  1. Gastón Clara
  2. Thursday, 26 November 2020 09:25 AM UTC
What you explained is exactly what we are doing. Nothing to change there.

My issue is that I want to track, at least, keys pressed, mouse movements and mouse clicks. With PB is not just enough to code those events in the pfc_w_main window. I need to track most of these events in most of the master visual objects. That is the way PB works.

A click is caught depending on which object it was done, on an empty area of the window, on a dw, on tree view, ona a button, etc.

What I would like to avaoid is to adding code to all master objects (same code).

And I am also concern about the amount of work that I would be adding to the aplication.



Thanks.
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Wednesday, 18 November 2020 18:07 PM UTC
  2. PowerBuilder
  3. # 4

The problem I see in the first place is that you want to track the time of "last interaction" with anything in the application to be able to make a decision whether you can close down an application or not.

Even if you'd add code to all visual (and non visual!) objects, you still have the problem that you'd have to decide on a transcurred time of inactivity to be able to make the conclusion that the user is no longer using the application and you can close it down.

What if a user is watching a screen for a very very long time and doesn't do anything else (maybe using one of the other apps meanwhile?)? Do you close down after 10 minutes, 30, 60 of inactivity?

If you can make a decision on that time interval of inactivity, you might as well use the applications object's idle event after all. (see one of my other comments). When you open the app you set "Idle(number of seconds)".

After "number of seconds" your event will be fired where you can close the application using

Halt close;

No need to put code in every visual / non visual object, just use the idle event: the question you have to solve remains the same.

regards

 

Comment
  1. Gastón Clara
  2. Wednesday, 18 November 2020 19:50 PM UTC
You are right, we do have and idle event to track the INactivity in the application in order to log-off and that is correct. What I need is to have a timer every 2 seconds that saves in the database the last time the user interacted with the app, this ways all other applications can decide if they can log out or not. As far as I can see is to code all events in all the objects in order to track tha last time the user uses them. It's going to be tricky, but.....
  1. Helpful
  1. Miguel Leeuwe
  2. Wednesday, 18 November 2020 22:52 PM UTC
Well, if it's good enough for you to know whether the user "has not closed" the application. (not exactly the same as "actively interacting" with the app), then you could - instead of coding all the objects - define a timer event in for example the MDI window (or application object). In that event you would insert/update the table in the database with the latest time. I do recommend to use a separate transaction object for that operation, so the "commit using ....;" won't interfere with any other transactions that you application will be using.
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Wednesday, 18 November 2020 17:56 PM UTC
  2. PowerBuilder
  3. # 5

Read your comment again, and no. .. previous comment is probably not what you are looking for.

I'd say: when a user connects and disconnects to your database, insert the a row with the userid and application id in some table.

When the user connects you insert a row and when the user disconnects, you delete that row first.

Then when you want to shut down, you first check that table.

It's not 100% waterproof, as when a user is thrown out, the row probably still exists in the database and the applcition might be closed.

 

Comment
  1. Gastón Clara
  2. Friday, 20 November 2020 08:52 AM UTC
We are already doing that and this is correct. This is a different task, I need to track the last time a user interacts with the application every 2 seconds. This is what I really need to achieve. How to track activity over all the different visual user objects.
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 18 November 2020 17:01 PM UTC
  2. PowerBuilder
  3. # 6

Hi Gastón;

   My framework does this by using the Activate and Deactivate events in the Window that is controlling the overall Application's processing. The Activate records the time that the App User entered the App and the Deactivate event records the time that the user left the app (aka "last active").

   The difference between these times is the time the user actually spent within the App. My framework also records over all key stroke counts and how many times an App user has gone through (used) a particular menu item (Select # vs Clicked #).

HTH

Regards ... Chris

Comment
  1. Gastón Clara
  2. Friday, 20 November 2020 08:51 AM UTC
We are already doing that and this is correct. This is a different task, I need to track the last time a user interacts with the application every 2 seconds. This is what I really need to achieve. How to track activity over all the different visual user objects.
  1. Helpful
  1. Miguel Leeuwe
  2. Friday, 20 November 2020 10:11 AM UTC
If you think of updating a database table on every getfocus(), activate(), itemchanged(), constructor(), etc. then you are really going to put some pressure on your database and slow down your application "unnecessarily". I don't know how many users might be running these applications, but it doesn't seem like a good idea to me.
  1. Helpful
  1. Gastón Clara
  2. Wednesday, 25 November 2020 15:41 PM UTC
That's wxactly what I think.

The problem that I am really having is that if I want to detect the mousemove event it is not enough to do it in the master window, because the window only captures it if it is done on an empty are, if you do it over a dw you have to code it in the datawindow to, if you do it over a picture you have to code it on the picture too....

Resuming if I want to track mouse movements on a screen I have to code the screen and ALL visual objects that could be placed on it.

And I think that is too much. That's why I am trying to find any other options.



Thanks.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.