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 


[Visual Basic help needed].

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

Joined: 08 Mar 2008
Posts: 95

PostPosted: Tue Sep 23, 2008 12:40 pm    Post subject: [Visual Basic help needed]. Reply with quote

I have created a program and made a label that says 'Status :' next to it says 'Program not running' I want to make it so that when i make the program opens CMD it changes the label text to 'Program running'. I know how to change the text but how do i make it so that the program detects when CMD is open or not?

Help is appreciated.
Back to top
View user's profile Send private message
Cryoma
Member of the Year
Reputation: 198

Joined: 14 Jan 2009
Posts: 1819

PostPosted: Tue Sep 23, 2008 12:47 pm    Post subject: Reply with quote

scan for process cmd.exe
If it's true then status.text ="Program Running"
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Tue Sep 23, 2008 12:51 pm    Post subject: Reply with quote

FindWindow

or

CreateToolhelp32Snapshot
Process32First
Process32Next
Back to top
View user's profile Send private message
Cryoma
Member of the Year
Reputation: 198

Joined: 14 Jan 2009
Posts: 1819

PostPosted: Tue Sep 23, 2008 12:53 pm    Post subject: Reply with quote

Wow all these years I've been doing things unnecessarily complicated.
Back to top
View user's profile Send private message
cildor666
Advanced Cheater
Reputation: 0

Joined: 08 Mar 2008
Posts: 95

PostPosted: Tue Sep 23, 2008 1:10 pm    Post subject: Reply with quote

slovach wrote:
FindWindow

or

CreateToolhelp32Snapshot
Process32First
Process32Next


I don't understand the bottom way, and i'm using visual basic 2008 express edition so i don't think the 'FindWindow' command exists. I was thinking of something like 'If process "cmd" = running Then label1.text = Program running' I know that command doesn't exist but i need something like that. Confused
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Tue Sep 23, 2008 1:19 pm    Post subject: Reply with quote

cildor666 wrote:
slovach wrote:
FindWindow

or

CreateToolhelp32Snapshot
Process32First
Process32Next


I don't understand the bottom way, and i'm using visual basic 2008 express edition so i don't think the 'FindWindow' command exists. I was thinking of something like 'If process "cmd" = running Then label1.text = Program running' I know that command doesn't exist but i need something like that. Confused


pinvoke, then call it.

or do it the managed way, which is probably smarter since you're using .NET

Look at the System.Diagnostics.Process class.

The GetProcessesByName method will be of use.

http://msdn.microsoft.com/en-us/library/z3w4xdc9.aspx
Back to top
View user's profile Send private message
cildor666
Advanced Cheater
Reputation: 0

Joined: 08 Mar 2008
Posts: 95

PostPosted: Tue Sep 23, 2008 1:56 pm    Post subject: Reply with quote

But i want to type it into the form code, so its like 'If Process("CMD") = running then Label1.Text = "Program Running" - Something similar.
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Tue Sep 23, 2008 2:39 pm    Post subject: Reply with quote

How about you actually try reading the article?

It returns a process array, can you guess what happens when there's no match?
The array is empty.
Back to top
View user's profile Send private message
Fuzz
Grandmaster Cheater
Reputation: 0

Joined: 12 Nov 2006
Posts: 531

PostPosted: Tue Sep 23, 2008 6:33 pm    Post subject: Reply with quote

Just use the API FindWindow, not sure if you can in VB, but yeah. Then just see if the HWND finwwindow == 1. Not sure to the VB equivilant.
_________________
Back to top
View user's profile Send private message AIM Address
Polynomial
Grandmaster Cheater
Reputation: 5

Joined: 17 Feb 2008
Posts: 524
Location: Inside the Intel CET shadow stack

PostPosted: Tue Sep 23, 2008 7:01 pm    Post subject: Reply with quote

Simple way to do it in VB.NET:

Code:
Public Function IsApplicationRunning(ByVal ApplicationName As String) As Boolean
    Return System.Diagnostics.Process.GetProcessesByName(ApplicationName).Length > 0
End Function


Note that you call this method with the friendly name of the executable - so you would do IsApplicationRunning("cmd") not IsApplicationRunning("cmd.exe"). The >0 part at the end of the Return line basically checks if any processes were found that match the name you specified and if so, return true (else return false).

If you want it in C# for whatever reason:
Code:
public bool IsApplicationRunning(string ApplicationName)
{
    return System.Diagnostics.Process.GetProcessesByName(ApplicationName).Length > 0;
}
Back to top
View user's profile Send private message
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