alientorress
Members-
Posts
11 -
Joined
-
Last visited
alientorress's Achievements
Seeker (1/7)
0
Reputation
-
Still Not Working: If ( StringInStr($aRecords[$x], "192.168.0.1"&":25") AND _ StringInStr($aRecords[$x], "ESTABLISHED") ) OR _ ( StringInStr($aRecords[$x], "192.168.0.1"&":110") AND _ StringInStr($aRecords[$x], "ESTABLISHED") ) _ Then With this code is not working, i don't know what is wrong. Please Help...
-
Hello There. This is my first Project with AutoIt and i will love to hear some advises so i can make my code better. Is a Dial-In server on WinXP: - I use a CallerID Software then when the rigth number dial-in I run the AutoIt script i made(I do this because otherwise if i always have the incoming connection created when someone call my home phone the modem will pick up the call.). - What the script do: - Once The CallerID software run the AutoIt script, AutoIt script close CallerID software because otherwise the RASMAN can't take care of the incoming connection because the CallerID software keep using the TAPI service or device... - Open Network Connection - Open New Connection Wizard and do all the Steps to finish that Incoming Connection(Here on this Steps i make lots of error check because this software i will use also on some unattenden remote servers...). - Wait 35 seconds so the incoming connection is complete.(If not complete then Delete Incoming Connection) - Then search on SysTray tooltips for the incoming connection name(is the only good way i found to do this on WinXP because making ping is not a good way because of firewalls on client side.)(I can't find any other good way to do this.)(I use this function from another guy on this forum and i made some changes credits for him...) - Once the connection is established then check if the client make any connection to my Mail Server(POP3 or SMTP) i use netstat -anop TCP stdout and read it to an array and parse that(there is a better way? please letme know.) - IF the client don't make any connection to my mail server i delete de incoming connection otherwise wait until the client finish the connection or for a maximun time of 16minutes so so. - Delete de Incoming Connection and Restore de CallerID Software. All this is working but i will love to hear some advises and also i will like to improve this, i was thinking about: - Just keep incoming connection created and stop and start rasman service but this service is really problematic and don't stop in the way it should and sometimes don't stop at all... - Other thing i was missing was to create incoming connection and then just check modem box or not depent on what i want to do... - PLEASE any other idea or anyother way to do this and make it better and faster with less steps? Here the code: #cs Script de AutoIt V3 Nombre: AceptarConexion Version: 2.1.0 Autor:TheBug2k5 Date: 14-Enero-2012 Time: 7:40PM Notas: Working so far. To Do: - Improve ErrorChecking Funtions. - Slowly change everything to use ControlCommands and ControlSend methods. - Add Code Comments. #ce ; Includes #include <file.au3> #include <Process.au3> #Include <GuiToolBar.au3> Global $hSysTray_Handle, $ConexExist Global $conexname = "gam" Global $hitcounter = 0 Global $winwait = 0 Global $conbreak = 0 Global $delcon = 0 Global $conectime = 0 Global $conexyes = 0 $param1 = $CmdLine[1] UnlockCloseP() WriteLog($param1) CreaConex() If $delcon = 0 Then CheckAndDelConex() WriteLogEnd($param1) RestoreSoft() _RefreshSystemTray() Exit Else WriteLogError($param1) RestoreSoft() _RefreshSystemTray() Exit EndIf Func UnlockCloseP() If ProcessExists("CallClerk.exe") Then ProcessClose("CallClerk.exe") EndIf Send("#m") Sleep(1000) EndFunc Func WriteLogErrorFatal($infoid) FileOpen(@ScriptDir & "\connect.log", 1) $handle = FileOpen(@ScriptDir & "\connect.log", 1) _FileWriteLog(@ScriptDir & "\connect.log","Error Fatal La PC se va a Reiniciar: "&$infoid) FileClose($handle) EndFunc Func WriteLogError($infoid) FileOpen(@ScriptDir & "\connect.log", 1) $handle = FileOpen(@ScriptDir & "\connect.log", 1) _FileWriteLog(@ScriptDir & "\connect.log","Error Procesando: "&$infoid) FileClose($handle) EndFunc Func WriteLog($infoid) FileOpen(@ScriptDir & "\connect.log", 1) $handle = FileOpen(@ScriptDir & "\connect.log", 1) _FileWriteLog(@ScriptDir & "\connect.log","Se ha Conectado: "&$infoid) FileClose($handle) EndFunc Func WriteLogEnd($infoid) FileOpen(@ScriptDir & "\connect.log", 1) $handle = FileOpen(@ScriptDir & "\connect.log", 1) _FileWriteLog(@ScriptDir & "\connect.log","Se ha Desconectado: "&$infoid) FileClose($handle) EndFunc ; FUNCION PARA CREAR LA CONEXION ENTRANTE Func CreaConex() Run("RUNDLL32.EXE SHELL32.DLL,Control_RunDLL ncpa.cpl", "") ActiveConnectRed() Sleep(500) Send("{ALT}ax") CheckWin() ActiveHit1() CheckWinSelect() ActiveHit2() CheckWin() ActiveHit3() CheckWin() ActiveHit4() CheckWin() ActiveHit5() CheckWin() ActiveHit6() CheckWin() ActiveHit7() CheckWin() ActiveHitEnd() WinClose("Conexiones de red") $conexion = 0 While Get_ConexExist($conexname) = 0 Sleep(500) _RefreshSystemTray() $conexion = $conexion + 1 If $conexion >= 35 Then DelConex() ExitLoop Else ContinueLoop EndIf WEnd EndFunc Func Conected() If FileExists(@ScriptDir&"-Status.txt") Then FileDelete(@ScriptDir&"-Status.txt") EndIf _RunDOS('netstat -anop TCP > ' & @ScriptDir&"-Status.txt") Local $aRecords _FileReadToArray(@ScriptDir&"-Status.txt",$aRecords) $pcname = @ComputerName For $x = 1 to $aRecords[0] If ( StringInStr($aRecords[$x], "192.168.0.1"&":25") OR _ ( StringInStr($aRecords[$x], "192.168.0.1"&":110") ) AND _ StringInStr($aRecords[$x], "ESTABLISHED")) _ Then $conexyes = 1 Else $conexyes = 0 EndIf Sleep(50) Next EndFunc Func CheckConexMail() If Get_ConexExist($conexname) = 0 AND $delcon = 0 Then DelConex() EndIf While Get_ConexExist($conexname) <> 0 Conected() If $conexyes <> 0 Then Sleep(500) $conbreak = $conbreak + 1 If $conbreak >= 1800 AND $delcon = 0 Then DelConex() ExitLoop Else If Get_ConexExist($conexname) <> 0 Then CheckConexMail() ElseIf $delcon = 0 Then DelConex() ExitLoop EndIf EndIf Else Sleep(500) $conectime = $conectime + 1 If $conectime >= 60 AND $delcon = 0 Then DelConex() ExitLoop Else CheckConexMail() EndIf EndIf WEnd EndFunc Func OnError() $counter3 = 0 $oncounter1 = 0 If WinExists("Asistente para conexión nueva") Then While WinExists("Asistente para conexión nueva") WinKill("Asistente para conexión nueva") Sleep(500) $counter3 = $counter3 + 1 If $counter3 >= 240 Then WriteLogErrorFatal($param1) Shutdown (18) Exit Else ContinueLoop EndIf WEnd Else While WinExists("Conexiones de red") WinKill("Conexiones de red") Sleep(500) $oncounter1 = $oncounter1 + 1 If $oncounter1 >= 240 Then WriteLogErrorFatal($param1) Shutdown (18) Exit Else ContinueLoop EndIf WEnd EndIf $on2counter1 = 0 If WinExists ("Conexiones de red") Then While WinExists("Conexiones de red") WinKill("Conexiones de red") Sleep(500) $on2counter1 = $on2counter1 + 1 If $on2counter1 >= 240 Then WriteLogErrorFatal($param1) Shutdown (18) Exit Else ContinueLoop EndIf WEnd EndIf WriteLogErrorFatal($param1) Shutdown (18) Exit EndFunc Func CheckWin() $counter1 = 0 $counter2 = 0 While Not WinExists("Asistente para conexión nueva") Sleep(500) $counter1 = $counter1 + 1 If $counter1 >= 240 Then OnError() ExitLoop Else ContinueLoop EndIf WEnd If WinExists("Asistente para conexión nueva") Then While Not WinActive("Asistente para conexión nueva") WinActivate("Asistente para conexión nueva") Sleep(500) $counter2 = $counter2 + 1 If $counter2 >= 240 Then OnError() ExitLoop Else ContinueLoop EndIf WEnd EndIf Sleep(500) EndFunc Func CheckWinSelect() $counter4 = 0 $counter5 = 0 $counter6 = 0 While Not WinExists("Asistente para conexión nueva") Sleep(500) $counter4 = $counter4 + 1 If $counter4 >= 240 Then OnError() ExitLoop Else ContinueLoop EndIf WEnd If WinExists("Asistente para conexión nueva") Then While Not WinActive("Asistente para conexión nueva") WinActivate("Asistente para conexión nueva") Sleep(500) $counter5 = $counter5 + 1 If $counter5 >= 240 Then OnError() ExitLoop Else ContinueLoop EndIf WEnd While Not ControlCommand('Asistente para conexión nueva', '', '[CLASS:Button; INSTANCE:4]', 'IsEnabled', '') Sleep(500) $counter6 = $counter6 + 1 If $counter6 >= 240 Then OnError() ExitLoop Else ContinueLoop EndIf WEnd ControlSend("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:4]", "{SPACE}") Sleep(500) EndIf EndFunc Func ActiveHit1() If ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:2]", "IsEnabled", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:2]", "IsVisible", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:4]", "IsEnabled", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:4]", "IsVisible", "") Then ControlFocus("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:2]") Sleep(50) Send("{ENTER}") Do Sleep(500) $winwait = $winwait + 1 If $winwait >= 40 Then CreaConex() ExitLoop EndIf Until WinExists("Asistente para conexión nueva") $winwait = 0 Else Sleep(500) $hitcounter = $hitcounter + 1 If $hitcounter >= 240 Then OnError() Else ActiveHit1() EndIf EndIf EndFunc Func ActiveHit2() If ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:6]", "IsEnabled", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:6]", "IsVisible", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:5]", "IsEnabled", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:5]", "IsVisible", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:8]", "IsEnabled", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:8]", "IsVisible", "") Then ControlFocus("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:6]") Sleep(50) Send("{ENTER}") Do Sleep(500) $winwait = $winwait + 1 If $winwait >= 40 Then CreaConex() ExitLoop EndIf Until WinExists("Asistente para conexión nueva") $winwait = 0 Else Sleep(500) $hitcounter = $hitcounter + 1 If $hitcounter >= 240 Then OnError() Else ActiveHit2() EndIf EndIf EndFunc Func ActiveHit3() If ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:8]", "IsEnabled", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:8]", "IsVisible", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:7]", "IsEnabled", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:7]", "IsVisible", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:10]", "IsEnabled", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:10]", "IsVisible", "") Then ControlFocus("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:8]") Sleep(50) Send("{ENTER}") Do Sleep(500) $winwait = $winwait + 1 If $winwait >= 40 Then CreaConex() ExitLoop EndIf Until WinExists("Asistente para conexión nueva") $winwait = 0 Else Sleep(500) $hitcounter = $hitcounter + 1 If $hitcounter >= 240 Then OnError() Else ActiveHit3() EndIf EndIf EndFunc Func ActiveHit4() If ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:9]", "IsEnabled", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:9]", "IsVisible", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:8]", "IsEnabled", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:8]", "IsVisible", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:11]", "IsEnabled", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:11]", "IsVisible", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:1]", "IsEnabled", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:1]", "IsVisible", "") Then ControlFocus("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:9]") Sleep(50) Send("{ENTER}") Do Sleep(500) $winwait = $winwait + 1 If $winwait >= 40 Then CreaConex() ExitLoop EndIf Until WinExists("Asistente para conexión nueva") $winwait = 0 Else Sleep(500) $hitcounter = $hitcounter + 1 If $hitcounter >= 240 Then OnError() Else ActiveHit4() EndIf EndIf EndFunc Func ActiveHit5() If ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:11]", "IsEnabled", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:11]", "IsVisible", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:10]", "IsEnabled", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:10]", "IsVisible", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:13]", "IsEnabled", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:13]", "IsVisible", "") Then ControlFocus("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:11]") Sleep(50) Send("{ENTER}") Do Sleep(500) $winwait = $winwait + 1 If $winwait >= 40 Then CreaConex() ExitLoop EndIf Until WinExists("Asistente para conexión nueva") $winwait = 0 Else Sleep(500) $hitcounter = $hitcounter + 1 If $hitcounter >= 240 Then OnError() Else ActiveHit5() EndIf EndIf EndFunc Func ActiveHit6() If ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:14]", "IsEnabled", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:14]", "IsVisible", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:1]", "IsEnabled", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:1]", "IsVisible", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:2]", "IsEnabled", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:2]", "IsVisible", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:3]", "IsEnabled", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:3]", "IsVisible", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:13]", "IsEnabled", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:13]", "IsVisible", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:16]", "IsEnabled", "") AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:16]", "IsVisible", "") Then ControlFocus("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:14]") Sleep(50) Send("{ENTER}") Do Sleep(500) $winwait = $winwait + 1 If $winwait >= 40 Then CreaConex() ExitLoop EndIf Until WinExists("Asistente para conexión nueva") $winwait = 0 Else Sleep(500) $hitcounter = $hitcounter + 1 If $hitcounter >= 240 Then OnError() Else ActiveHit6() EndIf EndIf EndFunc Func ActiveHit7() If ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:17]", "IsEnabled" ) AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:17]", "IsVisible" ) AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:1]", "IsEnabled" ) AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:1]", "IsVisible" ) AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:3]", "IsEnabled" ) AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:3]", "IsVisible" ) AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:16]", "IsEnabled" ) AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:16]", "IsVisible" ) AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:19]", "IsEnabled" ) AND _ ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:19]", "IsVisible" ) Then ControlFocus("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:17]") Sleep(50) Send("{ENTER}") Do Sleep(500) $winwait = $winwait + 1 If $winwait >= 40 Then CreaConex() ExitLoop EndIf Until WinExists("Asistente para conexión nueva") $winwait = 0 Else Sleep(500) $hitcounter = $hitcounter + 1 If $hitcounter >= 240 Then OnError() Else ActiveHit7() EndIf EndIf EndFunc Func ActiveHitEnd() If ControlCommand('Asistente para conexión nueva', '', 'Finalizar', 'IsEnabled', '') AND _ ControlCommand('Asistente para conexión nueva', '', 'Finalizar', 'IsVisible', '') Then ControlSend("Asistente para conexión nueva", "", "Finalizar", "{ENTER}") Do Sleep(500) $winwait = $winwait + 1 If $winwait >= 40 Then CreaConex() ExitLoop EndIf Until WinExists("Asistente para conexión nueva") $winwait = 0 EndIf While WinExists('Asistente para conexión nueva') Sleep(500) $hitcounter = $hitcounter + 1 If $hitcounter >= 240 Then OnError() ExitLoop Else ContinueLoop EndIf WEnd EndFunc Func ActiveConnectRed() $counterred1 = 0 $counterred2 = 0 While Not WinExists("[CLASS:CabinetWClass]","Conexiones de red") Sleep(500) $counterred1 = $counterred1 + 1 If $counterred1 >= 240 Then OnError() ExitLoop Else ContinueLoop EndIf WEnd If WinExists("[CLASS:CabinetWClass]","Conexiones de red") Then While Not WinActive("[CLASS:CabinetWClass]","Conexiones de red") WinActivate("[CLASS:CabinetWClass]","Conexiones de red") Sleep(500) $counterred2 = $counterred2 + 1 If $counterred2 >= 240 Then OnError() ExitLoop Else ContinueLoop EndIf WEnd $items = ControlListView("Conexiones de red", "", "SysListView321", "GetItemCount") $counteritems = 0 While $items < 1 WinActivate("[CLASS:CabinetWClass]","Conexiones de red") Sleep(500) $counteritems = $counteritems + 1 If $counteritems >= 240 Then OnError() ExitLoop Else $items2 = ControlListView("Conexiones de red", "", "SysListView321", "GetItemCount") $items = $items2 ContinueLoop EndIf WEnd EndIf Sleep(500) EndFunc Func Get_ConexExist($conexname) ; Find systray handle $hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]') If @error Then MsgBox(16, "Error", "System tray not found") Exit EndIf ; Get systray item count Local $iSystray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle) If $iSystray_ButCount = 0 Then MsgBox(16, "Error", "No items found in system tray") Exit EndIf ; Look for wanted tooltip For $ConexExist = 0 To $iSystray_ButCount - 1 If StringInStr(_GUICtrlToolbar_GetButtonText($hSysTray_Handle, $ConexExist), $conexname) > 0 Then ExitLoop Next If $ConexExist = $iSystray_ButCount Then Return 0 ; Not found Else Return $ConexExist ; Found EndIf EndFunc Func CheckAndDelConex() Sleep(50) While Get_ConexExist($conexname) <> 0 Sleep(50) CheckConexMail() WEnd If $delcon = 0 Then Sleep(50) DelConex() EndIf EndFunc Func DelConex() Run("RUNDLL32.EXE SHELL32.DLL,Control_RunDLL ncpa.cpl", "") ActiveConnectRed() $incoming = ControlListView("Conexiones de red", "", "SysListView321", "FindItem", "Conexiones entrantes") $fcounter1 = 0 ControlListView("Conexiones de red", "", "SysListView321", "ViewChange","details") If $incoming <> -1 Then ControlListView("Conexiones de red", "", "SysListView321", "Select", $incoming) Sleep(500) Send("+{DEL}") Sleep(500) While Not ControlCommand('Confirmar eliminación de conexión', '', '[CLASS:Button; INSTANCE:1]', 'IsEnabled', '') Sleep(500) $fcounter1 = $fcounter1 +1 If $fcounter1 >= 120 Then OnError() ExitLoop Else ContinueLoop EndIf WEnd ControlSend("Confirmar eliminación de conexión", "", "[CLASS:Button; INSTANCE:1]", "{ENTER}") EndIf ActiveConnectRed() WinClose("Conexiones de red") $delcon = 1 EndFunc ; FUNCIONA PARA REFRESCAR EL SYSTEM TRAY Func _RefreshSystemTray($nDelay = 1000) ; Save Opt settings Local $oldMatchMode = Opt("WinTitleMatchMode", 4) Local $oldChildMode = Opt("WinSearchChildren", 1) Local $error = 0 Do; Pseudo loop Local $hWnd = WinGetHandle("classname=TrayNotifyWnd") If @error Then $error = 1 ExitLoop EndIf Local $hControl = ControlGetHandle($hWnd, "", "Button1") ; We're on XP and the Hide Inactive Icons button is there, so expand it If $hControl <> "" And ControlCommand($hWnd, "", $hControl, "IsVisible") Then ControlClick($hWnd, "", $hControl) Sleep($nDelay) EndIf Local $posStart = MouseGetPos() Local $posWin = WinGetPos($hWnd) Local $y = $posWin[1] While $y < $posWin[3] + $posWin[1] Local $x = $posWin[0] While $x < $posWin[2] + $posWin[0] DllCall("user32.dll", "int", "SetCursorPos", "int", $x, "int", $y) If @error Then $error = 2 ExitLoop 3; Jump out of While/While/Do EndIf $x = $x + 8 WEnd $y = $y + 8 WEnd DllCall("user32.dll", "int", "SetCursorPos", "int", $posStart[0], "int", $posStart[1]) ; We're on XP so we need to hide the inactive icons again. If $hControl <> "" And ControlCommand($hWnd, "", $hControl, "IsVisible") Then ControlClick($hWnd, "", $hControl) EndIf Until 1 ; Restore Opt settings Opt("WinTitleMatchMode", $oldMatchMode) Opt("WinSearchChildren", $oldChildMode) SetError($error) EndFunc; _RefreshSystemTray()
-
Thanks u so much, i try this and i get unbalance parentexis expresion to i add ) rigth after "ESTABLISHED") so will be like this: "ESTABLISHED")) _ Then all compile and working, anyways i need to wait an user connect and see if the code work properly i will let u know... Kind Regards Alien and THANKS u AGAIN...
-
Hello to everyone. My problem is my For Loop is not working in the way it should please help... Why my script do is create an incoming connection(Dial-In) wait arround 30s to modem connection complete, then search on Systray tooltips to find if the connection is established and then run netstat to check if the incoming user have an established connection with my mail server, POP3 or SMTP, if not then delete connection in 2 minutes or so. But if the user have an established connection with my mail then wait until a maximun of 16Min so so... The problem is sometimes the user is downloading mails and the script go and delete the connection so for some reason my netstat loop is not working very well i will put here the functions involved but if someone need the entire code letme know... Thanks in advance... Kind Regards Alien. Func Conected() If FileExists(@ScriptDir&"-Status.txt") Then FileDelete(@ScriptDir&"-Status.txt") EndIf _RunDOS('netstat -anop TCP > ' & @ScriptDir&"-Status.txt") Local $aRecords _FileReadToArray(@ScriptDir&"-Status.txt",$aRecords) $pcname = @ComputerName For $x = 1 to $aRecords[0] If StringInStr($aRecords[$x], "192.168.0.1"&":25") AND _ StringInStr($aRecords[$x], "ESTABLISHED") OR _ StringInStr($aRecords[$x], "192.168.0.1"&":110") AND _ StringInStr($aRecords[$x], "ESTABLISHED") _ Then $conexyes = 1 Else $conexyes = 0 EndIf Sleep(50) Next EndFunc Func CheckConexMail() If Get_ConexExist($conexname) = 0 AND $delcon = 0 Then DelConex() EndIf While Get_ConexExist($conexname) <> 0 Conected() If $conexyes <> 0 Then Sleep(500) $conbreak = $conbreak + 1 If $conbreak >= 1800 AND $delcon = 0 Then DelConex() ExitLoop Else If Get_ConexExist($conexname) <> 0 Then CheckConexMail() ElseIf $delcon = 0 Then DelConex() ExitLoop EndIf EndIf Else Sleep(500) $conectime = $conectime + 1 If $conectime >= 60 AND $delcon = 0 Then DelConex() ExitLoop Else CheckConexMail() EndIf EndIf WEnd EndFunc
-
I´m trying to make a Software to Monitor for Incoming CallerID info from the modem and if the number is = xxxxxxx then Run another Software, ELSE continue monitoring the Line. The problems is in the same machine, i use to dial up from time to time to internet, and every example and code i test to handle COM PORTS... close the ConPort I already try with COM PORT UDF from Martin and some NetComOCX examples but when the Software is running i'm not able to Dial-Out or use the Modem at all... I know this can be done because some time ago i use CallClerk and even with CallClerk open i can dial to internet conection ISP... Please help... Thanks...
-
While Not Loop problem!
alientorress replied to alientorress's topic in AutoIt General Help and Support
Thank u so much to everyone... THANKss... now please could some one tellme if my code will be more fast and with low CPU comsuption with the IF conditionals like i do it or better with the case example and arrays that czardas wrote? Thank... nice comunity by the way i will keep in touch and share some code i wrote when is more stable and finished.... Thanks.... -
While Not Loop problem!
alientorress replied to alientorress's topic in AutoIt General Help and Support
Ohhh THANKS U so much by the way... -
While Not Loop problem!
alientorress replied to alientorress's topic in AutoIt General Help and Support
Before i read ur reply i do it like this: Func ActiveHit1() If ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:2]", "IsEnabled", "") AND ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:4]", "IsEnabled", "") Then Send("{ENTER}") Else Sleep(500) $contadorhit = $contadorhit + 1 If $contadorhit >= 240 Then OnError() Else ActiveHit1() EndIf EndIf EndFunc And it work, the question now is in what way is more stable and fast? time and CPU load is critical for me because this script will run on a very old machine... PIII 700Mhz 256MB RAM. And the other question... why i can't do: IF THIS AND THIS AND THIS... I always have to do: IF THIS AND THIS AND THIS all in a single line? problems with the editor or with the syntactical analysis of the compiler? -
I just need to do a While Not Loop... But i want the same While make more than 1 evaluation... Example: Func ActiveHit2() $hitcounter2 = 0 $hitcounter2a = 0 $hitcounter2c = 0 While Not ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:6]", "IsEnabled", "") Sleep(500) $hitcounter2 = $hitcounter2 + 1 If $hitcounter2 >= 240 Then OnError() ExitLoop Else ContinueLoop EndIf WEnd While Not ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:5]", "IsEnabled", "") Sleep(500) $hitcounter2a = $hitcounter2a + 1 If $hitcounter2a >= 240 Then OnError() ExitLoop Else ContinueLoop EndIf WEnd While Not ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:8]", "IsEnabled", "") Sleep(500) $hitcounter2c = $hitcounter2c + 1 If $hitcounter2c >= 240 Then OnError() ExitLoop Else ContinueLoop EndIf WEnd Send("{ENTER}") EndFunc But this make Diferents While Loop, i want everything inside only one While because i think will be more eficient... Thanks...