Jump to content
Sign in to follow this  
hunt

Executing time of ShellExecute is very big

Recommended Posts

hunt

Hello. I find problem with API-funtion ShellExecute.

When i use in my script, for example, ShellExecute("C:\preview.html") then on it leaves a lot of time (about 2 second). On following calls leaves 30ms.

I cannot find the reason of this problem.

My script is big (65kb).

I took some code from my script and give to a new script and in this new script is no problem.

Some code from script:

$Form1 = GUICreate("Form1", 214, 103, 193, 125)
$Button1 = GUICtrlCreateButton("Preview", 30, 30, 153, 41)
GUICtrlSetOnEvent($Button1, "_preview")

While 1
 sleep(20)
WEnd

Func _preview()
    ShellExecute("C:\предпросмотр.html")
EndFunc

Maybe reason of this problem is a big quantity of controls and events?

This problem does not occur when slowly to press the button.

Edited by hunt

Share this post


Link to post
Share on other sites
WolfWorld

it's not Autoit, my script OpenIndex is 195KB and it does not slow down.

Autoit reads from your script. It show not be that slow. Then it calls the Windows Shell API.

Which search for the extension HTML So the problem is with windows.

Try this.

Using Run

Run("IE/FF/CHROME/OPERA/SAFARI PATH" & " " & "The HTML PATH")

Share this post


Link to post
Share on other sites
hunt

athiwatc

So the problem is with windows.

Where?

Also my problem can be solved if to add before a call of function ShellExecute command:

Sleep (40) ; if sleep<40 then there is a probability of occurrence of this problem.

Edited by hunt

Share this post


Link to post
Share on other sites
WolfWorld

So what function is before it? May I ask.

Look. For the windows problem.

Run vs Shell

Run > Open The Exe/etc. File > There is your program.

Shell > WINDOWS search for the extension in the registry > it gets the run command > and it replace the %1 with the file path > then it calls Run(Window side) > Open the exe > There is your program.

And this is why ShellExeute does not return the PID

Edited by athiwatc

Share this post


Link to post
Share on other sites
hunt

Func _ViewHtml()
    ;Local $Code, $handle
    ;$Code=GuiCtrlRead($Edit_Code)
    ;$Code=StringRegExpReplace($Code,"\[city\](.+?)\[/city\]",'<img width="22" height="15" src="http://kzru.net/images/fl/$1.gif"></a>')
    ;$Code=StringReplace($Code,$crlf, "<br>")
    ;$hFile=FileOpen($NewsTempDir & "\предпросмотр.html",2)
    ;FileWrite($hFile,$Code)
    ;FileClose($hFile)
    ;MsgBox(0,"",$NewsTempDir & "\предпросмотр.html")
    ;ShellExecute($NewsTempDir & "\предпросмотр.html")
    ;ShellExecute($NewsTempDir & "\предпросмотр.html")
    ;sleep(10)
    ;$begin=TimerInit()
    ;_ShellExecuteEx("C:\предпросмотр.html")
    ;sleep(35)
    ShellExecute("C:\предпросмотр.html")
    ;Run('c:\Program Files\Opera\Opera.exe "C:\предпросмотр.html"')
    ;ShellExecute("C:\предпросмотр.html")
    ;$diff=TimerDiff($begin)
    ;MsgBox(0,"",$diff)
    ;return
EndFunc

I comments the previous functions, but all the same a problem

Edited by hunt

Share this post


Link to post
Share on other sites
hunt

Did you say it leaves 30ms?

For ShellExecute is about 30 ms. But when is occurring problem then is about 2 second.

Share this post


Link to post
Share on other sites
WolfWorld

Func _ViewHtml()
    ;Local $Code, $handle
    ;$Code=GuiCtrlRead($Edit_Code)
    ;$Code=StringRegExpReplace($Code,"\[city\](.+?)\[/city\]",'<img width="22" height="15" src="http://kzru.net/images/fl/$1.gif"></a>')
    ;$Code=StringReplace($Code,$crlf, "<br>")
    ;$hFile=FileOpen($NewsTempDir & "\предпросмотр.html",2)
    ;FileWrite($hFile,$Code)
    ;FileClose($hFile)
    ;MsgBox(0,"",$NewsTempDir & "\предпросмотр.html")
    ;ShellExecute($NewsTempDir & "\предпросмотр.html")
    ;ShellExecute($NewsTempDir & "\предпросмотр.html")
    ;sleep(10)
    ;$begin=TimerInit()
    ;_ShellExecuteEx("C:\предпросмотр.html")
    ;sleep(35)
    ShellExecute("C:\предпросмотр.html")
    ;Run('c:\Program Files\Opera\Opera.exe "C:\предпросмотр.html"')
    ;ShellExecute("C:\предпросмотр.html")
    ;$diff=TimerDiff($begin)
    ;MsgBox(0,"",$diff)
    ;return
EndFunc

I comments the previous functions, but all the same a problem

It can be because of the events. You maybe right.

Why don't you use the normal way in the first place?

Share this post


Link to post
Share on other sites
WolfWorld

I Have attached a script.

Problem is occuring when to press on button "Сгенерировать новость" and to press on button "Предпросмотр".

My guess is on the language. Try changing it to English(The file name).

I can't think of anything other than this.

Edited by athiwatc

Share this post


Link to post
Share on other sites
WolfWorld

Attached script.

Problem is occuring when to press on button "To generate news" and to press on button "Preview".

That is the same version and I don't have all the include file. c:\xxxx.html and so on.

But I have a solution for you. Create another Autoit file and run that exe and let that exe run the html.

Share this post


Link to post
Share on other sites
hunt

That is the same version and I don't have all the include file. c:\xxxx.html and so on.

Sorry. I has mixed dirs. This version with english buttons "To generate news" and "Preview".

But I have a solution for you. Create another Autoit file and run that exe and let that exe run the html.

I created other autoit file. In it there is no problem.

script.zip

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  

×