Forum Moderators: DixonJones

Message Too Old, No Replies

User Actions Tracking

         

pat270881

3:09 pm on Jul 9, 2004 (gmt 0)

10+ Year Member



hello,

Does anybody know how i can implement user actions tracking for mobile devices? i mean, that it will be recorded what user do with the PDA, which actions he will execute on the PDA? etc.

i hope someone can help me, it is very important.

thanks in advance

patrick

pat270881

10:10 am on Jul 11, 2004 (gmt 0)

10+ Year Member



hi

can nobody help me? - or do anybody know a tool for desktop to record user actions? - for example, when the user execute a task (e.g. to adjust another sreen solution in the the system control)that it will be recorded, what the user do.

i hope someone undestand my explanation.

lg patrick

pat270881

9:01 am on Jul 29, 2004 (gmt 0)

10+ Year Member



hello,

does anybody know how i can scan and/or log in a file, that e.g. for all 5 seconds or when a window opens, it would be logged in a file, which windows are opened?(the title of the window or something else) i need this mechanism for usability tests.

i have spoken with a developer of microsoft austria and he gave me the following solution:

Enumerating the top-level windows is easy: P/Invoke the EnumWindows native API:

[DllImport("user32.dll")]#
private static extern bool EnumWindows(EnumWindowsProc proc, IntPtr lParam);

private delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);

[DllImport("user32.dll", CharSet=CharSet.Auto)]
private static extern IntPtr GetWindowText(IntPtr hWnd,
[Out] string title, IntPtr maxCount);

public void EnumWindows()
{
EnumWindows(new EnumWindowsProc(Callback), IntPtr.Zero);
}

private bool Callback(IntPtr hWnd, IntPtr lParam)
{
string title = new string('\0', 260);
if (GetWindowText(hWnd, title, 260)!= IntPtr.Zero)
Log(string.Format("{0:x8}: {1}", hWnd, title);
}

If instead of windows you want to enumerate all running processes (and perhaps filter those that do not have application windows), you can use Process.GetProcesses and, optionally, check if Process.MainWindowHandle is IntPtr.Zero (not graphical).

Responding when a window opens is a bit more tricky. You must efficiently implement a Windows hook and handle the WH_CBT (0x05) message. This message is documented in the Platform SDK along with related APIs like SetWindowsHookEx. The callback (CBTProc) is called whenever a window is about to be activated, created, destroyed, minimized, maximized, moved, or resized (so you'll need to filter these appropriately based on your needs).

You can read more about implementing windows hooks in .NET (using the C# language) by reading Using Hooks from C#[^] here on this site. Any questions specific to this article should be directed to the article's message board at the bottom of the page.
---------------

i think i need this solution with the Windows Hooks, i also read something in the MSDN about Hooks but unfortunately i do not really look through it. Can anybode explain it to me in a simpler way? - This would be very nice, because it would be very important to me.

I looked in the MSDN for Windows Hooks and I think for my problem i need the WH_CBT Hook and the HCBT_ACTIVATE, HCBT_CREATEWND, HCBT_DESTROYWND, HCBT_MINMAX, HCBT_MOVESIZE, HCBT_SYSCOMMAND.

With these hooks i can log when a window opens (whereby i do not exactly know the difference between activate and createwnd), a window closes, a window minimizes or maximises and when a command executes.

But now if my thoughts are right i miss the practical relation to the c# and how i can implement that.

i hope you can give me further help.

thanks in advance.

yours sincerely,

patrick

PS: I hope you know that it still concern the event logging of the PDA, where Windows Mobile 2003, Second Edition and the .NET Compact Framework is installed. I thought this method with logging the open windows and so on is the best way to know what the user do with the PDA, because that is what i want to know and this should be logged in any wise.

Arkantos

11:37 pm on Jul 30, 2004 (gmt 0)

10+ Year Member



from what i could gather from the first two posts (the third one i cant understand), is that you are trying to develop a spy software.

i think i speak for all the members of this forum, that this kind of programming is looked down upon.

pat270881

7:59 am on Jul 31, 2004 (gmt 0)

10+ Year Member



hi,

no, no i develop this program for usability-tests on a PDA. I found a code sample for that but unfortunately i cannot really interpret this sample, especially the things with the AutoResetEvent and the delegates. It would be very nice, if anybody can help me and explain it to me.

using System;
using System.Runtime.InteropServices;
using System.Threading;

class Test
{
static AutoResetEvent evt;
static int count = 1;
static void Main(string[] args)
{
if (args.Length > 0)
{
try
{
count = int.Parse(args[0]);
}
catch {}
}

evt = new AutoResetEvent(false);
Timer t = new Timer(new TimerCallback(TimerCallback), null, 0, 5000);
evt.WaitOne();
}

static void TimerCallback(object state)
{
Console.WriteLine("Enumerating windows at {0:t}...", DateTime.Now);
EnumWindows(new EnumWindowsProc(EnumWindowsCallback), IntPtr.Zero);

if (--count == 0) evt.Set();
}

static bool EnumWindowsCallback(IntPtr hWnd, IntPtr lParam)
{
if (hWnd!= IntPtr.Zero)
{
string title = new string('\0', 260);
int ret = GetWindowText(hWnd, title, 260);
if (ret!= 0)
Console.WriteLine("0x{0:x8}: {1}", hWnd.ToInt64(),
title.Substring(0, ret));
}

return true;
}

[DllImport("user32.dll")]
static extern bool EnumWindows(EnumWindowsProc proc, IntPtr lParam);

delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);

[DllImport("user32.dll", CharSet=CharSet.Auto)]
static extern int GetWindowText(IntPtr hWnd, [Out] string title,
int maxCount);
}

I hope somebody has time to answer.

thanks in advance.

yours sincerely,

patrick