Solved

VB program will not come to front in all cases

Posted on 2002-04-23
6
154 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

760 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

18 Experts available now in Live!

Get 1:1 Help Now