Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Help] hWND Active app check

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
kikuvac
Master Cheater
Reputation: 0

Joined: 09 Jan 2007
Posts: 320

PostPosted: Fri Aug 15, 2008 6:19 am    Post subject: [Help] hWND Active app check Reply with quote

hi guys im currently trying to learn anvanced vb and for a project im doing i need to know if i handle a window how can i check if its active.

here is an example of what i need.

Timer1()
somthing to handle the window
if window check = true then MsgBox("Window Active") Else Textbox1.text = "Waiting on window"
end sub
end if

i know there are probably some mistakes in here but i am not on my computer and dont have my compiler with me thanks so much if you help

_________________
Respect for: Coders, Anti Spoon feeders, nice people.

MapleHost
Back to top
View user's profile Send private message
Xt3hb4nd1tX
Festering pile of crap
Reputation: 0

Joined: 12 Mar 2007
Posts: 953
Location: Beer Sheva, Israel

PostPosted: Fri Aug 15, 2008 10:13 pm    Post subject: Reply with quote

Google is your friend
http://www.vbexplorer.com/VBExplorer/tips/src09.htm

_________________
Back to top
View user's profile Send private message MSN Messenger
Codeslinger
I post too much
Reputation: 1

Joined: 11 Oct 2007
Posts: 3652
Location: Midwest, United States of America

PostPosted: Fri Aug 15, 2008 10:31 pm    Post subject: Reply with quote

MSDN is your friend

And this is not maple related

And this is not advanced VB
Back to top
View user's profile Send private message MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sat Aug 16, 2008 5:33 am    Post subject: Reply with quote

FindWindow / GetForegroundWindow will do what you need.

On Form1, add 1 textbox. Then add 1 module to the project.

Form1 Code
Code:
Option Explicit

Private Sub Form_Load()
    '//
    '// Create a timer that loops every 10 miliseconds..
    '//
    SetTimer Me.hwnd, 0, 10, AddressOf TimerProc
End Sub


Module1 Code
Code:
Option Explicit

'// Window API
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetForegroundWindow Lib "user32" () As Long

'// Timer API
Public Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long


Sub TimerProc(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long)
    Dim hWnd_Notepad As Long
    Dim hWnd_Current As Long
   
    hWnd_Notepad = FindWindow("Notepad", vbNullString)
    hWnd_Current = GetForegroundWindow()
       
    If (hWnd_Notepad = hWnd_Current) Then
        KillTimer Form1.hwnd, 0
        Form1.Text1.Text = "Notepad is active!"
        Exit Sub
    End If
    Form1.Text1.Text = "Notepad is not active!"
End Sub

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites