SetFocus Questions

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
ukdboyd
Newbie
Posts: 11
Joined: Wed May 25, 2005 6:09 pm

SetFocus Questions

Post by ukdboyd » Tue Jan 15, 2008 9:58 pm

I'm trying to write a script (and ultimate create an EXE) to manage an application (CompLab) that I use in a student computer lab. I thought that I had it working but have hit a dead end and don't know how to accomplish what I want.

The application (CompLab) presents a full-screen window, obscuring everything on the desktop, including the windows task bar and start button, and prompting the user for a login ID. This is not a Windows login, but simply logging them into this particular application. While this window is displayed, I do not want the user to be able to use the Windows/Start button or use Alt-Tab to switch to something else. Basically keep the focus on Complab. In other words, I want to force the user to enter their login information. Here's a snippet of the code that I've tried to use for that:

OnEvent>KEY_DOWN,VK91,0,WinKey
OnEvent>KEY_DOWN,VK92,0,WinKey
OnEvent>KEY_DOWN,LALT,0,ReleaseLALT
OnEvent>KEY_DOWN,RALT,0,ReleaseRALT

SRT>WinKey
Press ESC
END>WinKey

SRT>ReleaseRALT
Release RALT
END>ReleaseRALT

SRT>ReleaseLALT
Release LALT
END>ReleaseLALT


That basically accomplishes what I want. However, after the user logs in, there are a couple of other windows that appear. For example, Welcome to the computer lab, with an OK button. Then another Window that also requires an OK click from the user.

After the login happens Complab runs in the background with no other interface and no icon in the task bar or tray. To the user, it disappears.

While in this state, I do not want to restrict the user's ability to use the Windows/Start key or Alt key, so the above code would have to be disabled somehow. After a period of keyboard and mouse inactivity, Complab senses this inactivity and once again restores itself to full screen, obscuring everything. At this point Complab requests that the user re-enter their login ID to confirm that they are still there and using the computer. If they do, it goes back into hiding. As before, when Complab is displayed, I do not want the user to be able to do anything except type their ID into the system and respond to Complab's prompts.

That's where I am stuck. In a nutshell, when Complab, or any of it's dialog boxes or child windows, is visible, I want to force the focus onto Complab. When it either isn't running at all or is in a hidden state, I do not want to interfere with the user at all.

Sorry for the long message; any suggestions are greatly appreciated.

Thank you.

User avatar
JRL
Automation Wizard
Posts: 3505
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Jan 16, 2008 2:29 am

One way you can accomplish this is to write the onevents out to a separate script. Then have your main script (exe) run in an endless loop, waiting for the application window to be active. When the application window becomes the active window, the main script (exe) runs the onevent script. The onevent script will also need a loop to check to see that the application window is the current window. As soon as the application window is NOT the current window, the onevent script closes. See my Happy Button example.

Hope this makes sense.
Dick

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts