Solved

VB program will not come to front in all cases

Posted on 2002-04-23
6
155 Views
Last Modified: 2010-05-02
I have written a program that limits my kids time on the computer.  It basically has a timer that runs in the background and when the allowable time is up, a screen covers the screen.  

The problem is certain games, "Need for Speed III" and "Game of Life" do not allow the timer program to get focus and therefore the kids can go over the time in them.

Is there a way to force a program to get focus a certain number of times per minute or second?

0
Comment
Question by:sdbanks
6 Comments
 
LVL 3

Expert Comment

by:n_narayanan
ID: 6964605
sdbanks

You can rather close the game program first and bring the focus to your screen.

The following is the link to close any program.

http://www.freevbcode.com/ShowCode.Asp?ID=2781

http://www.freevbcode.com/ShowCode.Asp?ID=935

Option Explicit

Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Public Const WM_CLOSE = &H10

Public Sub CloseProgram(ByVal Caption as String)

 Handle= FindWindow(vbNullString, Caption)
 If Handle = 0 Then Exit Sub
 SendMessage Handle, WM_CLOSE, 0&, 0&

End Sub

Hope this will solve your problem.

Narayanan.
0
 
LVL 3

Expert Comment

by:n_narayanan
ID: 6964611
Another link for you

http://www.freevbcode.com/ShowCode.Asp?ID=1453

Narayanan
0
 
LVL 1

Expert Comment

by:delloro
ID: 6964750
What about:

AppActivate me.caption

if you have a form and a name for the form you are using.

?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:sdbanks
ID: 6966914
Thanks for your comments.

The problem I am having is that my program never gets any CPU time to do anything with the previously mentioned programs ("Need for Speed III").  They seem to be designed to use the pc exclusively.  What I need is a method to ensure my pc gets some CPU time in order to do its checks.

Unless I can get some CPU time, I cannot do anything.  That would include trying to close the offending programs.



0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7660778
Hi sdbanks,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.

sdbanks, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 7755405
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now