Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Code works on one machine - stops responding after few minutes on another

$
0
0
I have quite simple code which does few things. I know it can be made much better but I'm complete newbie, I'm not coding in any language - just used help file and google to find what I was looking for.
 
I'll explain quickly what it does:
- checks IP
- Starts VPN client and connects it to one of 20 locations (pics name randomly)
- checks if IP has changed (when VPN connects IP will change) and when it does
- clicks a button to run scraper
- runs for 80sec
- clicks a button to stop scraper
- disconnects
- kills VPN client
- and starts VPN client again and loops through that.
 
Everything was fine, I've managed to make it to work. Tested - it's running for over 24h on one machine so I was happy to copy the whole thing to other machines. It runs for few minutes (will loop through the whole process few times) and then it stops responding.
 
That is what windows have to say:
The program AutoIt3.exe version 3.3.8.1 stopped interacting with Windows and was closed. To see if more information about the problem is available, check the problem history in the Action Center control panel.
 Process ID: c18
 Start Time: 01ce6e82f8ea0e36
 Termination Time: 15
 Application Path: C:\Program Files (x86)\AutoIt3\AutoIt3.exe
 Report Id: 78fd5993-da77-11e2-aa9b-4c72b921bbb1

And here's the code:

AutoIt         
#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Compile_Both=y #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <array.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Inet.au3> Global $PublicIP = _GetIP() Global $WatchTime = 1 * 1000 ;Check every 1 seconds Global $TimeStamp = TimerInit() Global $CB_SETCURSEL = 0x14E Global $start = "dupa" $hGUI = GUICreate("Test", 300, 300) $hButton = GUICtrlCreateButton("Read", 10, 10, 80, 30) $hButton2 = GUICtrlCreateButton("Connect", 10, 50, 80, 30) $hButton3 = GUICtrlCreateButton("Disconnect", 100, 50, 80, 30) $hButton4 = GUICtrlCreateButton("Start Hrefer", 10, 100, 80, 30) $hButton5 = GUICtrlCreateButton("Stop Hrefer", 100, 100, 80, 30) $hButton6 = GUICtrlCreateButton("Statuscheck", 10, 150, 80, 30) $label = GUICtrlCreateLabel("Viscosity status: n/a", 100, 10, 200) $label2 = GUICtrlCreateLabel("Hrefer status: n/a", 100, 25, 200) $runStatus = "dupa" GUISetState() $x = 1 While 1 If TimerDiff($TimeStamp) >= $WatchTime Then Global $PublicIPcheck = _GetIP() If $PublicIP <> $PublicIPcheck Then ControlClick("[CLASS:TFormMain]", "", "TTeButton3") GUICtrlSetData($label, "Viscosity status: Connected") GUICtrlSetData($label2, "Hrefer status: Enabled") If $start == "dupa" Then $start = TimerInit() Else If TimerDiff($start) > 80000 Then Run("C:\Program Files\Viscosity\Viscosity.exe disconnect " & $x, "", @SW_MAXIMIZE) ControlClick("[CLASS:TFormMain]", "", "TTeButton2") Sleep(1000) ProcessClose("Viscosity.exe") $start = "dupa" $runStatus = "dupa" Sleep(20) $PublicIPcheck = $PublicIP _Taskbar_Refresh() EndIf EndIf Else GUICtrlSetData($label, "Viscosity status: Disconnected") ControlClick("[CLASS:TFormMain]", "", "TTeButton2") Sleep(100) If $runStatus == "dupa" Then Global $x = Random(1, 20, 1) Sleep(100) Run("C:\Program Files\Viscosity\Viscosity.exe connect " & $x, "", @SW_MAXIMIZE) $runStatus = "cipa" EndIf EndIf HreferStyle() $TimeStamp = TimerInit() EndIf Sleep(20) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton $w = ControlCommand("frmStats", "", "comboBox1", "SelectString", '2') ConsoleWrite($w) Case $hButton2 Run("C:\Program Files\Viscosity\Viscosity.exe connect 4", "", @SW_MAXIMIZE) Case $hButton3 Run("C:\Program Files\Viscosity\Viscosity.exe disconnect 4", "", @SW_MAXIMIZE) Sleep(3000) ProcessClose("Viscosity.exe") Case $hButton4 ControlClick("[CLASS:TFormMain]", "", "TTeButton3") Case $hButton5 ControlClick("[CLASS:TFormMain]", "", "TTeButton2") Case $hButton6 $iStyle = _GetWindowStyle(ControlGetHandle("[CLASS:TFormMain]", "", "TTeButton2")) If BitAND($iStyle, $WS_DISABLED) Then MsgBox(64, "Test Button is...", "Disabled") Else MsgBox(64, "Test Button is...", "Enabled") EndIf EndSwitch WEnd Func _Taskbar_Refresh() ; By rasim >> http://www.autoitscript.com/forum/topic/66629-systemtray-refresh/. Local $aMouseGetPos, $hHandle, $hParent, $hTaskBar, $tLeft, $tRight, $tTop, $tWinRect $hTaskBar = _WinAPI_FindWindow("Shell_TrayWnd", "") $hParent = ControlGetHandle($hTaskBar, "", "TrayNotifyWnd1") $hHandle = ControlGetHandle($hParent, "", "ToolbarWindow321") $tWinRect = _WinAPI_GetWindowRect($hHandle) $aMouseGetPos = MouseGetPos() $tLeft = DllStructGetData($tWinRect, "Left") $tRight = DllStructGetData($tWinRect, "Right") $tTop = DllStructGetData($tWinRect, "Top") For $A = $tLeft To $tRight MouseMove($A, $tTop, 0) Next MouseMove($aMouseGetPos[0], $aMouseGetPos[1], 0) EndFunc ;==>_Taskbar_Refresh Func HreferStyle() $iStyle = _GetWindowStyle(ControlGetHandle("[CLASS:TFormMain]", "", "TTeButton2")) If BitAND($iStyle, $WS_DISABLED) Then GUICtrlSetData($label2, "Hrefer status: Disabled") Else GUICtrlSetData($label2, "Hrefer status: Enabled") EndIf EndFunc ;==>HreferStyle Func _GetWindowStyle($hWnd) Local $a_iCall = DllCall("user32.dll", "int", "GetWindowLong", _ "hwnd", $hWnd, _ "int", -16) ; GWL_STYLE If @error Or Not $a_iCall[0] Then Return SetError(1, 0, 0) EndIf Return SetError(0, 0, $a_iCall[0]) EndFunc ;==>_GetWindowStyle

Any ideas what could be causing that? All machines run on the same system, have the same stuff installed etc.

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>