Solved

VB program will not come to front in all cases

Posted on 2002-04-23
6
156 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
change vba from autofit to 13.5 width? 4 29
VBA: Select SQL query based on a config Sheet v2 11 44
Hide vba in gp 7 93
fso.FolderExists("\\server\HiddenFolder$") 4 64
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

816 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

12 Experts available now in Live!

Get 1:1 Help Now