gsb Posted December 2, 2006 Share Posted December 2, 2006 I am still new at this. But a while back I made a script to use and got it working fine ...with considerable help from you folks, TY. Now with IE7 it has a problem closing. The code I am using includes: ... Run(@ProgramFilesDir & "\Internet Explorer\Iexplore.exe -k " & $filename, @WorkingDir) WinWait("") $handle = WinGetHandle("") ... WinClose($handle) Exit 0 I DL'd the latest version, installed and recompiled the script w/o any luck. Any thoughts what I need to do to fix it up? Thanks, gsb "Did you ever stop to think? ...and forget to restart!" Link to comment Share on other sites More sharing options...
GaryFrost Posted December 2, 2006 Share Posted December 2, 2006 I suggest looking at the IE Mananagment UDFs in the help and changing your code to use those functions. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
gsb Posted December 2, 2006 Author Share Posted December 2, 2006 gafrost, Thanks for your response. It is not like I have not pawed through much of the help files but the original code came from this forum a couple of months ago. Again, it worked fine. I think the only change was my loading IE7. And now it no longer works. Yes. With days I may get through all of the help files. And there is still a good chance that I will not know exactly what happened, why and what is the better approach. So you are right: that is a good source. But I was looking for, hoping for, a bit more information/code to: 1) get it working again, and 2) point out to me as to why this no longer works. Don't get me wrong, I appreciate you time to respond; but I know where the help files are, have been reading them and have done several searches here on the forum to no avail. gsb "Did you ever stop to think? ...and forget to restart!" Link to comment Share on other sites More sharing options...
mikehunt114 Posted December 2, 2006 Share Posted December 2, 2006 What's $filename? Post a complete script as well as console output/error logs and it will be easier to help. I don't know where you are having problems. The easier you make it for us the more likely we are to help. Otherwise, try replacing WinClose with WinKill. IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font] Link to comment Share on other sites More sharing options...
MHz Posted December 2, 2006 Share Posted December 2, 2006 Try using window class names to find the window. Try this Opt('WinTitleMatchMode', 4) $filename = 'www.google.com' Run('"' & @ProgramFilesDir & '\Internet Explorer\Iexplore.exe" -k ' & $filename, @WorkingDir) WinWait("classname=IEFrame") $handle = WinGetHandle("classname=IEFrame") Sleep(5000) WinClose($handle) Link to comment Share on other sites More sharing options...
GaryFrost Posted December 2, 2006 Share Posted December 2, 2006 depending on the filename I think will depend on what IE7 will do. For instance the following code will attempt to download the file, not open it in a browser window Run(@ProgramFilesDir & "\Internet Explorer\Iexplore.exe -k " & @ScriptDir & "\test2.au3") SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
gsb Posted December 2, 2006 Author Share Posted December 2, 2006 Thank you all again for the responses. I reduced the code to what I thought was salient to the issue. Seems "big" code gets less attention here on the forum and I thought that the main issue was the opening and closing. As I said before, it was working fine, same filename etc., in IE6. The filename: $filename = "http://www.gypsytrader.com/testing/index.html" This is a default but it should work with any similar page. This is a Flash content wrapper HTML file. Here is the full code: expandcollapse popup#Include <GUIConstants.au3> #Include <Constants.au3> #Include <File.au3> #include <IE.au3> #Include "Misc.au3" #Include <array.au3> #NoTrayIcon if _Singleton("gsb_fscp",1) = 0 Then MsgBox(262144," fscp","...already running. Aborting.", 10) Exit 0 EndIf $filename = _ArrayToString($cmdline," ",1) If stringlen( $filename) = 0 Then $filename = "http://www.gypsytrader.com/testing/index.html" ElseIf ( stringright($filename,4) <> ".swf" AND stringright($filename,5) <> ".html") Then MsgBox(262144,"File Error","Bad file type.", 10) Exit 0 EndIf $count=0 While NOT Ping("Google.com") If $count < 4 Then $count += 1 Else ;MsgBox(262144,"No Internet","You are not connected to the internet." & @CRLF & "Terminating now.") ;Exit 0 MsgBox(262144,"No Internet","You are not connected to the internet." & @CRLF & "Using local index.html") $filename = @WorkingDir & "\index.html" ExitLoop EndIf Wend HotKeySet("+!t", "Terminate"); Shift-Alt-t $log_file = @WorkingDir & "\gsb_fscp.log" _FileWriteLog($log_file, @ScriptName & " started with " & $filename ) Run(@ProgramFilesDir & "\Internet Explorer\Iexplore.exe -k " & $filename, @WorkingDir) ;Run(@ProgramFilesDir & "\Internet Explorer\Iexplore.exe -k " & @ScriptDir & "\application.html", @WorkingDir) WinWait("") $handle = WinGetHandle("") Opt("TrayMenuMode",1) ;TraySetIcon("gsb_fscp.ico") TraySetToolTip("fsCommand processor" & @CRLF & "by GSB v061014a") $aboutitem = TrayCreateItem("About") TrayCreateItem("") $exititem = TrayCreateItem("Exit") TrayCreateItem("") $abortitem = TrayCreateItem("Abort") TraySetState() $gui = GUICreate("gsb_fscp", 1, 1, -1, -1) GUISetIcon ("SWiSHmax.ico") $sfObj = ObjCreate("ShockwaveFlash.ShockwaveFlash.1") $SinkObject = ObjEvent($sfObj,"controller_"); $GUIActiveX = GUICtrlCreateObj($sfObj, 0, 0, 1, 1) $sfObj.Movie = @ScriptDir & "\controller.swf?gsbTraceLevel=2" $sfObj.SetVariable("/:aiTrace",@scriptdir & " started."); While 1 $msg = TrayGetMsg() Switch $msg Case 0 ContinueLoop Case $aboutitem Msgbox(64,"About: fscp","fsCommand processor." & @CRLF & "by GSB v061014a") Case $exititem $sfObj.SetVariable("/:terminate","TrayMenu"); Case $abortitem Msgbox(0," fscp","Bad idea!") ExitLoop EndSwitch WEnd WinClose($handle) _FileWriteLog($log_file, @ScriptName & " aborted..." & @CRLF & @CRLF ) Exit 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func controller_FSCommand($cmd,$args) Select Case $cmd = "exit" $sfObj.SetVariable("/:terminate","Application"); Case $cmd = "terminate" _FileWriteLog($log_file, @ScriptName & " terminated...[" & $args & "]" & @CRLF & @CRLF ) WinClose($handle) Exit 0 Case $cmd = "showmenu" Case $cmd = "log" _FileWriteLog($log_file, $args ) Case Else $a = StringSplit($args,"|||",1) If $a[0] > 1 Then $from = $a[1] $args = $a[2] Else $args = $a[1] $from = "none" EndIf _FileWriteLog($log_file, "FSCommand - cmd: " & $cmd & " Args: " & $args & @CRLF) $sfObj.SetVariable("/:returnvalue",$from & "|||Success"); MsgBox(262144," fscp","au3 FSCommand" & @crlf & "From: " & $from & @crlf & "Cmd: " & $cmd & @crlf & "Args: " & $args, 10) EndSelect EndFunc Func Terminate() HotKeySet("+!t"); Shift-Alt-t $sfObj.SetVariable("/:terminate","HotKeys"); EndFunc It is setup to run a local or remote (from server) Flash content wrapper HTML file and provide custom local fsCommand processing. mikehunt114, I do not have console output/error logs nor do I know how to generate them. :"> MHz, Thank you for your example code. I will try that and let you know. gafrost, And TY again. The problem is not in opening for it opens the HTML/Flash; it runs fine and can use the fsCommand processor fine as well. It just will not exit properly, leaving the "full screen" browser window open. I will try these potential fixes tomorrow. Thanks again folks. gsb "Did you ever stop to think? ...and forget to restart!" Link to comment Share on other sites More sharing options...
herewasplato Posted December 2, 2006 Share Posted December 2, 2006 (edited) ...2) point out to me as to why this no longer works......because you installed IE7 :-) Let us simplify the test case to this code:Run(@ProgramFilesDir & "\Internet Explorer\Iexplore.exe -k") WinWait("") $handle = WinGetHandle("") WinClose($handle)It opens IE6, [seems to] waits, gets the handle of the IE6 window and closes the IE6 window. [i was controlling the IE6 system via Windows Remote Desktop - that kind of messes with scripts and windows a bit anyway.] On a system with IE7... It opens IE7, DOES NOT WAIT, gets the handle of whatever window is active and closes it. A simple 3 second sleep above or below the WinWait line will make the rest of the script work as expected on a "IE7 system". Can anyone explain that change? [NVM] Edit: I was able to test the code above on two much slower systems, both running IE6 and it did not "wait"... so the [iE6] window did not close. I would guess that the before/after (work/no work) for the code posted [by the OP] was because of the additional time that it takes IE7 to load on the [OP's] system. The empty WinWait line made no sense to me... which is why I was interested in the post in the first place. Edit2: Attempted to clarify some things. Edit3: Clear as mud? -MSP- Edited December 2, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
herewasplato Posted December 2, 2006 Share Posted December 2, 2006 I did not want to make an Edit4 :-) Since the OP only posted part of his code, I wondered about any OPT settings that might be in the full code. WinWait("") made me think of WinTitleMatchMode 4 and from what I read in the help file, a WinWait("") line would only be of use with a prior window match... I was really shocked that the sample code that I posted worked everytime on the first IE6 system that I tested. I thought that something was letting the script wait long enough to get the right handle. Well, as it turns out - something was - but more importantly IE6 was loading fast enough for the bad code to work. From the help file under AutoItSetOption, WinWaitDelay:Alters how long a script should briefly pause after a successful window-related operation. Time in milliseconds to pause (default=250).So, if no OPT settings were used [as was the case for my test code], then the WinWait line = one 250 millisecond sleep... long enough for IE6 to "reload". [Reload since it never leaves RAM - once loaded - unless pushed out by Windows memory management.] -MSP- [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
herewasplato Posted December 2, 2006 Share Posted December 2, 2006 (edited) ...I think the only change was my loading IE7...In case you did not find my point (guess) from all of my previous ramblings - here is the executive summary:WinWait("") does little more than sleep for 250 millisecondsIE7 takes a bit longer than that to load on your system.$handle = WinGetHandle("") grabbed the handle of some window other than the IE7 one because IE7 had not finished loading by the time that line of code executed.Edit: Therefore, WinClose($handle) did not close the IE7 window....of course, I could be wrong about all of this... Edited December 2, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
MHz Posted December 2, 2006 Share Posted December 2, 2006 ...of course, I could be wrong about all of this...Your recognition of the problem sounds good to me. Link to comment Share on other sites More sharing options...
gsb Posted December 2, 2006 Author Share Posted December 2, 2006 I really appreciate your time to explain that to me, herewasplato. And MHz, your code changes have it up and running again, thank you. I looked up the functions and re-read them. I think I understand it much better now, certainly not fully, LOL. I am open to any further suggestions for improving the code, should anyone feel like continuing my education. Though it is unlikely that I will use AutoIt for anything else anytime soon. This was an experiment to find a mechanism for running the flash content. I use it as a demo and point other interested people here to expand on their own ideas. Thanks again to all. gsb "Did you ever stop to think? ...and forget to restart!" Link to comment Share on other sites More sharing options...
herewasplato Posted December 2, 2006 Share Posted December 2, 2006 I really appreciate your time to explain that to me, herewasplato...You are welcome - I could not sleep anyway. Thanks for wading thru my ramblings. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
herewasplato Posted December 2, 2006 Share Posted December 2, 2006 Your recognition of the problem sounds good to me. Thanks for the confirmation. As tired as I was, I feared that I had overlooked some other issue and was off chasing the wrong rabbit. [size="1"][font="Arial"].[u].[/u][/font][/size] 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