gcue Posted June 3, 2010 Share Posted June 3, 2010 (edited) i have a script that has an IE object embedded that becomes unresponsive peridically.. im not sure what happens that would cause the unresponsiveness.. i registered a com handler but it never gets to that - any ideas? expandcollapse popup#NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=webcam.ico #AutoIt3Wrapper_Outfile=Camera.exe #AutoIt3Wrapper_Res_Fileversion=0.8.0.0 #AutoIt3Wrapper_Run_Tidy=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> #include <array.au3> #include <ComboConstants.au3> #include <StaticConstants.au3> #include <Constants.au3> #include <Misc.au3> #include <ButtonConstants.au3> Opt("GUIOnEventMode", 1) Global $script_version = ("Camera v" & FileGetVersion(@ScriptName)) Global $tools_dir = "\\share_server\Share\App\" Global $log_dir = "\\share_server\Share\Log\" Global $log_file = $log_dir & "log.txt" Global $multi_enabled, $URL, $users[17][3] Global $always_on_top, $default_camera, $switch_count = 0 Global $GUI, $IE, $URL_combo, $always_on_top_checkbox, $background, $set_default_btn Global $x_position, $y_position Global $Custom_COM_Error, $COM_Error = 0 _IEErrorHandlerRegister("Custom_COM_Error") BuildUserArray() AssignCamera() ReadSettings() $IE = _IECreateEmbedded() If $multi_enabled = False Then If $always_on_top = "True" Then $GUI = GUICreate($script_version, 325, 310, $x_position, $y_position, $GUI_SS_DEFAULT_GUI, $WS_EX_TOPMOST) Else $GUI = GUICreate($script_version, 325, 310, $x_position, $y_position, $GUI_SS_DEFAULT_GUI) EndIf $refresh_btn = GUICtrlCreateButton("", 3, 3, 20, 21, $BS_ICON) GUICtrlSetOnEvent(-1, "CameraRefresh") GUICtrlSetImage(-1, "xpsp2res.dll", -54, 0) GUICtrlSetTip(-1, "Refresh current camera") $IEGUI = GUICtrlCreateObj($IE, -13, 25, 370, 285) EndIf If $multi_enabled = True Then If $always_on_top = "True" Then $GUI = GUICreate($script_version, 325, 325, $x_position, $y_position, $GUI_SS_DEFAULT_GUI, $WS_EX_TOPMOST) Else $GUI = GUICreate($script_version, 325, 325, $x_position, $y_position, $GUI_SS_DEFAULT_GUI) EndIf $refresh_btn = GUICtrlCreateButton("", 160, 10, 20, 21, $BS_ICON) GUICtrlSetOnEvent(-1, "CameraRefresh") GUICtrlSetImage(-1, "xpsp2res.dll", -54, 0) GUICtrlSetTip(-1, "Refresh current camera") $IEGUI = GUICtrlCreateObj($IE, -13, 40, 370, 285) EndIf $always_on_top_checkbox = GUICtrlCreateCheckbox("Always on Top", 242, 5, 77, 12) GUICtrlSetOnEvent(-1, "SetTopMost") GUICtrlSetFont(-1, 7) GUICtrlSetTip(-1, "Set this window to be on top of all other windows") If $always_on_top = "True" Then GUICtrlSetState(-1, $GUI_CHECKED) EndIf If $multi_enabled = True Then $URL_combo = GUICtrlCreateCombo("", 3, 3, 95, 15, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, "COMPANY2 - SITE1|COMPANY1 - SITE1|COMPANY1 - SITE2|COMPANY2 - SITE2", $default_camera) GUICtrlSetOnEvent(-1, "SetCamera") $set_default_btn = GUICtrlCreateButton("Set As Default", 3, 25, 95, 15) GUICtrlSetOnEvent(-1, "SetDefault") GUICtrlSetFont(-1, 7) GUICtrlSetTip(-1, "Set current camera as default") EndIf SetCamera() GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) GUISetOnEvent($GUI_EVENT_CLOSE, "Xbutton") GUISetState() While 1 Sleep(100) WEnd Func BuildUserArray() ;User ;Location ;Access $users[0][0] = "USER1" $users[0][1] = "SITE1" $users[0][2] = "BOTH_COMPANIES" $users[1][0] = "USER2" $users[1][1] = "SITE1" $users[1][2] = "COMPANY1" $users[2][0] = "USER3" $users[2][1] = "SITE1" $users[2][2] = "COMPANY1" EndFunc ;==>BuildUserArray Func AssignCamera() $user_found = False $multi_enabled = False $class_B_subnet = StringLeft(@IPAddress1, 5) For $x = 0 To UBound($users) - 1 If @UserName = $users[$x][0] Then $user_found = True If $users[$x][1] = "SITE1" Then If $users[$x][2] = "COMPANY1" Then $company = "COMPANY1" If $class_B_subnet = "192.168" Then $city = "SITE1" Else $city = "SITE2" EndIf EndIf If $users[$x][2] = "COMPANY2" Then $company = "COMPANY2" If $class_B_subnet = "192.168" Then $city = "SITE1" Else $city = "SITE2" EndIf EndIf EndIf If $users[$x][1] = "SITE2" Then If $users[$x][2] = "COMPANY1" Then $company = "COMPANY1" If $class_B_subnet = "192.167" Then $city = "SITE2" Else $city = "SITE1" EndIf EndIf If $users[$x][2] = "COMPANY2" Then $company = "COMPANY2" If $class_B_subnet = "192.167" Then $city = "SITE2" Else $city = "SITE1" EndIf EndIf EndIf If $users[$x][2] = "BOTH_COMPANIES" Then $multi_enabled = True EndIf EndIf Next If $user_found = False Then MsgBox(262144, $script_version, "You do not have access to view any cameras.") Return EndIf If $multi_enabled = False Then CreateHtml($company, $city) EndIf EndFunc ;==>AssignCamera Func CreateHtml($company, $city) If $company = "COMPANY2" And $city = "SITE1" Then $ip = "http://192.167.22.201:80/" EndIf If $company = "COMPANY2" And $city = "SITE2" Then $ip = "http://192.168.8.230:80/" EndIf If $company = "COMPANY1" And $city = "SITE1" Then $ip = "http://192.167.10.200:80/" EndIf If $company = "COMPANY1" And $city = "SITE2" Then $ip = "http://192.168.56.220:80/" EndIf $URL = @TempDir & "\Camera.html" If FileExists($URL) Then FileDelete($URL) EndIf $text = '<html>' & @CRLF $text &= '<title>' & $company & '-' & $city & ' Camera</title>' & @CRLF $text &= '<style>' & @CRLF $text &= '<!--' & @CRLF $text &= ' /* Style Definitions */' & @CRLF $text &= ' p.MsoNormal, li.MsoNormal, div.MsoNormal' & @CRLF $text &= ' {mso-style-parent:"";' & @CRLF $text &= ' margin:0in;' & @CRLF $text &= ' margin-bottom:.0001pt;' & @CRLF $text &= ' mso-pagination:widow-orphan;' & @CRLF $text &= ' font-size:12.0pt;' & @CRLF $text &= ' font-family:"Times New Roman";' & @CRLF $text &= ' mso-fareast-font-family:"Times New Roman";}' & @CRLF $text &= 'p.style8, li.style8, div.style8' & @CRLF $text &= ' {mso-style-name:style8;' & @CRLF $text &= ' mso-margin-top-alt:auto;' & @CRLF $text &= ' margin-right:0in;' & @CRLF $text &= ' mso-margin-bottom-alt:auto;' & @CRLF $text &= ' margin-left:0in;' & @CRLF $text &= ' mso-pagination:widow-orphan;' & @CRLF $text &= ' font-size:12.0pt;' & @CRLF $text &= ' font-family:Arial;' & @CRLF $text &= ' mso-fareast-font-family:"Times New Roman";' & @CRLF $text &= ' color:whitesmoke;' & @CRLF $text &= ' font-weight:bold;}' & @CRLF $text &= 'span.style81' & @CRLF $text &= ' {mso-style-name:style81;' & @CRLF $text &= ' font-family:Arial;' & @CRLF $text &= ' mso-ascii-font-family:Arial;' & @CRLF $text &= ' mso-hansi-font-family:Arial;' & @CRLF $text &= ' mso-bidi-font-family:Arial;' & @CRLF $text &= ' color:whitesmoke;' & @CRLF $text &= ' font-weight:bold;}' & @CRLF $text &= '@page Section1' & @CRLF $text &= ' {size:8.5in 11.0in;' & @CRLF $text &= ' margin:1.0in 1.25in 1.0in 1.25in;' & @CRLF $text &= ' mso-header-margin:.5in;' & @CRLF $text &= ' mso-footer-margin:.5in;' & @CRLF $text &= ' mso-paper-source:0;}' & @CRLF $text &= 'div.Section1' & @CRLF $text &= ' {page:Section1;}' & @CRLF $text &= '-->' & @CRLF $text &= '</style>' & @CRLF $text &= '</head>' & @CRLF $text &= '' & @CRLF $text &= '<body bgcolor="#E8E8E8" lang=EN-US style="tab-interval:.5in">' & @CRLF $text &= '' & @CRLF $text &= '<div class=Section1>' & @CRLF $text &= '<div align=center>' & @CRLF $text &= '<table class=MsoNormalTable border=0 cellpadding=0 width=365 style="width:3.3in;' & @CRLF $text &= ' mso-cellspacing:1.5pt;mso-padding-alt:0in 5.4pt 0in 5.4pt">' & @CRLF $text &= ' <tr style="mso-yfti-irow:0;mso-yfti-firstrow:yes">' & @CRLF $text &= ' <td style="background:#006699;padding:.75pt .75pt .75pt .75pt">' & @CRLF $text &= ' <p class=MsoNormal align=center style="margin-right:7.4pt;text-align:center"><span' & @CRLF $text &= ' class=style81>' & $company & '-' & $city & ' Trading</span></p>' & @CRLF $text &= ' </td>' & @CRLF $text &= ' </tr>' & @CRLF $text &= ' <tr style="mso-yfti-irow:1">' & @CRLF $text &= ' <td style="padding:.75pt .75pt .75pt .75pt">' & @CRLF $text &= ' <p class=MsoNormal><span style="font-size:10.0pt">' & @CRLF $text &= ' <applet codebase="' & $ip & '-wvdoc-01-/LiveApplet/" height="240" archive="LiveApplet.zip" width="320" code="LiveApplet.class" VIEWASTEXT>' & @CRLF $text &= ' <param name="url" value="' & $ip & '" />' & @CRLF $text &= ' <param name="cabbase" value="LiveApplet.cab" />' & @CRLF $text &= ' <param name="capture_size" value="320x240" />' & @CRLF $text &= ' <param name="video_width" value="340" />' & @CRLF $text &= ' <param name="bg_color" value="#ececec" />' & @CRLF $text &= ' <param name="controller_style" value="no_pantilt" />' & @CRLF $text &= ' </applet>' & @CRLF $text &= ' </span></p>' & @CRLF $text &= ' </td>' & @CRLF $text &= ' </tr>' & @CRLF $text &= '</table>' & @CRLF $text &= '</div>' & @CRLF $text &= '</div>' & @CRLF $text &= '</body>' & @CRLF $text &= '</html>' & @CRLF FileWrite($URL, $text) EndFunc ;==>CreateHtml Func ReadSettings() $always_on_top = RegRead("HKLM\Software\Camera", "TopMost") $default_camera = RegRead("HKLM\Software\Camera", "Default") If $default_camera = "" Then $default_camera = "COMPANY2 - SITE1" EndIf $x_position = RegRead("HKLM\Software\Camera", "X_Position") If $x_position = "" Then $x_position = "0" EndIf $y_position = RegRead("HKLM\Software\Camera", "Y_Position") If $y_position = "" Then $y_position = "0" EndIf EndFunc ;==>ReadSettings Func SetTopMost() If BitAND(GUICtrlRead($always_on_top_checkbox), $GUI_CHECKED) Then $topmost = True WinSetOnTop($script_version, "", 1) EndIf If BitAND(GUICtrlRead($always_on_top_checkbox), $GUI_UNCHECKED) Then $topmost = False WinSetOnTop($script_version, "", 0) EndIf RegWrite("HKLM\Software\Camera", "TopMost", "REG_SZ", $topmost) EndFunc ;==>SetTopMost Func SetDefault() $default = GUICtrlRead($URL_combo) RegWrite("HKLM\Software\Camera", "Default", "REG_SZ", $default) MsgBox(262144, $script_version, $default & " has been set as default.") EndFunc ;==>SetDefault Func SetPosition() $position_array = WinGetPos($script_version, "") $x_position = $position_array[0] $y_position = $position_array[1] RegWrite("HKLM\Software\Camera", "X_Position", "REG_SZ", $x_position) RegWrite("HKLM\Software\Camera", "Y_Position", "REG_SZ", $y_position) EndFunc ;==>SetPosition Func SetCamera() If $multi_enabled = False Then If Not FileExists($URL) Then MsgBox(262144, $script_version, "Unable to find " & $URL) Exit EndIf EndIf If $multi_enabled = True Then If GUICtrlRead($URL_combo) = "COMPANY1 - SITE2" Then $company = "COMPANY1" $city = "SITE2" EndIf If GUICtrlRead($URL_combo) = "COMPANY2 - SITE2" Then $company = "COMPANY2" $city = "SITE2" EndIf If GUICtrlRead($URL_combo) = "COMPANY1 - SITE1" Then $company = "COMPANY1" $city = "SITE1" EndIf If GUICtrlRead($URL_combo) = "COMPANY2 - SITE1" Then $company = "COMPANY2" $city = "SITE1" EndIf CreateHtml($company, $city) If Not FileExists($URL) Then MsgBox(262144, $script_version, "Unable to find " & $URL) Exit EndIf EndIf _IENavigate($IE, $URL, 0) EndFunc ;==>SetCamera Func CameraRefresh() _IEAction($IE, "refresh") EndFunc ;==>CameraRefresh Func Custom_COM_Error() MsgBox(262144, $script_version, $Custom_COM_Error.Description & @CRLF & _ "" & @CRLF & _ "Script Line: " & $Custom_COM_Error.ScriptLine) $COM_Error = 1 CameraRefresh() EndFunc ;==>Custom_COM_Error Func Xbutton() FileDelete($URL) SetPosition() Exit EndFunc ;==>Xbutton Edited June 7, 2010 by gcue Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 3, 2010 Share Posted June 3, 2010 Wouldn't you be better off with _IEErrorHandlerRegister() vice your own handler, if you suspect it's an IE issue? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
gcue Posted June 4, 2010 Author Share Posted June 4, 2010 i registered the IE error handler but no luck =/ the gui became unresponsive again today with no error. i think it happens when i switch around windows alot and quickly then when i try to select it in the end its unresponsive.. actually i can almost duplicate it everytime. Link to comment Share on other sites More sharing options...
DaleHohm Posted June 5, 2010 Share Posted June 5, 2010 (edited) If you can duplicate it then you should be able to pepper your code with debugging statements and narrow down there it is happening. Also take a look at SciTe debugging mode (see my sig) Dale Edited June 5, 2010 by DaleHohm Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
gcue Posted June 7, 2010 Author Share Posted June 7, 2010 (edited) debug didnt give me any extra info.. these are the last recorded events in the console before it became unresponsiveagain i can duplicate this by clicking around several windows quickly0103: 0-0: WEnd0102: 0-0: Sleep(100)0103: 0-0: WEnd0102: 0-0: Sleep(100)0103: 0-0: WEnd0102: 0-0: Sleep(100)0103: 0-0: WEnd0102: 0-0: Sleep(100)0103: 0-0: WEnd0102: 0-0: Sleep(100)0103: 0-0: WEnd0102: 0-0: Sleep(100)*sigh*any other ideas? Edited June 7, 2010 by gcue Link to comment Share on other sites More sharing options...
DaleHohm Posted June 7, 2010 Share Posted June 7, 2010 Sorry, there is no replacement for debugging and stripping your code down to create a small reproducer. You are lucky since you say you can get the trouble to occur at will. We cannot run your code, so there is little we can do for you. Suggest you start ripping out code and simplifying until you can no longer reproduce the trouble and then isolate root cause. Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 30, 2010 Share Posted June 30, 2010 Still no code/site/reproducer to look at, so: Psychic Hotline Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
gcue Posted June 30, 2010 Author Share Posted June 30, 2010 LOL - see first post =) Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 30, 2010 Share Posted June 30, 2010 That's your stripped down, minimalist reproducer with all irrelevant options and extraneous elements removed? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
gcue Posted July 1, 2010 Author Share Posted July 1, 2010 (edited) i have made some progress in determining what the issue is... i did not change anything in the code, rather instead of using a HTML file that has a webcam in it the script uses an HTML file with text only and i cannot make the script crash. is it because the website has an object, in this case a webcam is constantly refreshing? if anyone can please help id really appreciate this. here's the full script: thank you in advance!!! expandcollapse popup#NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=webcam.ico #AutoIt3Wrapper_Outfile=Camera.exe #AutoIt3Wrapper_Res_Fileversion=0.8.0.0 #AutoIt3Wrapper_Run_Tidy=y #AutoIt3Wrapper_Run_Debug_Mode=Y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> #include <array.au3> #include <ComboConstants.au3> #include <StaticConstants.au3> #include <Constants.au3> #include <Misc.au3> #include <ButtonConstants.au3> Opt("GUIOnEventMode", 1) Global $script_version = ("Camera v" & FileGetVersion(@ScriptName)) Global $tools_dir = "\\Server\Share\Application\" Global $log_dir = "\\Server\Share\Log\" Global $log_file = $log_dir & "log.txt" Global $multi_enabled, $URL, $users[4][3] Global $always_on_top, $default_camera, $switch_count = 0 Global $GUI, $IE, $URL_combo, $always_on_top_checkbox, $background, $set_default_btn Global $x_position, $y_position Global $Custom_COM_Error, $COM_Error = 0 _IEErrorHandlerRegister("Custom_COM_Error") ;~ CheckRequirements() BuildUserArray() AssignCamera() ReadSettings() $IE = _IECreateEmbedded() If $multi_enabled = False Then If $always_on_top = "True" Then $GUI = GUICreate($script_version, 325, 310, $x_position, $y_position, -1, $WS_EX_TOPMOST) Else $GUI = GUICreate($script_version, 325, 310, $x_position, $y_position) EndIf $refresh_btn = GUICtrlCreateButton("", 3, 3, 20, 21, $BS_ICON) GUICtrlSetOnEvent(-1, "CameraRefresh") GUICtrlSetImage(-1, "xpsp2res.dll", -54, 0) GUICtrlSetTip(-1, "Refresh current camera") GUICtrlCreateObj($IE, -13, 25, 370, 285) EndIf If $multi_enabled = True Then If $always_on_top = "True" Then $GUI = GUICreate($script_version, 325, 325, $x_position, $y_position, -1, $WS_EX_TOPMOST) Else $GUI = GUICreate($script_version, 325, 325, $x_position, $y_position) EndIf $refresh_btn = GUICtrlCreateButton("", 160, 10, 20, 21, $BS_ICON) GUICtrlSetOnEvent(-1, "CameraRefresh") GUICtrlSetImage(-1, "xpsp2res.dll", -54, 0) GUICtrlSetTip(-1, "Refresh current camera") GUICtrlCreateObj($IE, -13, 40, 370, 285) EndIf $always_on_top_checkbox = GUICtrlCreateCheckbox("Always on Top", 242, 5, 77, 12) GUICtrlSetOnEvent(-1, "SetTopMost") GUICtrlSetFont(-1, 7) GUICtrlSetTip(-1, "Set this window to be on top of all other windows") If $always_on_top = "True" Then GUICtrlSetState(-1, $GUI_CHECKED) EndIf If $multi_enabled = True Then $URL_combo = GUICtrlCreateCombo("", 3, 3, 95, 15, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, "COMPANY2 - SITE1|COMPANY1 - SITE1|COMPANY1 - SITE2|COMPANY2 - SITE2", $default_camera) GUICtrlSetOnEvent(-1, "SetCamera") $set_default_btn = GUICtrlCreateButton("Set As Default", 3, 25, 95, 15) GUICtrlSetOnEvent(-1, "SetDefault") GUICtrlSetFont(-1, 7) GUICtrlSetTip(-1, "Set current camera as default") EndIf SetCamera() GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) GUISetOnEvent($GUI_EVENT_CLOSE, "Xbutton") GUISetState() While 1 Sleep(100) WEnd Func CheckRequirements() Local $get_output = Run(@ComSpec & " /c java.exe -version", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Local $line While 1 $line = StderrRead($get_output) If @error Then ExitLoop If $line <> "" Then $first_line = StringStripWS(StringReplace($line, "java version", ""), 8) $java_version = StringTrimRight(StringReplace($first_line, '"', ""), 3) ExitLoop EndIf WEnd $version_compare = _VersionCompare("1.6.0", $java_version) If $version_compare = 1 Then MsgBox(262144, $script_version, "You need to update JAVA client.") Exit EndIf EndFunc ;==>CheckRequirements Func BuildUserArray() ;User ;Location ;Access $users[0][0] = "USER1" $users[0][1] = "SITE1" $users[0][2] = "BOTH_COMPANIES" $users[1][0] = "USER2" $users[1][1] = "SITE1" $users[1][2] = "COMPANY1" $users[2][0] = "USER3" $users[2][1] = "SITE2" $users[2][2] = "COMPANY1" $users[3][0] = "USER3" $users[3][1] = "SITE1" $users[3][2] = "COMPANY2" EndFunc ;==>BuildUserArray Func AssignCamera() $user_found = False $multi_enabled = False $class_B_subnet = StringLeft(@IPAddress1, 5) For $x = 0 To UBound($users) - 1 If @UserName = $users[$x][0] Then $user_found = True If $users[$x][1] = "SITE1" Then If $users[$x][2] = "COMPANY1" Then $company = "COMPANY1" If $class_B_subnet = "192.163" Then $city = "SITE1" Else $city = "SITE2" EndIf EndIf If $users[$x][2] = "COMPANY2" Then $company = "COMPANY2" If $class_B_subnet = "192.163" Then $city = "SITE1" Else $city = "SITE2" EndIf EndIf EndIf If $users[$x][1] = "SITE2" Then If $users[$x][2] = "COMPANY1" Then $company = "COMPANY1" If $class_B_subnet = "192.160" Then $city = "SITE2" Else $city = "SITE1" EndIf EndIf If $users[$x][2] = "COMPANY2" Then $company = "COMPANY2" If $class_B_subnet = "192.160" Then $city = "SITE2" Else $city = "SITE1" EndIf EndIf EndIf If $users[$x][2] = "BOTH_COMPANIES" Then $multi_enabled = True EndIf EndIf Next If $user_found = False Then MsgBox(262144, $script_version, "You do not have access to view any cameras.") Return EndIf If $multi_enabled = False Then CreateHtml($company, $city) EndIf EndFunc ;==>AssignCamera Func CreateHtml($company, $city) If $company = "COMPANY2" And $city = "SITE1" Then $ip = "http://192.160.22.201:80/" EndIf If $company = "COMPANY2" And $city = "SITE2" Then $ip = "http://192.163.8.230:80/" EndIf If $company = "COMPANY1" And $city = "SITE1" Then $ip = "http://192.160.10.200:80/" EndIf If $company = "COMPANY1" And $city = "SITE2" Then $ip = "http://192.163.56.220:80/" EndIf $URL = @TempDir & "\Camera.html" If FileExists($URL) Then FileDelete($URL) EndIf $text = '<html>' & @CRLF $text &= '<title>' & $company & '-' & $city & ' Camera</title>' & @CRLF $text &= '<style>' & @CRLF $text &= '<!--' & @CRLF $text &= ' /* Style Definitions */' & @CRLF $text &= ' p.MsoNormal, li.MsoNormal, div.MsoNormal' & @CRLF $text &= ' {mso-style-parent:"";' & @CRLF $text &= ' margin:0in;' & @CRLF $text &= ' margin-bottom:.0001pt;' & @CRLF $text &= ' mso-pagination:widow-orphan;' & @CRLF $text &= ' font-size:12.0pt;' & @CRLF $text &= ' font-family:"Times New Roman";' & @CRLF $text &= ' mso-fareast-font-family:"Times New Roman";}' & @CRLF $text &= 'p.style8, li.style8, div.style8' & @CRLF $text &= ' {mso-style-name:style8;' & @CRLF $text &= ' mso-margin-top-alt:auto;' & @CRLF $text &= ' margin-right:0in;' & @CRLF $text &= ' mso-margin-bottom-alt:auto;' & @CRLF $text &= ' margin-left:0in;' & @CRLF $text &= ' mso-pagination:widow-orphan;' & @CRLF $text &= ' font-size:12.0pt;' & @CRLF $text &= ' font-family:Arial;' & @CRLF $text &= ' mso-fareast-font-family:"Times New Roman";' & @CRLF $text &= ' color:whitesmoke;' & @CRLF $text &= ' font-weight:bold;}' & @CRLF $text &= 'span.style81' & @CRLF $text &= ' {mso-style-name:style81;' & @CRLF $text &= ' font-family:Arial;' & @CRLF $text &= ' mso-ascii-font-family:Arial;' & @CRLF $text &= ' mso-hansi-font-family:Arial;' & @CRLF $text &= ' mso-bidi-font-family:Arial;' & @CRLF $text &= ' color:whitesmoke;' & @CRLF $text &= ' font-weight:bold;}' & @CRLF $text &= '@page Section1' & @CRLF $text &= ' {size:8.5in 11.0in;' & @CRLF $text &= ' margin:1.0in 1.25in 1.0in 1.25in;' & @CRLF $text &= ' mso-header-margin:.5in;' & @CRLF $text &= ' mso-footer-margin:.5in;' & @CRLF $text &= ' mso-paper-source:0;}' & @CRLF $text &= 'div.Section1' & @CRLF $text &= ' {page:Section1;}' & @CRLF $text &= '-->' & @CRLF $text &= '</style>' & @CRLF $text &= '</head>' & @CRLF $text &= '' & @CRLF $text &= '<body bgcolor="#E8E8E8" lang=EN-US style="tab-interval:.5in">' & @CRLF $text &= '' & @CRLF $text &= '<div class=Section1>' & @CRLF $text &= '<div align=center>' & @CRLF $text &= '<table class=MsoNormalTable border=0 cellpadding=0 width=365 style="width:3.3in;' & @CRLF $text &= ' mso-cellspacing:1.5pt;mso-padding-alt:0in 5.4pt 0in 5.4pt">' & @CRLF $text &= ' <tr style="mso-yfti-irow:0;mso-yfti-firstrow:yes">' & @CRLF $text &= ' <td style="background:#006699;padding:.75pt .75pt .75pt .75pt">' & @CRLF $text &= ' <p class=MsoNormal align=center style="margin-right:7.4pt;text-align:center"><span' & @CRLF $text &= ' class=style81>' & $company & '-' & $city & ' Trading</span></p>' & @CRLF $text &= ' </td>' & @CRLF $text &= ' </tr>' & @CRLF $text &= ' <tr style="mso-yfti-irow:1">' & @CRLF $text &= ' <td style="padding:.75pt .75pt .75pt .75pt">' & @CRLF $text &= ' <p class=MsoNormal><span style="font-size:10.0pt">' & @CRLF $text &= ' <applet codebase="' & $ip & '-wvdoc-01-/LiveApplet/" height="240" archive="LiveApplet.zip" width="320" code="LiveApplet.class" VIEWASTEXT>' & @CRLF $text &= ' <param name="url" value="' & $ip & '" />' & @CRLF $text &= ' <param name="cabbase" value="LiveApplet.cab" />' & @CRLF $text &= ' <param name="capture_size" value="320x240" />' & @CRLF $text &= ' <param name="video_width" value="340" />' & @CRLF $text &= ' <param name="bg_color" value="#ececec" />' & @CRLF $text &= ' <param name="controller_style" value="no_pantilt" />' & @CRLF $text &= ' </applet>' & @CRLF $text &= ' </span></p>' & @CRLF $text &= ' </td>' & @CRLF $text &= ' </tr>' & @CRLF $text &= '</table>' & @CRLF $text &= '</div>' & @CRLF $text &= '</div>' & @CRLF $text &= '</body>' & @CRLF $text &= '</html>' & @CRLF FileWrite($URL, $text) EndFunc ;==>CreateHtml Func ReadSettings() $always_on_top = RegRead("HKLM\Software\Camera", "TopMost") $default_camera = RegRead("HKLM\Software\Camera", "Default") If $default_camera = "" Then $default_camera = "COMPANY2 - SITE2" EndIf $x_position = RegRead("HKLM\Software\Camera", "X_Position") If $x_position = "" Then $x_position = "0" EndIf $y_position = RegRead("HKLM\Software\Camera", "Y_Position") If $y_position = "" Then $y_position = "0" EndIf EndFunc ;==>ReadSettings Func SetTopMost() If BitAND(GUICtrlRead($always_on_top_checkbox), $GUI_CHECKED) Then $topmost = True WinSetOnTop($script_version, "", 1) EndIf If BitAND(GUICtrlRead($always_on_top_checkbox), $GUI_UNCHECKED) Then $topmost = False WinSetOnTop($script_version, "", 0) EndIf RegWrite("HKLM\Software\Camera", "TopMost", "REG_SZ", $topmost) EndFunc ;==>SetTopMost Func SetDefault() $default = GUICtrlRead($URL_combo) RegWrite("HKLM\Software\Camera", "Default", "REG_SZ", $default) MsgBox(262144, $script_version, $default & " has been set as default.") EndFunc ;==>SetDefault Func SetPosition() $position_array = WinGetPos($script_version, "") $x_position = $position_array[0] $y_position = $position_array[1] RegWrite("HKLM\Software\Camera", "X_Position", "REG_SZ", $x_position) RegWrite("HKLM\Software\Camera", "Y_Position", "REG_SZ", $y_position) EndFunc ;==>SetPosition Func SetCamera() If $multi_enabled = False Then If Not FileExists($URL) Then MsgBox(262144, $script_version, "Unable to find " & $URL) Exit EndIf EndIf If $multi_enabled = True Then If GUICtrlRead($URL_combo) = "COMPANY1 - SITE2" Then $company = "COMPANY1" $city = "SITE2" EndIf If GUICtrlRead($URL_combo) = "COMPANY2 - SITE2" Then $company = "COMPANY2" $city = "SITE2" EndIf If GUICtrlRead($URL_combo) = "COMPANY1 - SITE1" Then $company = "COMPANY1" $city = "SITE1" EndIf If GUICtrlRead($URL_combo) = "COMPANY2 - SITE1" Then $company = "COMPANY2" $city = "SITE1" EndIf CreateHtml($company, $city) If Not FileExists($URL) Then MsgBox(262144, $script_version, "Unable to find " & $URL) Exit EndIf EndIf _IENavigate($IE, $URL, 0) EndFunc ;==>SetCamera Func CameraRefresh() _IEAction($IE, "refresh") EndFunc ;==>CameraRefresh Func Custom_COM_Error() $HexNumber = Hex($Custom_COM_Error.number, 8) MsgBox(0, "", "We intercepted a COM Error !" & @CRLF & _ "Number is: " & $HexNumber & @CRLF & _ "Windescription is: " & $Custom_COM_Error.windescription & @CRLF & _ "Source is: " & $Custom_COM_Error.source & @CRLF & _ "Description is: " & $Custom_COM_Error.description & @CRLF & _ "Help file is: " & $Custom_COM_Error.helpfile & @CRLF & _ "Help context is: " & $Custom_COM_Error.helpcontext & @CRLF & _ "Last DLL error: " & $Custom_COM_Error.lastdllerror & @CRLF & _ "Script line: " & $Custom_COM_Error.scriptline) $COM_Error = 1 CameraRefresh() EndFunc ;==>Custom_COM_Error Func Xbutton() FileDelete($URL) SetPosition() Exit EndFunc ;==>Xbutton Edited July 1, 2010 by gcue Link to comment Share on other sites More sharing options...
DaleHohm Posted July 1, 2010 Share Posted July 1, 2010 This makes no sense to me:instead of using a HTML file that has a webcam in it the script uses an HTML file with text only and i cannot make the script crash.Please see my sig for the definition of a reproducer. You will cheat yourself of the knowledge the troubleshooting process can give you if you try to avoid creating one. I'll be surprised if you don't solve your own problem as part of the exercise and even if you don't you will be able to compose succinct questions that you stand a chance of getting answered.Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
gcue Posted July 30, 2010 Author Share Posted July 30, 2010 (edited) interestinly enough, i found that my GUI crashes ONLY when i click another program and then my GUI - freezes everytime and only with that other program. the other program is written in C# is there any kind of property that would conflict with C#? Edited July 30, 2010 by gcue Link to comment Share on other sites More sharing options...
gcue Posted August 2, 2010 Author Share Posted August 2, 2010 bump Link to comment Share on other sites More sharing options...
Bert Posted August 2, 2010 Share Posted August 2, 2010 What happens when you simply change to the desktop and return to the app? In other words what happens when your program loses focus then regains it? The Vollatran project  My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
gcue Posted August 2, 2010 Author Share Posted August 2, 2010 (edited) ooooo i hadnt noticed that!!!! you're right!! it crashes too.. if i just click the desktop then click my gui, it freezes.. howd u know??? has this happened to you?? Edited August 2, 2010 by gcue Link to comment Share on other sites More sharing options...
gcue Posted August 3, 2010 Author Share Posted August 3, 2010 ok ive combined those 2 if statements. the trap you were talking about... not sure what you meant... this is what i put into the while loop. unable to trap anything... =/ While 1 If @error Then MsgBox(0, @ScriptLineNumber, @error) CameraRefresh() EndIf Sleep(10) WEnd Link to comment Share on other sites More sharing options...
Bert Posted August 3, 2010 Share Posted August 3, 2010 You have a loop that runs, but you have no method to reset when you regain focus nor to trap what you have running into an idle loop when you lose focus. Also I noticed you have 2 if statements that start the same. I could not see why you did this twice. If $multi_enabled = True Then You should figure out a way to combine the 2 IF statements into one function. The Vollatran project  My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
gcue Posted August 4, 2010 Author Share Posted August 4, 2010 i re-read your message and tried this (couldn't figure it out): $dGUI_handle = WinGetHandle($script_version) $dGUI_classname = _WinAPI_GetClassName($dGUI_handle) While 1 $win = _WinAPI_GetFocus() If _WinAPI_GetClassName($win) = $dGUI_classname Then MsgBox(0,"","Selected") EndIf Sleep(10) WEnd BUT i tried this and it's working great!!!! $IEGUI = GUICtrlCreateObj($IE, -13, 40, 370, 285) GUICtrlSetState(-1, $gui_disable) i can sleep peacefully tonight. 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