• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 163
  • Last Modified:

VB program will not come to front in all cases

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
sdbanks
Asked:
sdbanks
1 Solution
 
n_narayananCommented:
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
 
n_narayananCommented:
Another link for you

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

Narayanan
0
 
delloroCommented:
What about:

AppActivate me.caption

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

?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
sdbanksAuthor Commented:
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
 
DanRollinsCommented:
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
 
SpideyModCommented:
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now