Sign in to follow this  
Followers 0
AHJAHJ

I Want Helping In This Script ...

15 posts in this topic

#1 ·  Posted (edited)

Hi All,

I try this Script but it doesn't run properly

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Run ("A.exe")

ProcessClose ("A.exe")

Msgbox (0,"A","A")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

First : Autoit Run A.exe then two process starts in same name (( one of them in System and the other is normal))

after nearly 5 second the normal process Closes and the system Process Still Running ...

I want doing something ((For eg MSGBox )) When Normal Process Closed ...

I hope you understand what am i want .

Edited by AHJAHJ

Share this post


Link to post
Share on other sites



HI,

Opt("OnExitFunc", "endscript")
MsgBox(0,"","first statement")

Func endscript()
    MsgBox(0,"","after last statement " & @EXITMETHOD)
EndFunc

Hope that helps.

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

No NO !!

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hi,

after read it again, I think what you need is to detect in which user context a process is running.

So, you've got to processes with the same name and want to know when the user context process is closed.

I have to look that up. I duuno jet, how to get the ProcessOwner or ProcessUser ...

So long,

Mega

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

You could always look at ProcessWaitClose() if you wanting to do something "After" the process has closed.

But even if there is a language barrier, I suggest you type it in your native tongue, and then try and do a translation so that maybe you can get the help you want or "think" you deserve... the "No No !!" didn't read so nicely from me, and I'm sure wasn't taken nicely from th.meger that was only trying to help from what he understood..


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Hi,

have a look at : http://www.autoitscript.com/forum/index.ph...284&hl=GetOwner

Hope that helps

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

I hope you understand what am i want .

I'm game. Is this what you want?:
$pid = Run("charmap")
While 1
    If ProcessWaitClose($pid) Then
        MsgBox(1,"alert:","Process " & $pid & " is closed")
        Exit
    EndIf
WEnd

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I hope you understand what am i want .

WAIT! This is even better!!
#include <Process.au3>

; run the program
$pid = Run("charmap")
Run("charmap"); to simulate the shadow copy for my testing only
$pname = _ProcessGetName($pid)
$parray = ProcessList()

; find the "shadow" copy of the program
For $i = 1 to $parray[0][0]
    If $parray[$i][0] = $pname And $pid <> $parray[$i][1] Then 
        $secondpname = $parray[$i][1]
        ExitLoop
    EndIf
Next
    
; wait for the shadow copy to close and let me know when it does
While 1
    If ProcessWaitClose($secondpname) Then
        MsgBox(1,"alert:","Process " & $secondpname & " is closed")
        Exit
    EndIf
WEnd
Edited by jefhal

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

Thanks All, :(

I'm game. Is this what you want?:

$pid = Run("charmap")
While 1
    If ProcessWaitClose($pid) Then
        MsgBox(1,"alert:","Process " & $pid & " is closed")
        Exit
    EndIf
WEnd
It Runs Successfully :)

Share this post


Link to post
Share on other sites

be sure to put a small sleep inside the while loop as not to use CPU

while

; your stuff

sleep(10)

wend

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

be sure to put a small sleep inside the while loop as not to use CPU

while

; your stuff

sleep(10)

wend

8)

I don't see that mattering... the sleep() or the If/Then Statement... Example:
$PID = Run('Notepad.exe')
ProcessWait($PID)
While 1
    If ProcessWaitClose($PID) Then
        MsgBox(64, 'Closed', 'Closed Pid')
    EndIf
    If MsgBox(64, 'Info:', "If you got here, the If statement made a difference, if not until after you got the first msgbox() it didn't") = 1 Then Exit
WEnd

Edit:

So in other words, there's no difference between the above and this:

$PID = Run('Notepad.exe')
ProcessWait($PID)
ProcessWaitClose($PID)
MsgBox(1,"alert:","Process " & $pid & " is closed")
Exit
Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

ProcessWait($PID)

ProcessWaitClose($PID)

Hi SmOke_N-

Do the above functions have some kind of "cpu saver" built into them, or do they consume lots of cpu time while they are waiting? If they don't then maybe the while wend loop with a sleep(10) would be less cpu intensive? - jefhal


...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

From the AutoIt manual entry for *both* functions,

in a paragraph all by itself...

"The process is polled approximately every 250 milliseconds."

-mu

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