hunt Posted August 18, 2009 Share Posted August 18, 2009 (edited) 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 August 18, 2009 by hunt Link to comment Share on other sites More sharing options...
WolfWorld Posted August 18, 2009 Share Posted August 18, 2009 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") Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
hunt Posted August 18, 2009 Author Share Posted August 18, 2009 (edited) athiwatcSo 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 August 18, 2009 by hunt Link to comment Share on other sites More sharing options...
WolfWorld Posted August 18, 2009 Share Posted August 18, 2009 (edited) 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 August 18, 2009 by athiwatc Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
hunt Posted August 18, 2009 Author Share Posted August 18, 2009 (edited) 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 August 18, 2009 by hunt Link to comment Share on other sites More sharing options...
hunt Posted August 18, 2009 Author Share Posted August 18, 2009 Did you say it leaves 30ms?For ShellExecute is about 30 ms. But when is occurring problem then is about 2 second. Link to comment Share on other sites More sharing options...
WolfWorld Posted August 18, 2009 Share Posted August 18, 2009 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? Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
WolfWorld Posted August 18, 2009 Share Posted August 18, 2009 (edited) 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 August 18, 2009 by athiwatc Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
WolfWorld Posted August 18, 2009 Share Posted August 18, 2009 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. Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
hunt Posted August 18, 2009 Author Share Posted August 18, 2009 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now