
kjcdude
Active Members-
Posts
137 -
Joined
-
Last visited
Everything posted by kjcdude
-
I'm using _accessQueryLike() on a script that pulls from a database containing over a million financial transaction entries. I use the querylike to search for the current date's revenue and then it outputs it and is graphed in real time. One major issue I've been running into is the amount of time it takes for querylike to search through all those entries. It's currently taking about 5-6 seconds. It's fine that it's taking that long, but I have about 5 autoit scripts constantly pulling data every 30 seconds as well as the core server program writing data constantly. Is there anyway to tell querylike what line to start searching from? My goal would be to record where the querylike found the data last time and start searching from that point on next run. Thanks
-
I've ran into the limit for the character limit transfered in the parameter field of ShellExecuteWait. Autoit pops the error "Windows cannot access the specified device, path, or file. You may not have the appropriate permissions to access this item" with the exe trying to launch as the title. Does anyone know the exact character limit? Thanks
-
Time Difference Between Date/Time
kjcdude replied to kjcdude's topic in AutoIt General Help and Support
From the suggestions above here's what I cam up with. Here's what I cam up with. I'm going to use _NowCalc() instead of the date variables for the start and end time. To calculate the time I'm going to use _DateDiff(s, $, $) then take that return and use _TicksToTime($ * 1000, $, $, $) to get a clean hour, min, sec return. Thanks for the all the help. -
I'm working on writing a function that can take in the difference between two full date/time strings and convert it back to date time. I imagine someone has written something like, if not I'll create my own. $start = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & @MSEC sleep(1000) $end = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & @MSEC $time = $end - $start I need to take the $time variable and output a clean difference output such as 00:00:01 Example times: Start: 20100416140654796 End: 20100416232951176 "Ticks": 92296380 Thanks
-
WindowFromPoint was exactly what I was looking for, worked perfectly. Little example of how I used it. #include <WinAPI.au3> Global $Struct = DllStructCreate($tagPoint) DllStructSetData($Struct, "x", 805) DllStructSetData($Struct, "y", 234) $mhwnd = _WinAPI_WindowFromPoint($Struct) while 1 Pos() $hwnd = _WinAPI_WindowFromPoint($Struct) if $mhwnd <> $hwnd Then MsgBox(0, "", "on top") EndIf ToolTip($hwnd & @CRLF & MouseGetPos(0) & " X " & MouseGetPos(1)) WEnd Func Pos() DllStructSetData($Struct, "x", MouseGetPos(0)) DllStructSetData($Struct, "y", MouseGetPos(1)) EndFunc ;==>Pos
-
I'm looking for a function that can detect when a window is visible by the human eye. I know that WinGetState() will return if it exists, is "visible", enabled, and active. But that doesn't tell me if the window is covered or if it's visible by the human eye. From the tests I've run it will only return 7 even if the window is covered by another application, even a full screen application. The good thing is the window I'm monitoring is inside a script, so if I need to use a gui function that won't be a problem. Thanks for the help.
-
Thanks to whoever created this. Very useful code to see when a guictrl is clicked on.
-
I'm having a very weird issue getting data to stream from a console window into stdoutread. Here's the source code working without stdoutread so you can see what my goal is. I can't figure out any possible way to enter the prompts via rsync variables. Take a look at the two attached images for the prompts that come up. $v = "-r -v --progress admin@10.10.10.37:" & "'" & '"/share/Public/public/Games & Patches/Aion/"' & "'" & " /cygdrive/c/test/" ShellExecute("rsync.exe", $v, "C:\Program Files\cwRsync\bin", "open", @SW_HIDE) WinWait("C:\Program Files\cwRsync\bin\rsync.exe", "") $wa = WinWait("C:\Program Files\cwRsync\bin\rsync.exe", "") Sleep(1000) WinActivate($wa) WinWaitActive($wa) send("yes" & "{ENTER}") sleep(2000) WinActivate($wa) WinWaitActive($wa) send("admin" & "{ENTER}") while 1 Sleep(1000) Select Case ProcessExists("rsync.exe") = 0 MsgBox(0, "", "Process Closed") ExitLoop Case WinExists($wa) = 0 MsgBox(0, "", "Window Closed") ExitLoop EndSelect WEnd Here's the stdoutread code that i'm trying to use, but nothing streams to stdoutread. #include <Constants.au3> $v = "-r -v --progress admin@10.10.10.37:" & "'" & '"/share/Public/public/Games & Patches/Aion/"' & "'" & " /cygdrive/c/test/" $p = Run("C:\Program Files\cwRsync\bin\rsync.exe " & $v, "", @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD) while 1 $line = StdoutRead($p) MsgBox(0, "", $line) if ProcessExists($p) = 0 Then Exit WEnd
-
I ran it live on 5 servers on Tuesday night and ran into no issues. Each server was handling about 160 clients with no issue. Thanks for the fix!
-
Initial tests looks great, no failures so far. Running with 200 concurrent connections, everything is reporting correctly. I'm going to run my full version of the program on 5 servers next week. I'll report back with some more real world results. Thanks for the fix!
-
Just saw this post. I'll test and report back with results.
-
The reason for the extra if statement was to confirm twice for debugging out to the msgbox. The actual code is this: while 1 local $ct = WinGetTitle("Steam - Updating -", "") sleep(30000) Select Case WinGetTitle("Steam - Updating -", "") = $ct ProcessClose("steam.exe") FileDelete("C:\Program Files\Steam\ClientRegistry.blob") FileDelete("C:\Program Files\Steam\AppUpdateStats.blob") ShellExecuteWait("SteamService.exe", "/repair", "C:\Program Files\Steam\bin") run($gsteamlauncher) ExitLoop Case WinExists("Steam - Updating -", "") = 0 ExitLoop EndSelect WEnd I'll definitely try your suggestion, it looks to be a lot cleaner and more efficient than mine.
-
winactivate("", "") winwaitactive("", "") send({MouseUp})
-
I'm running into a very strange issue. It looks like a bug, but I'm not entirely sure. Here's the code with the error. while 1 local $ct = WinGetTitle("Steam - Updating -", "") sleep(30000) SplashTextOn("", "$CT = " & $ct & @CRLF & "Wingettitle = " & WinGetTitle("Steam - Updating -", ""), 300, 100, -1, -1, 16, "Veranda", 9) Select Case WinGetTitle("Steam - Updating -", "") = $ct if WinGetTitle("Steam - Updating -", "") = $ct Then MsgBox(0, "TRUE", "$CT = " & $ct & @CRLF & "Wingettitle = " & WinGetTitle("Steam - Updating -", "")) Else MsgBox(0, "FALSE", "$CT = " & $ct & @CRLF & "Wingettitle = " & WinGetTitle("Steam - Updating -", "")) EndIf ProcessClose("steam.exe") FileDelete("C:\Program Files\Steam\ClientRegistry.blob") FileDelete("C:\Program Files\Steam\AppUpdateStats.blob") ShellExecuteWait("SteamService.exe", "/repair", "C:\Program Files\Steam\bin") run($gsteamlauncher) ExitLoop Case WinExists("Steam - Updating -", "") = 0 ExitLoop EndSelect WEnd What will occur is it will provide a false positive. If the window is no longer open it will output 0 like it should, but case and the if statements return a TRUE result meaning "Steam - Updating - 81%" = "0" which it obviously doesn't. When there is an active title it will react correctly and provide a false statement as it should. As a temporary fix I changed the Case line to. Case WinGetTitle("Steam - Updating -", "") = $ct and WinGetTitle("Steam - Updating -", "") <> 0 See the attached screenshot for an example of the error.
-
I've been really busy and only recently have had the time to come back around to this problem. It still fails running 3.3.1.4 I went ahead and had TCP.au3 generate a log of everything happening inside _TCP_Server_ClientList(). Here's the updated code with the log being written. Func _TCP_Server_ClientList() Local $aReturn[1], $i For $i = 1 to UBound($__TCP_SOCKETS)-1 FileWriteLine($fhandle, "$i = " & $i) FileWriteLine($fhandle, "UBound = " & UBound($__TCP_SOCKETS)-1) FileWriteLine($fhandle, "__TCP_SOSCKETS = " & $__TCP_SOCKETS[$i][0]) If $__TCP_SOCKETS[$i][0] Then ReDim $aReturn[UBound($aReturn)+1] $aReturn[UBound($aReturn)-1] = $__TCP_SOCKETS[$i][0] EndIf Next $aReturn[0] = UBound($aReturn)-1 Return $aReturn EndFunc Here's the last 50 lines of the log file. There were around 150 connections before it failed. Here's the last lines of another log. It looks like the issue is with the $i and UBound
-
After upgrading to 3.3.1.3 the script crashes for me when running "_SoundSetMasterVolume("100")" No errors are outputted, the scripts just crashes.
-
Ran into a problem after I upgraded to 3.3.1.3. Get the following error. C:\Program Files\AutoIt3\Beta\Include\WinAPIEx.au3(5633,53) : WARNING: $tagTEXTMETRIC: possibly used before declaration. Local $tTEXTMETRIC = DllStructCreate($tagTEXTMETRIC) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
-
I received the following two errors after I upgraded to 3.3.1.3 C:\Program Files\AutoIt3\Beta\Include\WinAPIEx.au3(2380,53) : WARNING: $tagTEXTMETRIC: possibly used before declaration. Local $tTEXTMETRIC = DllStructCreate($tagTEXTMETRIC) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Program Files\AutoIt3\Beta\Include\WinAPIEx.au3(2380,53) : ERROR: $tagTEXTMETRIC: undeclared global variable. Local $tTEXTMETRIC = DllStructCreate($tagTEXTMETRIC) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ Didn't cause any issues with my script, but I figured I would go ahead and report it.
-
The error still exists in the stable version. I'm running using the same code as above. It failed when around 115 connections were made. >Running:(3.3.0.0):C:\Program Files\AutoIt3\autoit3.exe "X:\Scripts\Update System\Monitor\Server - Updater.au3" C:\Program Files\AutoIt3\Include\TCP.au3 (386) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: If $__TCP_SOCKETS[$i][0] Then If ^ ERROR
-
I'll try running both with the latest stable instead of the beta.
-
Below is the code and compiled versions of the server/client. For the client, run it with the ip of the server as the command line parameter. The compiled versions below have been tested and confirmed that it still fails. Server Compiled - http://howies.com/tmp/scripts/Server_-_Updater.exe #include <TCP.au3> #include <Array.au3> #include <Date.au3> $inifile = @DesktopDir & "\Active.ini" $inifiledata = @DesktopDir & "\Average.ini" $mc = 25 ;total active clients Global $Secs2, $Mins2, $Hour2 ToolTip("SERVER: Creating server...",@DesktopWidth - 145, 30) $hServer = _TCP_Server_Create(88); A server. Tadaa! _TCP_RegisterEvent($hServer, $TCP_NEWCLIENT, "NewClient"); Whooooo! Now, this function (NewClient) get's called when a new client connects to the server. _TCP_RegisterEvent($hServer, $TCP_DISCONNECT, "Disconnect"); And this,... this will get called when a client disconnects. _TCP_RegisterEvent($hServer, $TCP_RECEIVE, "Received"); Function "Received" will get called when something is received While 1 $activetotal = IniRead($inifile, "Active Connections", "Total Active", "0") $active = IniReadSection($inifile, "Connections") local $clist = _TCP_Server_ClientList() Select Case $activetotal <= $mc if @error or $active = 1 then sleep(75) else for $b = 1 to $active[0][0] $activetotaltmp = IniRead($inifile, "Active Connections", "Total Active", "0") if $active[$b][1] = "Not" and $activetotaltmp <= $mc Then _TCP_Send($active[$b][0], "Activate") IniWrite($inifile, "Connections", $active[$b][0], "Active") IniWrite($inifile, "Active Connections", "Total Active", $activetotaltmp + 1) EndIf Next EndIf EndSelect if @error or $active = 1 Then sleep(75) Else for $a = 1 to $active[0][0] _ArraySearch($clist, $active[$a][0]) if @error Then IniDelete($inifile, "Connections", $active[$a][0]) Else ;~ MsgBox(0, "", $active[$a][0] & " " & $clist[0]) EndIf Next EndIf $tactivea = _ArrayFindAll($active, "Active", 0, 0, 0, 0, 1) $tactiveam = _ArrayMax($tactivea) IniWrite($inifile, "Active Connections", "Total Active", $tactiveam) sleep(65) WEnd Func NewClient($hSocket, $iError); Yo, check this out! It's a $iError parameter! (In case you didn't noticed: It's in every function) _TCP_Send($hSocket, "Established Connection"); Sending: "Bleh!" to the new client. local $clist = _TCP_Server_ClientList() ToolTip("SERVER:" & @CRLF & "Total Clients - " & $clist[0] & @CRLF & "Active Clients - " & $activetotal, @DesktopWidth - 145, 30) IniWrite($inifile, "Connections", $hSocket, "Not") EndFunc Func Disconnect($hSocket, $iError); Damn, we lost a client. Time of death: @Hour & @Min & @Sec :P local $clist = _TCP_Server_ClientList() ToolTip("SERVER:" & @CRLF & "Total Clients - " & $clist[0] & @CRLF & "Active Clients - " & $activetotal, @DesktopWidth - 145, 30); Placing a tooltip right under the tooltips of the client. ;if client disconnects then iniwrite them off the list IniDelete($inifile, "Connections", $hSocket) EndFunc Func Received($hSocket, $sReceived, $iError); And we also registered this! Our homemade do-it-yourself function gets called when something is received. if $sReceived = "Not Active" Then local $clist = _TCP_Server_ClientList() ToolTip("SERVER:" & @CRLF & "Total Clients - " & $clist[0] & @CRLF & "Active Clients - " & $activetotal, @DesktopWidth - 145, 30) $cactive = $hSocket if StringIsDigit($cactive) = 0 Then $c1 = StringSplit($cactive, "x") $convertedd = Dec($c1[2]) IniWrite($inifile, "Connections", $convertedd, "Not") Else IniWrite($inifile, "Connections", $hSocket, "Not") EndIf Else local $dtclients = IniRead($inifiledata, "Total Clients", "Total Clients", "0")+1 local $upavg = IniRead($inifiledata, "Average MB Sec Up", "Average", "0") local $davg = IniRead($inifiledata, "Average MB Sec Down", "Average", "0") local $tticks = IniRead($inifiledata, "Average Time", "Ticks", "0") local $rcvddata = StringSplit($sReceived, ",") IniWrite($inifiledata, "Average MB Sec Up", "Average", round(((($upavg*($dtclients-1))+$rcvddata[2])/$dtclients), 3)) IniWrite($inifiledata, "Average MB Sec Down", "Average", round(((($davg*($dtclients-1))+$rcvddata[3])/$dtclients), 3)) local $avgticks = round((($tticks*($dtclients-1))+$rcvddata[4])/$dtclients, 3) IniWrite($inifiledata, "Average Time", "Ticks", $avgticks) _TicksToTime($avgticks, $Hour2, $Mins2, $Secs2) local $Timef = StringFormat("%02i:%02i:%02i", $Hour2, $Mins2, $Secs2) IniWrite($inifiledata, "Average Time", "Converted", $Timef) IniWrite($inifiledata, "Total Clients", "Total Clients", $dtclients) ;~ _TCP_Server_Send("Processed") EndIf EndFunc Client Compiled - http://howies.com/tmp/scripts/Client_-_Updater.exe #include <Date.au3> #include <TCP.au3> ;~ #include "\\storageownz\IT Folder\Scripts\Update System\Updates\Automated Installs\au3\Store and PC Defs.au3" #include <String.au3> #include <WindowsConstants.au3> ToolTip("CLIENT: Connecting...",10,10) ;~ if $storename = "001" Then ;~ global $sip = "10.10.10.203" ;~ ElseIf $storename = "002" Then ;~ global $sip = "10.10.10.7" ;~ ElseIf $storename = "003" Then ;~ global $sip = "10.10.10.5" ;~ ElseIf $storename = "004" Then ;~ global $sip = "10.10.10.5" ;~ ElseIf $storename = "005" Then ;~ global $sip = "10.10.10.5" ;~ EndIf $sip = $CmdLine[1] $h1 = @DesktopHeight $w1 = @DesktopWidth $vfpre = "\\Nas01\Volume_1\Update System\" $vfexe = "Version Fixer.exe" $vfscript = $vfpre & $vfexe ;~ $tmpini = @DesktopDir & "\tmpdatafile.ini" ;~ FileDelete($tmpini) #include "\\storageownz\IT Folder\Scripts\Update System\Updates\Automated Installs\au3\Includes\NetStats.au3" $tmptimer = TimerInit() $hClient = _TCP_Client_Create($sip, 88); Create the client. Which will connect to the local ip address on port 88 _TCP_RegisterEvent($hClient, $TCP_RECEIVE, "Received"); Function "Received" will get called when something is received _TCP_RegisterEvent($hClient, $TCP_CONNECT, "Connected"); And func "Connected" will get called when the client is connected. _TCP_RegisterEvent($hClient, $TCP_DISCONNECT, "Disconnected"); And "Disconnected" will get called when the server disconnects us, or when the connection is lost. While 1 $tmptimero = TimerDiff($tmptimer)/1000 ;~ $activeq = IniRead($tmpini, "Version Fixer Started", "Activated", "0") Select Case $tmptimero >= 100; and $activeq = 0 _TCP_Send($fSocket, "Not Active") GUICtrlSetData($al1, "Not Active") $tmptimer = TimerInit() Exit ;~ MsgBox(0, "", "Sent") ;~ Case IniRead($tmpini, "Client Data", "Processed", "0") = 0 and $activeq = 1 ;~ _TCP_Client_Send($rawdata) EndSelect sleep(75) WEnd Func Connected($hSocket, $iError); We registered this (you see?), When we're connected (or not) this function will be called. ;~ MsgBox(0, "", $hSocket) Global $fSocket = $hSocket If not $iError Then; If there is no error... ToolTip("CLIENT: Connected!",10,10); ... we're connected. Else; ,else... ToolTip("CLIENT: Could not connect. Are you sure the server is running?",10,10); ... we aren't. EndIf EndFunc Func Received($hSocket, $sReceived, $iError); And we also registered this! Our homemade do-it-yourself function gets called when something is received. ToolTip("CLIENT: We received this: "& $sReceived, 10,10); (and we'll display it) #comments-start if $sReceived = "Activate" Then ;~ IniWrite($tmpini, "Version Fixer Started", "Activated", "1") $begin = TimerInit() $stim = TimerInit() Global $Secs1, $Mins1, $Hour1 ProgressOn("Timer", "Starting", "0%", $w1-306, "0") GUICtrlSetData($al1, "Version Fixer Started") Run($vfscript) sleep(5000) GUICtrlSetData($al1, "Waiting for Verification") while 1 sleep(500) Select Case ProcessExists($vfexe) = 0 Run($vfscript) Case ProcessExists($vfexe) <> 0 GUICtrlSetData($al1, "Version Fixer Running") GUICtrlSetData($al1, "Waiting for VC to Close") ProcessWait("Version Checker.exe") ProcessWaitClose("Version Checker.exe") GUICtrlSetData($al1, "Version Fixer Running") ExitLoop EndSelect WEnd ;if timeout occurs then detect and launch again $totaltimep = 9000 ;in seconds - 9000=2.5 hours - 7200=2 hours - 10800=3 hours - 21600=6 hours - 25200=7 hours While 1 $timerm = TimerDiff($begin) $difm = $timerm/1000 if $difm >= $totaltimep Then RunWait("\\nas01\Volume_1\Scripts\force restart.exe") GUICtrlSetData($al1, "Forced Restart") sleep(100) ProgressOff() ExitLoop EndIf $prcts = Round(($difm/$totaltimep) * 100, 2) _TicksToTime($timerm, $Hour1, $Mins1, $Secs1) $Timef = StringFormat("%02i:%02i:%02i", $Hour1, $Mins1, $Secs1) ProgressSet($prcts, $prcts & "%", "Total Time - " & $Timef) _netstat($UpStr,$DownStr) GUICtrlSetData($Download, _StringAddThousandsSep($DownStr) & " MB") GUICtrlSetData($Upload, _StringAddThousandsSep($UpStr) & " MB") $TodayUp = Round(($UpStr - $Tup)/$difm, 3) $TodayDown = Round(($DownStr - $Tdwn)/$difm, 3) GUICtrlSetData($Up, _StringAddThousandsSep($TodayUp) & " MB") GUICtrlSetData($Down, _StringAddThousandsSep($TodayDown) & " MB") if ProcessExists("Version Checker.exe") Then Global $rawdata = @ComputerName & "," & $TodayUp & "," & $TodayDown & "," & $timerm _TCP_Send($hSocket, $rawdata) GUICtrlSetData($al1, "Version Fixer Completed") sleep(30000) ExitLoop EndIf sleep(500) WEnd ;~ ElseIf $sReceived = "Processed" then ;~ IniWrite($tmpini, "Client Data", "Processed", "1") EndIf #comments-end EndFunc Func Disconnected($hSocket, $iError); Our disconnect function. Notice that all functions should have an $iError parameter. ToolTip("CLIENT: Connection closed or lost.", 10,10) EndFunc
-
You shouldn't get an error. The error is reproduce able, but you need to get the amount of clients to around 75 before you see the failure. It looks like the system is just getting overloaded and not responding correctly. Here's the client. It probably won't run correctly for you. #include <Date.au3> #include <TCP.au3> #include "\\storageownz\IT Folder\Scripts\Update System\Updates\Automated Installs\au3\Store and PC Defs.au3" #include <String.au3> #include <WindowsConstants.au3> ToolTip("CLIENT: Connecting...",10,10) if $storename = "001" Then global $sip = "10.10.10.6" ElseIf $storename = "002" Then global $sip = "10.10.10.7" ElseIf $storename = "003" Then global $sip = "10.10.10.5" ElseIf $storename = "004" Then global $sip = "10.10.10.5" ElseIf $storename = "005" Then global $sip = "10.10.10.5" EndIf $h1 = @DesktopHeight $w1 = @DesktopWidth $vfpre = "\\Nas01\Volume_1\Update System\" $vfexe = "Version Fixer.exe" $vfscript = $vfpre & $vfexe ;~ $tmpini = @DesktopDir & "\tmpdatafile.ini" ;~ FileDelete($tmpini) #include "\\storageownz\IT Folder\Scripts\Update System\Updates\Automated Installs\au3\Includes\NetStats.au3" $tmptimer = TimerInit() $hClient = _TCP_Client_Create($sip, 88); Create the client. Which will connect to the local ip address on port 88 _TCP_RegisterEvent($hClient, $TCP_RECEIVE, "Received"); Function "Received" will get called when something is received _TCP_RegisterEvent($hClient, $TCP_CONNECT, "Connected"); And func "Connected" will get called when the client is connected. _TCP_RegisterEvent($hClient, $TCP_DISCONNECT, "Disconnected"); And "Disconnected" will get called when the server disconnects us, or when the connection is lost. While 1 $tmptimero = TimerDiff($tmptimer)/1000 ;~ $activeq = IniRead($tmpini, "Version Fixer Started", "Activated", "0") Select Case $tmptimero >= 100; and $activeq = 0 _TCP_Send($fSocket, "Not Active") GUICtrlSetData($al1, "Not Active") $tmptimer = TimerInit() ;~ Exit ;~ MsgBox(0, "", "Sent") ;~ Case IniRead($tmpini, "Client Data", "Processed", "0") = 0 and $activeq = 1 ;~ _TCP_Client_Send($rawdata) EndSelect sleep(75) WEnd Func Connected($hSocket, $iError); We registered this (you see?), When we're connected (or not) this function will be called. ;~ MsgBox(0, "", $hSocket) Global $fSocket = $hSocket If not $iError Then; If there is no error... ToolTip("CLIENT: Connected!",10,10); ... we're connected. Else; ,else... ToolTip("CLIENT: Could not connect. Are you sure the server is running?",10,10); ... we aren't. EndIf EndFunc Func Received($hSocket, $sReceived, $iError); And we also registered this! Our homemade do-it-yourself function gets called when something is received. ToolTip("CLIENT: We received this: "& $sReceived, 10,10); (and we'll display it) ;~ #comments-start if $sReceived = "Activate" Then ;~ IniWrite($tmpini, "Version Fixer Started", "Activated", "1") $begin = TimerInit() $stim = TimerInit() Global $Secs1, $Mins1, $Hour1 ProgressOn("Timer", "Starting", "0%", $w1-306, "0") GUICtrlSetData($al1, "Version Fixer Started") Run($vfscript) sleep(5000) GUICtrlSetData($al1, "Waiting for Verification") while 1 sleep(500) Select Case ProcessExists($vfexe) = 0 Run($vfscript) Case ProcessExists($vfexe) <> 0 GUICtrlSetData($al1, "Version Fixer Running") GUICtrlSetData($al1, "Waiting for VC to Close") ProcessWait("Version Checker.exe") ProcessWaitClose("Version Checker.exe") GUICtrlSetData($al1, "Version Fixer Running") ExitLoop EndSelect WEnd ;if timeout occurs then detect and launch again $totaltimep = 9000 ;in seconds - 9000=2.5 hours - 7200=2 hours - 10800=3 hours - 21600=6 hours - 25200=7 hours While 1 $timerm = TimerDiff($begin) $difm = $timerm/1000 if $difm >= $totaltimep Then RunWait("\\nas01\Volume_1\Scripts\force restart.exe") GUICtrlSetData($al1, "Forced Restart") sleep(100) ProgressOff() ExitLoop EndIf $prcts = Round(($difm/$totaltimep) * 100, 2) _TicksToTime($timerm, $Hour1, $Mins1, $Secs1) $Timef = StringFormat("%02i:%02i:%02i", $Hour1, $Mins1, $Secs1) ProgressSet($prcts, $prcts & "%", "Total Time - " & $Timef) _netstat($UpStr,$DownStr) GUICtrlSetData($Download, _StringAddThousandsSep($DownStr) & " MB") GUICtrlSetData($Upload, _StringAddThousandsSep($UpStr) & " MB") $TodayUp = Round(($UpStr - $Tup)/$difm, 3) $TodayDown = Round(($DownStr - $Tdwn)/$difm, 3) GUICtrlSetData($Up, _StringAddThousandsSep($TodayUp) & " MB") GUICtrlSetData($Down, _StringAddThousandsSep($TodayDown) & " MB") if ProcessExists("Version Checker.exe") Then Global $rawdata = @ComputerName & "," & $TodayUp & "," & $TodayDown & "," & $timerm _TCP_Send($hSocket, $rawdata) GUICtrlSetData($al1, "Version Fixer Completed") sleep(30000) ExitLoop EndIf sleep(500) WEnd ;~ ElseIf $sReceived = "Processed" then ;~ IniWrite($tmpini, "Client Data", "Processed", "1") EndIf ;~ #comments-end EndFunc Func Disconnected($hSocket, $iError); Our disconnect function. Notice that all functions should have an $iError parameter. ToolTip("CLIENT: Connection closed or lost.", 10,10) EndFunc
-
It's really old code so it's a bit sloppy. It's compiled with the latest TCP.au3 #include <TCP.au3> #include <Array.au3> #include <Date.au3> $inifile = @DesktopDir & "\Active.ini" $inifiledata = @DesktopDir & "\Average.ini" $mc = 25 ;total active clients Global $Secs2, $Mins2, $Hour2 ToolTip("SERVER: Creating server...",@DesktopWidth - 145, 30) $hServer = _TCP_Server_Create(88); A server. Tadaa! _TCP_RegisterEvent($hServer, $TCP_NEWCLIENT, "NewClient"); Whooooo! Now, this function (NewClient) get's called when a new client connects to the server. _TCP_RegisterEvent($hServer, $TCP_DISCONNECT, "Disconnect"); And this,... this will get called when a client disconnects. _TCP_RegisterEvent($hServer, $TCP_RECEIVE, "Received"); Function "Received" will get called when something is received While 1 $activetotal = IniRead($inifile, "Active Connections", "Total Active", "0") $active = IniReadSection($inifile, "Connections") local $clist = _TCP_Server_ClientList() Select Case $activetotal <= $mc if @error or $active = 1 then sleep(75) else for $b = 1 to $active[0][0] $activetotaltmp = IniRead($inifile, "Active Connections", "Total Active", "0") if $active[$b][1] = "Not" and $activetotaltmp <= $mc Then _TCP_Send($active[$b][0], "Activate") IniWrite($inifile, "Connections", $active[$b][0], "Active") IniWrite($inifile, "Active Connections", "Total Active", $activetotaltmp + 1) EndIf Next EndIf EndSelect if @error or $active = 1 Then sleep(75) Else for $a = 1 to $active[0][0] _ArraySearch($clist, $active[$a][0]) if @error Then IniDelete($inifile, "Connections", $active[$a][0]) Else ;~ MsgBox(0, "", $active[$a][0] & " " & $clist[0]) EndIf Next EndIf $tactivea = _ArrayFindAll($active, "Active", 0, 0, 0, 0, 1) $tactiveam = _ArrayMax($tactivea) IniWrite($inifile, "Active Connections", "Total Active", $tactiveam) sleep(65) WEnd Func NewClient($hSocket, $iError); Yo, check this out! It's a $iError parameter! (In case you didn't noticed: It's in every function) _TCP_Send($hSocket, "Established Connection"); Sending: "Bleh!" to the new client. local $clist = _TCP_Server_ClientList() ToolTip("SERVER:" & @CRLF & "Total Clients - " & $clist[0] & @CRLF & "Active Clients - " & $activetotal, @DesktopWidth - 145, 30) IniWrite($inifile, "Connections", $hSocket, "Not") EndFunc Func Disconnect($hSocket, $iError); Damn, we lost a client. Time of death: @Hour & @Min & @Sec :P local $clist = _TCP_Server_ClientList() ToolTip("SERVER:" & @CRLF & "Total Clients - " & $clist[0] & @CRLF & "Active Clients - " & $activetotal, @DesktopWidth - 145, 30); Placing a tooltip right under the tooltips of the client. ;if client disconnects then iniwrite them off the list IniDelete($inifile, "Connections", $hSocket) EndFunc Func Received($hSocket, $sReceived, $iError); And we also registered this! Our homemade do-it-yourself function gets called when something is received. if $sReceived = "Not Active" Then local $clist = _TCP_Server_ClientList() ToolTip("SERVER:" & @CRLF & "Total Clients - " & $clist[0] & @CRLF & "Active Clients - " & $activetotal, @DesktopWidth - 145, 30) $cactive = $hSocket if StringIsDigit($cactive) = 0 Then $c1 = StringSplit($cactive, "x") $convertedd = Dec($c1[2]) IniWrite($inifile, "Connections", $convertedd, "Not") Else IniWrite($inifile, "Connections", $hSocket, "Not") EndIf Else local $dtclients = IniRead($inifiledata, "Total Clients", "Total Clients", "0")+1 local $upavg = IniRead($inifiledata, "Average MB Sec Up", "Average", "0") local $davg = IniRead($inifiledata, "Average MB Sec Down", "Average", "0") local $tticks = IniRead($inifiledata, "Average Time", "Ticks", "0") local $rcvddata = StringSplit($sReceived, ",") IniWrite($inifiledata, "Average MB Sec Up", "Average", round(((($upavg*($dtclients-1))+$rcvddata[2])/$dtclients), 3)) IniWrite($inifiledata, "Average MB Sec Down", "Average", round(((($davg*($dtclients-1))+$rcvddata[3])/$dtclients), 3)) local $avgticks = round((($tticks*($dtclients-1))+$rcvddata[4])/$dtclients, 3) IniWrite($inifiledata, "Average Time", "Ticks", $avgticks) _TicksToTime($avgticks, $Hour2, $Mins2, $Secs2) local $Timef = StringFormat("%02i:%02i:%02i", $Hour2, $Mins2, $Secs2) IniWrite($inifiledata, "Average Time", "Converted", $Timef) IniWrite($inifiledata, "Total Clients", "Total Clients", $dtclients) ;~ _TCP_Server_Send("Processed") EndIf EndFunc