Jump to content

ProcessExists, Run, RunWait & @SW_HIDE


Anne
 Share

Recommended Posts

Hi.

I feel like an idiot for asking this but I really cannot make this work.

For some reason, I can't get my script to pause until a process has stopped when the process is hidden (With @SW_HIDE).

This is the script without the @SW_HIDE parameter:

dim $ClearID=3
RunWait("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess " & $ClearID)


MsgBox(0, "Done", "Cookies & history has been deleted")

It currently waits until the cookies & browser history is deleted and displays the MsgBox.

However, the MsgBox is displayed immediately after executing the script when I use @SW_HIDE

I have tried multiple variations but neither seem to work for me. Here is what I have tried so far:

dim $ClearID=3
RunWait("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess " & $ClearID, @SW_HIDE)


MsgBox(0, "Done", "Cookies & history has been deleted")
dim $ClearID=3
dim $run=Run("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess " & $ClearID, @SW_HIDE)
while 1
if ProcessExists($run) then
    Sleep(100)
else
    exitloop
endif
wend

MsgBox(0, "Done", "Cookies & history has been deleted")
dim $ClearID=3
dim $run=Run("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess " & $ClearID, @SW_HIDE)
while ProcessExists($run) 
    Sleep(100)
wend

MsgBox(0, "Done", "Cookies & history has been deleted")
dim $ClearID=2
dim $run=Run("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess " & $ClearID)
while 1
if ProcessExists($run) <> 0 then
    Sleep(100)
else
    exitloop
endif
wend

Any kind of help would be very much appreciated here!

Thank you very much.

Edited by Anne
Link to comment
Share on other sites

You have the parameters mixed up. You have the @SW_HIDE in the "WorkingDir" parameter, and not in the "show flag" parameter.

; this
RunWait("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess " & $ClearID, @SW_HIDE)

; should be like this
RunWait("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess " & $ClearID, "", @SW_HIDE)

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

 

You have the parameters mixed up. You have the @SW_HIDE in the "WorkingDir" parameter, and not in the "show flag" parameter.

; this
RunWait("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess " & $ClearID, @SW_HIDE)

; should be like this
RunWait("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess " & $ClearID, "", @SW_HIDE)

 

Oh my god how embarrasing!

It must be a bug in the SciTe editor, because while writing it out, when you press comma after @ClearID it  tells you that the next parameter is show_flag. But when you actually look at the code you are completely right, it is indeed in the workingdir parameter.

Well then I learned to look at what I am actually writing instead of trusting SciTe to always be one step ahead.

Thank you very much.

(Also, this is extra embarrasing while I actually did a search on the problem and came up with numerous topics where people had @SH_HIDE in the Workingdir parameter. But I was stupid and trusted SciTe to tell me what parameter was active.)

Link to comment
Share on other sites

Actually scratch that, I should have given it a try before replying.
SciTe wasn't wrong afterall.

 

RunWait("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess " & $ClearID, "", @SW_HIDE)

According to the documentation, ( http://www.autoitscript.com/autoit3/docs/functions/RunWait.htm ) this piece of code should run a hidden window and wait until it has ended before continuing the script.
However, it does not really hide the window.

According to SciTe, the @SW_HIDE is placed in the opt_flag parameter, but according to the documentation it is placed in the show_flag parameter.

When placing a comma after $ClearID it skips the WorkingDir and goes straight to show_flag

What is wrong here?

Edited by Anne
Link to comment
Share on other sites

It will hide RunDll32.exe, it my not hide other processes which that spawns.

 

Well the below code does hide the process which spawns from RunDll32.exe but it does not wait for it to finish up.

That's the problem I'm facing.

 

RunWait("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess " & $ClearID, @SW_HIDE)
Link to comment
Share on other sites

Don't go by what SciTE is telling you, the comma in your first parameter is confusing it. You're still putting the @SW_HIDE in the workingdir parameter.

BTW, when I run that command (RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 3) in the console window manually it returns immediately because it spawns another process. You can't use RunWait with this command because of this.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Don't go by what SciTE is telling you, the comma in your first parameter is confusing it. You're still putting the @SW_HIDE in the workingdir parameter.

BTW, when I run that command (RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 3) in the console window manually it returns immediately because it spawns another process. You can't use RunWait with this command because of this.

 

Well that can't be right?

Try running this script:

dim $ClearID=2
RunWait("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess " & $ClearID)


MsgBox(0, "fskfk", "Cookies & History has been deleted")

It does not prompt the MsgBox until the cookies and history has been deleted.

Oh yea you got a point in that first sentence. The comma in the first paramter must indeed be what is confusing the issue!

Hmm I'll have to do some tests then.

 

EDIT: Okay I removed the comma and it works now. However, as JohnDoe said, it does not hide the process which springs from RunDll32.exe

Any ideas on how to make it hide the new process? WinSetState?

Edited by Anne
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...