Sign in to follow this  
Followers 0
TestMachine

Running a listener script

12 posts in this topic

Hi again beautiful creatures!

I have a small listener script that constantly checks for unwanted windows, and closes them down.

The thing I'm trying to solve is how to run this script at the same time as my regular script is doing stuff.

I'm very new to AutoIt so I wonder whats the best approach is here coming from the pro's :)

Should I just run the script seperately by the startup of my original script? If True Then How do I do this ;) ? The script is being located in the same folder as my other scripts under C:/MyScripts, which is not the AutoIt folder.

Share this post


Link to post
Share on other sites



ProcessExist?

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Please have a look at my OutlookEX UDF (for download please see my signature). Function _OL_Open starts _OL_Warnings.exe and passes some parameters to this exe (process Id, timing information etc.). This exe runs as long as the starting process exists.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

ProcessExist?

This only shows me if a certain process exists, could you elaborate?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Script A starts the compiled script B and passes the process-Id of A. B checks in a loop 1) for windows to close and 2) if the calling process A still exists (using processexist). If A doesn't exist any longer B exits itself.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Script A starts the compiled script B and passes the process-Id of A. B checks in a loop 1) for windows to close and 2) if the calling process A still exists (using processexist). If A doesn't exist any longer B exits itself.

So it has to be compiled? And lets say I just wanted to run 3-4 .au3 scripts at the same time to do different things, how would I make the first script execute the other ones? I understand this is not very optimal, but I just want to play around and learn :).

Thanks

Share this post


Link to post
Share on other sites

Do you want to start the second script if the first is working, right?

If ProcessExist(first.exe) Then
Run(@WorkingDir & "second.exe")
EndIf

Or a loop

Func Test()
Do
    Sleep(1000)
Until ProcessExists(first.exe")
Run(@WorkingDir & "second.exe")
EndFunc

Share this post


Link to post
Share on other sites

Best way to learn is to take a real life problem and write a script to solve it.

Creating a problem and then trying to solve it is a bit of a waste of time.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

For what its worth, in my past i used to use Processexists to check things but rapidly found its a heavy CPU function. Running at 250 (sleep) my script was using 6-8 cpu, i replaced them with a Winexists "as in my cases the processes all had a active window somewhere i could check to see if it existed and this had the postive effect of lowering the cpu usage for my script to 0"

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Best way to learn is to take a real life problem and write a script to solve it.

Creating a problem and then trying to solve it is a bit of a waste of time.

There is a real life problem to solve behind the scenes, I just tried to simplify my explanation of it. I appreciate your help very much and I get your point.

I have one Au3 script that is running and doing a lot of things, but a lot of things are popping up in its way to slow its progress down, which is why I want to run a script on the side to eliminate the obstacles entirely, while doing stuff like counting seconds, minutes, looking for colors e t c. If I were to do everything in my first script, a simple Sleep() will paus everything else (from what I've learned so far). That is the best explanation that I can come up with, since I got so much to learn.

Edited by TestMachine

Share this post


Link to post
Share on other sites

For what its worth, in my past i used to use Processexists to check things but rapidly found its a heavy CPU function. Running at 250 (sleep) my script was using 6-8 cpu, i replaced them with a Winexists "as in my cases the processes all had a active window somewhere i could check to see if it existed and this had the postive effect of lowering the cpu usage for my script to 0"

This too, I'm happy with running my second script only once every 10 seconds.

Share this post


Link to post
Share on other sites

Then I would suggest my approach. Give it a try and if you run into any problems we will be glad to assist you.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0