-
Posts
296 -
Joined
-
Last visited
-
Days Won
1
Community Answers
-
sahsanu's post in Wait until I can ping 3 devices before I move on in the script was marked as the answer
Try this code:
Global $IPAddress1 = "192.168.1.37" Global $IPAddress2 = "192.168.1.40" Global $IPAddress3 = "192.168.1.41" Global $IPArray[3] = [$IPAddress1, $IPAddress2, $IPAddress3] _Ping() ;If you want lo limit the tries to ping all the machines simply add the number of tries _Ping(20) for example, by default are 10 If @error Then ConsoleWrite("One or more machines are down." & @CRLF) Else ConsoleWrite("All machines are up and running." & @CRLF) EndIf Func _Ping($iMaxtries = 10) $iCountTotal = 0 Do $iCount = 0 For $p = 0 To UBound($IPArray) - 1 $PingTemp = Ping($IPArray[$p], 250) If Not @error Then $iCount += 1 Sleep(100) Next $iCountTotal += 1 If $iCountTotal = $iMaxtries And $iCount < 3 Then Return SetError(1, 1, 1) EndIf Sleep(500) Until $iCount = 3 Return 0 EndFunc ;==>_Ping Cheers,
sahsanu
-
sahsanu's post in StringRegExpReplace from text was marked as the answer
mikell pointed to the the solution to solve your problem. You have two options, make the search case insensitive
$aArray = StringRegExp(GUICtrlRead($Edit1), '(?i)\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b', $STR_REGEXPARRAYGLOBALMATCH) or add a-z to the pattern to match lowercase letters.
$aArray = StringRegExp(GUICtrlRead($Edit1), '\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}\b', $STR_REGEXPARRAYGLOBALMATCH) Anyway, in the page I linked yesterday, you had this info "If you want to use the regular expression above, there's two things you need to understand. First, long regexes make it difficult to nicely format paragraphs. So I didn't include a-z in any of the three character classes. This regex is intended to be used with your regex engine's "case insensitive" option turned on."
Cheers,
sahsanu
-
sahsanu's post in InetRead problem was marked as the answer
Change function _IEBodyReadHTML by _IEDocReadHTML and you should get the expected result:
#include <String.au3> #include <IE.au3> Local $oIE = _IECreate("http://www.cesarsway.com/channel/dog-training", 0, 0) Local $HTMLCODE = _IEDocReadHTML($oIE) ClipPut($HTMLCODE) If Not @error Then $TITLE = _StringBetween($HTMLCODE, "<title>", "</title>") If IsArray($TITLE) Then $TITLE1 = $TITLE[0] Else $TITLE1 = "missing title" EndIf MsgBox(0, "", $TITLE1) EndIf -
sahsanu's post in Getting program version from a webpage was marked as the answer
Hello,
Something like this could work:
$bSource = InetRead("http://forum.rustoxide.com/resources/rustrcon-admin-tool-32-bit.434/") $sSource = BinaryToString($bSource) $aVersion = StringRegExp($sSource, "(?i)<h3>Version\s(.+?)</h3>", 1) ConsoleWrite("Current version is: " & $aVersion[0] & @CRLF) Cheers,
sahsanu
-
sahsanu's post in Can autoit pull a variable from a string? was marked as the answer
It is a really strange question but just in case...
$JOE = "192.168.1.45" $BOB = "192.168.1.34" $USERSTR = "ifconfig $BOB netmask 255.255.255.0" $aSearchVariable = StringRegExp($USERSTR, "(\$.*?) ", 1) $newip = Execute($aSearchVariable[0]) $new = StringRegExpReplace($USERSTR, "(\$.*?) ", $newip & " ") MsgBox(0, "IP", $new) Keep in mind that there is no error checks at all.
Cheers,
sahsanu
-
sahsanu's post in StdinWrite and Special characters was marked as the answer
Hello,
You said that you used chcp with no result but as it is working to me, could you try this?.
$RunPid=Run(@ComSpec & ' /k chcp 1250', '',"",$STDIN_CHILD + $STDOUT_CHILD + $STDERR_CHILD) Cheers,
sahsanu
-
sahsanu's post in Searching for Strings in Text Using Wildcards was marked as the answer
Hello,
_StringBetween returns an array so $Name is an array and you should explicit wrote what row from that array you want to write to registry, file, whatever...
For example, if you want to use the first row in the array:
RegWrite("HKEY_CURRENT_USER\Software\Test", "Test", "REG_SZ", $Name[0]) Take a look to Arrays section in the help file.
Edit: Added link to Autoit Wiki (Arrays)
-
sahsanu's post in Testing connections to Remote Server TCP Ports was marked as the answer
You are welcome
Just an example using your first script:
Local $ODBC = "LocaHost" Local $ODBC_IP = "10.10.1.10" Local $RPC_Port = "135" Local $SQL_Port = "1825" Local $LS_Port = "1234" Local $aPorts = [$RPC_Port, $SQL_Port, $LS_Port] TCPStartup() For $i = 0 To UBound($aPorts) - 1 $iSocket = TCPConnect($ODBC_IP, $aPorts[$i]) If @error Then ConsoleWrite("No luck connecting to " & $ODBC & "/" & $ODBC_IP & " on port " & $aPorts[$i] & @CRLF) Else ConsoleWrite("Yeah, I've connected to " & $ODBC & "/" & $ODBC_IP & " on port " & $aPorts[$i] & @CRLF) EndIf TCPCloseSocket($iSocket) Next TCPShutdown() -
sahsanu's post in Accessing an Array element using Eval Function was marked as the answer
You could try to use Execute instead of Eval:
Global $MMEList[3] = ["LSMC1-MME0001-CST", "LSMC1-MME0004-CST", "LSMC1-MME0010-CST"] Global $SGWList[3] = ["LSMC1-MME0001-CST", "LSMC1-MME0004-CST", "LSMC1-MME0010-CST"] Global $NEType[2] = ["MME", "SGW"] For $i = 0 To 1 ConsoleWrite("The content of " & "$" & $NEType[$i] & "List[" & $i & "] is: ") ConsoleWrite(Execute("$" & $NEType[$i] & "List[" & $i & "]") & @CRLF) Next Exit Cheers,
sahsanu
-
sahsanu's post in INetGet and INetRead return different values was marked as the answer
Hello,
Using BinaryToString default flag [1] works for me:
$VCard2 = BinaryToString(InetRead($URL,1),1) As flag 1 for BinaryToString is the default one, you could use the function without this parameter:
$VCard2 = BinaryToString(InetRead($URL,1)) As I said, using your url example it returns the Last Name of that person with he right encode "Alcántara" instead of "Alc?ntara".
Edit: I forgot to say that Ureña is showed with right encode too "Ureña" instead of "Ure?a"
Cheers,
sahsanu
-
sahsanu's post in Strings question ... was marked as the answer
Just another approach:
#include <Array.au3> $sString="{1} Blessed be He in Whose hands is the Dominion; and He has Power over all things; {2} It is He Who created Death" & _ "and Life, that He might put you to the test which of you is best in deed: And He is the Exalted in Might, the Oft-Forgiving;" & _ "{3} It is He Who created the seven heavens one above another: No want of proportion will you see in the Creation of Allah the" & _ "Most Gracious. So turn your sight again: Do you see any flaw? " $sResult=StringRegExpReplace($sString,"(\{\d{1,}\})",@CR & "$1") $sResult=StringRegExpReplace($sResult,"(\r)(.*)","$2",1) ConsoleWrite('Result:' & @CRLF & $sResult & @CRLF) ;If you want it in an array add this: $aArray=StringSplit($sResult,@CR) _ArrayDisplay($aArray) Cheers,
sahsanu
-
sahsanu's post in Console or dunno was marked as the answer
I think you need something like this:
#include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <GUIEdit.au3> #include <ScrollBarConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUICloseOnESC", 1) Opt("GUIOnEventMode", 1) Global $hGUI = GUICreate("AutoTrade", 350, 400, -1, -1, -1, $WS_EX_TOPMOST) Global $hEdit = GUICtrlCreateEdit("", 0, 0, 350, 350, BitOR($ES_READONLY, $ES_AUTOVSCROLL)) GUICtrlSetBkColor($hEdit, 0xFFFFFF) Global $hButton = GUICtrlCreateButton("Start", 0, 350, 175, 50) GUICtrlSetOnEvent($hButton, "_StartProgram") Global $hButton2 = GUICtrlCreateButton("Pause", 175, 350, 175, 50) GUICtrlSetOnEvent($hButton2, "_PauseProgram") GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate") GUISetState(@SW_SHOW, $hGUI) Global $start = 0, $wait = 1 _WriteToEditBox("AutoTrade started. Press ESC or click X to exit") While 1 If $start = 1 Then _MainProgram() Sleep(100) wend Func _StartProgram() _WriteToEditBox("Starting program") $wait = 1 $start = 1 EndFunc ;==>_StartProgram Func _PauseProgram() _WriteToEditBox("Pausing program") $start = 0 EndFunc ;==>_Pauserogram Func _MainProgram() If $wait=1 Then _WriteToEditBox("Wait till positive position") $coord = PixelSearch(17, 753, 37, 765, 0x90F393); wait till positive position If Not @error Then $wait=1 _WriteToEditBox("Closing position") MouseClick("left", 1265, 738, 1); closing position _WriteToEditBox("Waiting for sale mark") Sleep(3000) $coord = PixelSearch(214, 124, 249, 182, 0xFF6060); waiting for sale mark If Not @error Then MouseClick("left", 306, 148, 1); opening new position _WriteToEditBox("Opening new position") EndIf Else $wait=0 Sleep(100) EndIf EndFunc ;==>_MainProgram Func _WriteToEditBox($sText) $iEnd = StringLen(GUICtrlRead($hEdit)) _GUICtrlEdit_SetSel($hEdit, $iEnd, $iEnd) _GUICtrlEdit_Scroll($hEdit, $SB_SCROLLCARET) If $iEnd = 0 Then GUICtrlSetData($hEdit, @HOUR & ":" & @MIN & ":" & @SEC & " :-: " & $sText, 1) Else GUICtrlSetData($hEdit, @CRLF & @HOUR & ":" & @MIN & ":" & @SEC & " :-: " & $sText, 1) EndIf EndFunc ;==>_WriteToEditBox Func Terminate() Exit EndFunc ;==>Terminate I'm pretty sure you will need to change several things but I think you have some start point to get what you are looking for.
Cheers,
sahsanu
-
sahsanu's post in filefind filemove keeping same name was marked as the answer
As you are asking different questions, next time please, open a new thread
Yes, it is possible.
There is a way to Trim the first 7 characters but it is not so simple.
I've modified your script to move files every 400 rows and when the last row is processed and rename the files removing the first 7 characters "thomas_" when you move them. Double check it before put it in production
#include <Excel.au3> #include <File.au3> ;enter excel data into calypso $oExcel = _ExcelBookOpen("\\fbnecl3\inzb\Documents\Load Support\Book1.xlsx") WinActivate("Calypso Host") Sleep(700) Send("DA") $dosomethingevery = 400 ;move files every x times $dosomethingreached = $dosomethingevery $finalcount = 2700 For $i = 1 To $finalcount ;Loop $TypCellValue = _ExcelReadCell($oExcel, $i, 1) $CityCellValue = _ExcelReadCell($oExcel, $i, 2) $PrdCellValue = _ExcelReadCell($oExcel, $i, 3) Send("{TAB}") Sleep(100) Sleep(100) Send($TypCellValue) Sleep(100) Send($CityCellValue) Sleep(100) Send("+{DELETE}") Sleep(100) Send($PrdCellValue) Sleep(100) Send("{ENTER}") Sleep(100) Send("+{F12}") Sleep(100) Send("C") Sleep(100) Send("{TAB}") Sleep(100) Send("{ENTER}") Sleep(100) Send("{NUMPADMULT}") Sleep(100) Send("thomas_") Sleep(100) Send($TypCellValue) Sleep(100) Send("_") Sleep(100) Send($CityCellValue) Sleep(100) Send("_") Sleep(100) Send($PrdCellValue) Sleep(100) Send(".doc") Sleep(100) Send("{TAB}") Sleep(100) Send("PC") Sleep(100) Send("{ENTER}") Sleep(100) Send("{ESC}") ;Moving files every x times and when $finalcount is 2700 if $i = $dosomethingreached Or $i = $finalcount Then ;if limit is reached (in the example every 400) or last line (2700) then move files $aFileList = _FileListToArray("\\calypso.au.flitech.net\reports\loadtext\", "thomas_*_*_*.doc", 1);need to put the file names into an array to process then later If @error = 4 Then ConsoleWrite("No files found: " & $i & @CRLF) Else For $f = 1 to $aFileList[0] $finalname = StringTrimLeft($aFileList[$f], 7) ;remove first 7 characters FileMove("\\calypso.au.flitech.net\reports\loadtext\" & $aFileList[$f], "\\fbnecl3\inzb\Documents\ATI - LOAD\ATI - LIVE\CPL Migration\Supplier Notes\" & $finalname, 9) Next EndIf $dosomethingreached = $dosomethingevery + $dosomethingreached ;increase the limit adding 400 every time EndIf Next Sleep(60000)
-
sahsanu's post in Need help deleting a line was marked as the answer
You could also use arrays and rewrite the file from the second line, something like this:
#include <File.au3> $textfile = "textfile.txt" Local $aRecords If Not _FileReadToArray($textfile, $aRecords) Then ConsoleWrite("Error reading file to Array:" & @error) Exit EndIf If $aRecords[0] = 1 Then ConsoleWrite("Mmmmm there is just 1 line on file... exiting" & @CRLF) Exit EndIf Local $hFile = FileOpen($textfile, 2) ; 2 = overwrite _FileWriteFromArray($hFile, $aRecords, 2) FileClose($hFile)