Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 18:29

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Waiting function

Discussion on Waiting function within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1
 
Krasti's Avatar
 
elite*gold: 4
Join Date: Aug 2011
Posts: 2,169
Received Thanks: 7,917
Waiting function

Sup
I wanna know if there is any way make the program wait for a process.
I was about to use while,but it's blocking the execution of the program,so...

There is a button which is waiting the process and then it doing its stuff.
The program is a window application and using dialogs

Code:
case IDC_BUTTON1:        v Process
        while(isRunning("S4Client.exe")==false){}
                 ^The waiting func
Krasti is offline  
Old 07/01/2012, 22:49   #2


 
MrSm!th's Avatar
 
elite*gold: 7110
Join Date: Jun 2009
Posts: 28,902
Received Thanks: 25,407
You cannot wait in that case-block, since you are within the message loop of a window and it wouldn't react anymore, if you did.
You could use a thread or a timer; since it's just that little task, i would tend to use the timer. You create a timer that ticks every 100ms and add a handler for it to your message loop.
MrSm!th is offline  
Thanks
2 Users
Old 07/01/2012, 22:50   #3
 
xNopex's Avatar
 
elite*gold: 0
Join Date: May 2009
Posts: 827
Received Thanks: 471
I've never tried this before but it should be possible to install a global windows hook which receives a notification when the S4Window has been created:

>>
>>

Quote:
You could use a thread or a timer; since it's just that little task, i would tend to use the timer. You create a timer that ticks every 100ms and add a handler for it to your message loop.
Polling is...
xNopex is offline  
Thanks
1 User
Old 07/01/2012, 22:58   #4
 
Naworia's Avatar
 
elite*gold: 12
Join Date: Aug 2011
Posts: 455
Received Thanks: 418
Use Autoit library so you can it easy.
Naworia is offline  
Old 07/01/2012, 23:05   #5
 
Krasti's Avatar
 
elite*gold: 4
Join Date: Aug 2011
Posts: 2,169
Received Thanks: 7,917
Quote:
Originally Posted by MrSm!th View Post
You cannot wait in that case-block, since you are within the message loop of a window and it wouldn't react anymore, if you did.
You could use a thread or a timer; since it's just that little task, i would tend to use the timer. You create a timer that ticks every 100ms and add a handler for it to your message loop.
Use timer?SetTimer or?

Quote:
Originally Posted by Naworia View Post
Use Autoit library so you can it easy.
You may use Autoit function in C++ or?
EDIT: Tried but again it's freeze
Krasti is offline  
Old 07/02/2012, 01:00   #6
 
Naworia's Avatar
 
elite*gold: 12
Join Date: Aug 2011
Posts: 455
Received Thanks: 418
Use this.
While(true)
{
if(ProcessExists("S4") == true)
{
"successs";
}
}
Naworia is offline  
Old 07/02/2012, 01:23   #7


 
MrSm!th's Avatar
 
elite*gold: 7110
Join Date: Jun 2009
Posts: 28,902
Received Thanks: 25,407
Quote:
Originally Posted by Naworia View Post
Use this.
While(true)
{
if(ProcessExists("S4") == true)
{
"successs";
}
}
You clearly did not understand the problem.
MrSm!th is offline  
Old 07/02/2012, 13:09   #8
 
.SkyneT.'s Avatar
 
elite*gold: 273
Join Date: Sep 2010
Posts: 1,831
Received Thanks: 786
Quote:
Originally Posted by Naworia View Post
Use Autoit library so you can it easy.
Plz not :<


@Topic:
Create a thread:

And let it check every, for instance 100ms, if the Process is running
with .
(I know a new thread isnt the best way to do this, but it should work)
.SkyneT. is offline  
Thanks
1 User
Old 07/02/2012, 15:21   #9
 
Krasti's Avatar
 
elite*gold: 4
Join Date: Aug 2011
Posts: 2,169
Received Thanks: 7,917
Quote:
Originally Posted by .SkyneT. View Post
Plz not :<


@Topic:
Create a thread:

And let it check every, for instance 100ms, if the Process is running
with .
(I know a new thread isnt the best way to do this, but it should work)
The thread i should make at begin of program?
Cause the users should choose by checkboxes and then button should wait process etc.
Krasti is offline  
Old 07/02/2012, 16:31   #10
 
.SkyneT.'s Avatar
 
elite*gold: 273
Join Date: Sep 2010
Posts: 1,831
Received Thanks: 786
Quote:
Originally Posted by Krasti View Post
The thread i should make at begin of program?
Cause the users should choose by checkboxes and then button should wait process etc.
Code:
If (Checkbox == checked)
{
    CreateThread
}
if (Checkbox != checked)
{
    SuspendThread or TerminateThread
}
The thread runs the loop to check if the Process is running.
.SkyneT. is offline  
Thanks
1 User
Old 07/02/2012, 19:51   #11
 
elite*gold: 0
Join Date: Jun 2012
Posts: 187
Received Thanks: 58
The Correct way:


to get the Handle of the process, use 'PROCESS_ALL_ACCESS', and inherit the handle (second parameter true).


pass the handle and the maximum time you wish to wait.


Create an Event after the WaitForSingleObject call to notify your main thread.

Put these three calls in a function and in your main thread you just let yourself be notified via the event you set up (see MSDN).

Finally, call on that function. Once the target application terminates, your secondary thread will unblock and create an event which notifies your main thread.
tnd0 is offline  
Old 07/04/2012, 00:36   #12


 
MrSm!th's Avatar
 
elite*gold: 7110
Join Date: Jun 2009
Posts: 28,902
Received Thanks: 25,407
Quote:
Originally Posted by xNopex View Post
I've never tried this before but it should be possible to install a global windows hook which receives a notification when the S4Window has been created:

>>
>>



Polling is...
Impossible, S4 is protected by XTrap, a long time before the window is created and i am **** sure, he wants to write a trainer.

Quote:
Originally Posted by tnd0 View Post
The Correct way:
Nope, it's wrong, he wants to wait untill S4 starts and not untill it terminates.
MrSm!th is offline  
Old 07/04/2012, 07:25   #13




 
Omdi's Avatar
 
elite*gold: 1
Join Date: Apr 2010
Posts: 13,772
Received Thanks: 15,036
Here how to do that with a thread
Code:
DWORD WINAPI Thread(LPVOID lpParam)
{
UNREFERENCED_PARAMETER(lpParam);

while(isRunning("S4Client.exe")==false)
Sleep(100);

//do ur stuff

return TRUE;
}

case IDC_BUTTON1:        
        CreateThread(NULL, NULL, Thread, NULL, NULL, NULL);
        break;
Omdi is offline  
Thanks
1 User
Old 07/04/2012, 16:29   #14
 
Krasti's Avatar
 
elite*gold: 4
Join Date: Aug 2011
Posts: 2,169
Received Thanks: 7,917
I put the stuff i wanna do in a function,but the IsDlgButtonChecked isn't work.
I mean after the while,i made it,but it didn't do anything...I hope you get me
Krasti is offline  
Old 07/04/2012, 16:31   #15




 
Omdi's Avatar
 
elite*gold: 1
Join Date: Apr 2010
Posts: 13,772
Received Thanks: 15,036
Quote:
Originally Posted by Krasti View Post
I put the stuff i wanna do in a function,but the IsDlgButtonChecked isn't work.
I mean after the while,i made it,but it didn't do anything...I hope you get me
Did your programm freez or what ?
It shouldn't freeze if you do ur stuff in a thread.
Omdi is offline  
Reply


Similar Threads Similar Threads
[VIP-function] ToxicSYS [VIP-function]
08/14/2010 - WarRock Hacks, Bots, Cheats & Exploits - 1 Replies
heeeey E-pvpers :pimp: this is a new hack by TSYS Status : UNDETECTED Functions (VIDEO) : YouTube - WarRock - Bikini event VIP hack
[FRIENDLY WAITING ROOM]Cheat Engine waiting updates here..
07/06/2009 - Grand Chase - 49 Replies
Since,many of us are really craving for teh updated MLE or other Engine. I would like to create this thread to fix and clean this GC Area section..As we could see..Many threads are being revived and some are fake threads.. At this thread..We all are working as one.I promise..If i got and hunt the new engine i'll be updating this thread soon..This thread will be permanent in case of losing Engine again. TAKE NOTE: We are all taking this engines for granted. We are enjoying games because of...
We are all waiting!!!
10/18/2007 - WarRock - 3 Replies
Hi all!!! We are all waiting for the new GST tool hack!!! i think was one of the best, or the best, public hack i used!!! no bugs at all!! please update it!!!! thanks all!!!
im waiting for the ban
04/28/2006 - Conquer Online 2 - 1 Replies
when will you ban my acc?



All times are GMT +1. The time now is 18:30.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.