
99ojo
Active Members-
Posts
829 -
Joined
-
Last visited
Everything posted by 99ojo
-
Search a .txt to see if it contains values in a .INI
99ojo replied to Shakala's topic in AutoIt General Help and Support
Hi, if i catch you right, you want to save $SouceText[2] into an ignore list. 1) Save your ignore list into a file. 2) Read this file into an array. -> _FileListToArray () 3) Perform a search over the array, to check, if the line string is in the array. -> _ArraySearch () 4) If not in array, perform your $SearchResults..... If you find the string, add this line to your ignore list and do an _ArrayAdd ($arignore, FileReadLine ("ignore.txt", -1)) -> Read Last Line from ignore.txt and put value into ignore array for later or more comparisons. This might helps you for further coding...... ;-)) Stefan P.S: This is all i will give you........ -
Hi, 1) FileGetTime doesn't work with Wildcards. 2) FileGetTime returns an array. Try this: #include <Date.au3> #Include <File.au3> Dim $i, $arfile $sFolder = InputBox("Backup-Cleaner", "Please type in filepath correctly", "C:\Downloads") If @error = 1 Then MsgBox(4096, "Backup-Cleaner", "Aborted by User") Exit EndIf $iMaxDays = InputBox("Backup-Cleaner", "Type in the age of files which should be removed e.g.= 14", "14") If @error = 1 Then MsgBox(4096, "Backup-Cleaner", "Aborted by User") Exit EndIf ;get all files into array $arfile = _FileListToArray ($sFolder, "*.doc", 1) If @error Then MsgBox (0,"Error", "Path or no documents found!!") Exit EndIf For $i = 1 To UBound ($arfile) - 1 ;get modified date of file, return is an array $t = FileGetTime ($sFolder & "\" & $arfile [$i]) ;if difference is bigger then input in days -> delete file, see helpfile _DateDiff () If _DateDiff ("D", $t [0] & "/" & $t [1] & "/" & $t [2], _NowCalcDate ()) > $iMaxDays Then FileDelete ($sFolder & "\" & $arfile [$i]) EndIf Next ;-)) Stefan
-
ShellExecuteWait() and errorlevels
99ojo replied to Phenom's topic in AutoIt General Help and Support
Hi, if help file is correct, yes and no: If the called program returns different exit codes for different errorlevels: Helpfile ShellExecuteWait () Success: Returns the exit code of the program that was run. ;-)) Stefan -
how to check if an input box is empty
99ojo replied to Phenom's topic in AutoIt General Help and Support
Hi, as Zorphnog suggests: $input1 = GuiCtrlCreateInput....... If GuiCtrlRead($input1) = "" Then MsgBox (0,"Empty.....", "....Input detected!") ;-)) Stefan -
How to get path from multiple files ?
99ojo replied to madasraka's topic in AutoIt General Help and Support
Hi, if you need path and filenames for further coding, i'd use: $sString = "C:\Users\Administrator\Desktop\System|DN3D_pickups.u|Dweather.u|Dweather.ucl" $artemp = StringSplit ($string, "|") MsgBox (0,"", "Path: " & $artemp [1]) For $i = 2 To $artemp [0] MsgBox (0,"", "File: " & $artemp [$i] & @CRLF & "Full Path: " & $artemp [1] & "\" & $artemp [$i]) Next ;-)) Stefan -
Hi, how did you test? My example works fine on Win 7 64 Bit Ultimate (Compiled and as au3 script); but it is running as a VMWare machine. I use a local stored swf file without problems. You may post your test code if you haven't tried mine and i can test it on monday on my Win 7 machine. By the way, how do i know, which browser, 64 bit or 32 bit version, is used as embedded object? Both are available! ;-)) Stefan P.S: ?? It might be a combination of ie, flash and graphic driver ??
-
Hi, my solution with your 3 origin arrays. Depends what you want, you may prefer Melba's solution. Local $1[4] = [315,275,366,254] Local $2[4] = [345,298,430,265] Local $3[4] = [485,485,470,275] $run = 1 _mysum ($1) _mysum ($2) _mysum ($3) Func _mysum ($array) $sum = $array [0] $sum1 = $array [1] $sum2 = $array [2] $sum3 = $array [3] MsgBox (0, "Sum Run " & $run, $sum & @CRLF & $sum1 & @CRLF & $sum2 & @CRLF & $sum3) $run += 1 EndFunc ;-)) Stefan @Melba23: HaHaHaHaHa, thanks ....
-
Hi, so do 1st a RegRead and look for the return / @error. Failure: Returns "" and sets the @error flag: 1 if unable to open requested key 2 if unable to open requested main key Then you can do a RegWrite to write the missing keys. If you have @error 2 you have to do 2 RegWrite's. See helpfile RegWrite: Creates a key or value in the registry. RegWrite ( "keyname" [,"valuename" [, "type" [, value]]] ) ;-)) Stefan
-
Problem with while loops and if
99ojo replied to niubbone's topic in AutoIt General Help and Support
Hi, for exiting the second while loop, $condition has to be bigger then 9. Since $condition never changes in the 2nd while loop, it will run 4 ever: !! $condition=Random(1,5,1) !! You missed the else for the 2nd If $clickcount < 20: If $ClickCount<20 Then; ITS ELSE DOESNT WORK! <- can't, because you are sticking in the while loop following While 1 If $ClickCount<20 Then ; !! This else is missing with an exit loop !! ; or you might change it to: If ClickCount = 20 Then ExitLoop ;code as follows ;-)) Stefan -
List Running Tasks on Remote Machine
99ojo replied to Naveed's topic in AutoIt General Help and Support
Hi, you try to check, if item 1 is selected. Therefore you only get True or False (i guess mostly false ) in your msgbox. See helpfile function _GUICtrlListView_GetItemSelected (). Try this: Func kill() $arselect = _GUICtrlListView_GetSelectedIndices ($in1, "True") If $select [0] = "" Then MsgBox (0,"Error", "No Selection") Else MsgBox(1,"",_GUICtrlListView_GetItemText($in1, $arselect [1]),5) EndIf EndFunc If you want to allow multi selection in your listview, you have to loop over array $arselect: For $i = 1 To $arselect [0] MsgBox(1,"",_GUICtrlListView_GetItemText($in1, $arselect [$i]),5) Next in the else tree. ;-)) Stefan -
Hi, changes: ;Opt("GUIOnEventMode", 1) Func createGUI() Global $hGUI = GUICreate("Input",350,150) GUICtrlCreateLabel("Enter the Row Number of the stream to be loaded :",10,20,250,75) Global $readedit = GUICtrlCreateInput(" ",270,15,75,20) GUICtrlCreateLabel("Select the Frequency to be set from the list:",10,50,250,75) Global $hCombo = GUICtrlCreateCombo("473", 270, 50, 75, 20) GUICtrlSetData(-1, "479|485|491|497|503|509|515|521|527|533|539|545|551|557|563|569|575|581|587|593|599|605|611|617|623|629|635|641|647|653|659|665|671|677|683|689|695|701|707|713|719|725|731|743|749|755|761|767", "") ; add other item snd set a new default Global $setvaluebuttn = GUICtrlCreateButton("Set Value",90,95,70) ;GUISetOnEvent(-1,"validate") Global $exitappbuttn = GUICtrlCreateButton("Exit",190,95,70) GUISetState() GUISetState(@SW_SHOW) EndFunc While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $setvaluebuttn validate () Case $msg = $exitappbuttn Exit EndSelect WEnd You should resort your code in a better way. It looks a little bit messy with your formats and coding style...... ;-)) Stefan
-
List Running Tasks on Remote Machine
99ojo replied to Naveed's topic in AutoIt General Help and Support
Hi, try this: #include <GUIConstantsEx.au3> #include <array.au3> ;Opt("GUIOnEventMode", 1) GUICreate("My GUI",600,600) GUISetState(@SW_SHOW) $test = GUICtrlCreateButton("List Tasks",20,20,100,100) ;GUICtrlSetOnEvent($test,"gettasks") $test2 = GUICtrlCreateButton("Kill Tasks",120,20,100,100) ;GUICtrlSetOnEvent($test2,"") ;GUISetOnEvent($GUI_EVENT_CLOSE,"exit1") $in = GUICtrlCreateInput("",20,130,200,200) Global $in1 = GUICtrlCreateListView("Tasks ",230,130,200,200) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $test gettasks () Case $msg = $test2 exit1 () EndSelect WEnd Func exit1() Exit EndFunc ;use gettask ("Hostname") to get processes from other computer Func gettasks($strComputer = "localhost") $count = 1 Local $arTasks [1] $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Process", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then Local $Object_Flag = 0 For $objItem In $colItems $Object_Flag = 1 ReDim $arTasks [$count] $arTasks [$count - 1] = $objItem.Caption $count += 1 ;GUICtrlCreateListViewItem ($objitem.Caption, $in1) ;if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop Next _ArraySort ($artasks) For $i = 0 To UBound ($artasks) - 1 GUICtrlCreateListViewItem ($artasks [$i], $in1) Next ;If $Object_Flag = 0 Then Msgbox(1,"WMI Output",$OutputTitle) Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Process" ) Endif EndFunc ;-)) Stefan -
[Solved] How to distinguish between file & folder ?
99ojo replied to goldenix's topic in AutoIt General Help and Support
Hi, yes there is. See FileGetAttrib ( ). ;-)) Stefan -
Yes indeed, there isn't.You haven't read my proposal to search forum, not helpfile, for _INetSmtpMailCom (), haven't you? ;-)) Stefan
-
Hi, 1) Did you see any param for password in function _INetSmtpMail () in helpfile? I don't. If you need authentication, search in forum for _INetSmtpMailCom (). 2) I don't know any script for receiving mail, sorry. ;-)) Stefan
-
Hi, this should work. The trick is reading last line of textfile and extracting the number to build new $trno. #Include <File.au3> Global $var1a, $var1b, $var2a, $var2b, $var3a, $var3b Global $trno, $message, $trnostart $message = "Hold down Ctrl or Shift to choose multiple files." $dir = FileOpenDialog($message, @ScriptDir & "\","File (*.ini)", 1 + 4) If @error Then MsgBox(4096,"","No File(s) chosen. Exit Program") Exit Else MsgBox(4096,"Confirm","You choose " & StringReplace($dir, "|", @CRLF)) EndIf $files = StringSplit ($dir, "|") $textfile = @ScriptDir & "\newtextfile.txt" If FileExists ($textfile) Then ;reading last line of textfile $temp = FileReadLine ($textfile, -1) ;Splitting string by ; $temp = StringSplit ($temp, ";") ;$temp [1] is "000xx", so replace 0 with nothing to get start value $trnostart = StringReplace ($temp [1], "0", "") EndIf For $i = 2 To $files [0] $var1a = IniRead($files [1] & "\" & $files [$i], "Test", "Date", "") $var1b = IniRead($files [1] & "\" & $files [$i], "Name", "") $var2a = IniRead($files [1] & "\" & $files [$i], "Test", "Acc1", "") $var2b = IniRead($files [1] & "\" & $files [$i], "Test", "Acc2", "") $var3a = IniRead($files [1] & "\" & $files [$i], "Test", "Tot1", "") $var3b = IniRead($files [1] & "\" & $files [$i], "Test", "Tot2", "") If $trnostart + $i - 1 < 10 Then $trno = "0000" & $trnostart + $i - 1 Else $trno = "000" & $trnostart + $i - 1 EndIf FileWriteLine($textfile, $trno & ";" & $var1a & ";" & $var1b & ";" & $var2a & ";" & $var3a) FileWriteLine($textfile, $trno & ";" & $var1a & ";" & $var1b & ";" & $var2b & ";" & $var3b) Next ;-)) Stefan @edit: Add $trnostart in variable declaration @edit: Sorry my code doesn't work for numbers like 10, 20 100 and so on. Rewrite part If FileExists: If FileExists ($textfile) Then ;reading last line of textfile $temp = FileReadLine ($textfile, -1) ;Splitting string by ; $temp = StringSplit ($temp, ";") For $i = 1 To StringLen ($temp [1]) ;Find 1 to 9, If found, $trnostart is $temp [1] at position $i to end of string If StringRegExp (StringMid ($temp [1], $i, 1), "[1-9]") Then $trnostart = StringMid ($temp [1], $i, StringLen ($temp [1]) - $i + 1) ExitLoop EndIf Next EndIf also changed as follows in For .. Loop to write output file: FileWriteLine($textfile, $trno & ";" & $var1a & ";" & $var1b & ";" & $var2a & ";" & $var3a) FileWriteLine($textfile, $trno & ";" & $var1a & ";" & $var1b & ";" & $var2b & ";" & $var3b)
-
Hi, #Include <File.au3> Global $var1a, $var1b, $var2a, $var2b, $var3a, $var3b Global $trno, $message, $files $message = "Hold down Ctrl or Shift to choose multiple files." $dir = FileOpenDialog($message, @ScriptDir & "\","File (*.ini)", 1 + 4) If @error Then MsgBox(4096,"","No File(s) chosen. Exit Program") Exit Else MsgBox(4096,"Confirm","You choose " & StringReplace($dir, "|", @CRLF)) EndIf ;Splitting string by delimiter "|" into array $files, $files [0] -> array elements, $files [1] -> Path to chosen files ;$files [2.........] -> Filenames $files = StringSplit ($dir, "|") ;define outputfile $textfile = @ScriptDir & "\newtextfile.txt" ;loop over $files array starting with 1.st chosen file For $i = 2 To $files [0] $var1a = IniRead($files [1] & "\" & $files [$i], "Test", "Date", "") $var1b = IniRead($files [1] & "\" & $files [$i], "Name", "") $var2a = IniRead($files [1] & "\" & $files [$i], "Test", "Acc1", "") $var2b = IniRead($files [1] & "\" & $files [$i], "Test", "Acc2", "") $var3a = IniRead($files [1] & "\" & $files [$i], "Test", "Tot1", "") $var3b = IniRead($files [1] & "\" & $files [$i], "Test", "Tot2", "") $trno = "0000" & $i - 1 FileWriteLine($textfile, $trno & ";" & $var1a & ";" & $var1b & ";" & $var2b & ";" & $var3b) Next ; show output file ShellExecute ("notepad.exe", $textfile) ;-)) Stefan @edit: Missed the numbering part in the post. Changed line $trno = "0000" & $i to $trno = "0000" & $i - 1 in post
-
Hi, where's the problem, if you know how to: Reading 1st ini and write values to textfile with 001. Reading 2nd ini and write values to textfile with 002. If you have problems with your code, you should post it.... ;-)) Stefan
-
Hi, this should work: ;Get environment variable %server% $server = EnvGet ("Server") ; if %server% = teste DriveMapAdd ("I:", "\\" & $server & "\cid") ;-)) Stefan
-
Hi, the sauce for the fries (frittjes special...) Some paste and copy error, formerly in school we call it transfer task. S ince you post not all of your code, my glasbowl shows me: If @error Then MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc) Else ;MsgBox(0, "Error!", "Mail failed with error code " & $err) -> paste and copy error... MsgBox (0,"Success!", "Sucessfully sent Mail!") EndIf ;-)) Stefan
-
Hi, try this and put in Username and password: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> ;#include <INet.au3> #Include<file.au3> #Region ### START Koda GUI section ### Form= Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") Dim $as_Body[2] $s_SmtpServer = "smtp.gmail.com" $s_FromName = "My Name" $s_FromAddress = "mymail@gmail.com" $s_ToAddress = "mymail@gmail.com" $Importance ="Normal" $Username = "******" ; username for the account used from where the mail gets sent - REQUIRED -> put in your gmail account user $Password = "********" ; password for the account used from where the mail gets sent - REQUIRED -> the password for user above $IPPort=465 ; GMAIL port used for sending the mail $ssl=1 $Form1 = GUICreate("Mail Tester v1.0", 200, 150) $Input1 = GUICtrlCreateInput("", 64, 24, 121, 21) $s_Subject = GUICtrlCreateLabel("Subject:", 23, 27, 36, 17) $Line1 = GUICtrlCreateInput("", 64, 56, 121, 21) $Label2 = GUICtrlCreateLabel("Line1:", 30, 59, 28, 17) $Line2 = GUICtrlCreateInput("", 64, 80, 121, 21) $Label3 = GUICtrlCreateLabel("Line2:", 30, 84, 28, 17) $Button1 = GUICtrlCreateButton("Send", 112, 110, 73, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $as_Body[0] = GUICtrlRead($Line1) $as_Body[1] = GUICtrlRead($Line2) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ;$Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) ;$err = @error $rc = _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, GuiCtrlRead ($s_Subject), $as_Body, "", "", "", $Importance, $Username, $Password, $IPPort, $ssl) If @error Then MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc) Else MsgBox(0, "Error!", "Mail failed with error code " & $err) EndIf EndSwitch WEnd Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0) Local $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress $objEmail.Subject = $s_Subject If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf If $s_AttachFiles <> "" Then Local $S_Files2Attach = StringSplit($s_AttachFiles, ";") For $x = 1 To $S_Files2Attach[0] $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x]) ;~ ConsoleWrite('@@ Debug : $S_Files2Attach[$x] = ' & $S_Files2Attach[$x] & @LF & '>Error code: ' & @error & @LF) ;### Debug Console If FileExists($S_Files2Attach[$x]) Then ConsoleWrite('+> File attachment added: ' & $S_Files2Attach[$x] & @LF) .AddAttachment($S_Files2Attach[$x]) Else ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF) SetError(1) Return 0 EndIf Next EndIf $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer If Number($IPPort) = 0 then $IPPort = 25 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort ;Authenticated SMTP If $s_Username <> "" Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password EndIf If $ssl Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True EndIf ;Update settings $objEmail.Configuration.Fields.Update ; Set Email Importance Switch $s_Importance Case "High" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High" Case "Normal" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal" Case "Low" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low" EndSwitch $objEmail.Fields.Update ; Sent the Message $objEmail.Send If @error Then SetError(2) Return $oMyRet[1] EndIf $objEmail="" EndFunc ;==>_INetSmtpMailCom ; ; ; Com Error Handler Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) $oMyRet[0] = $HexNumber $oMyRet[1] = StringStripWS($oMyError.description, 3) ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF) SetError(1); something to check for when this function returns Return EndFunc ;==>MyErrFunc ;-)) Stefan @edit: Reviewing code you might try: Global $as_body.... $as_body = GuiCtrlRead ($line1) & @CRLF & GuiCtrlRead ($line2) instead of Global $as_body [2].... $as_Body[0] = GUICtrlRead($Line1) $as_Body[1] = GUICtrlRead($Line2)
-
Hi, you have to authenticate before sending. See this post and take the _INetSmtpMailCom () function. http://www.autoitscript.com/forum/index.php?showtopic=96313&st=0&p=692425&hl=smtp%20gmailcom&fromsearch=1&#entry692425 ;-)) Stefan Tip: I found this in forum search with smtp gmail.com.....
-
Hi, if you want to shutdown computer, have a look at helpfile: Function shutdown (). If you want to do something else or if you have other problems, be mor precise. ;-)) Stefan
-
Check multiple admin accounts with isadmin?
99ojo replied to EricL's topic in AutoIt General Help and Support
Hi, have a look at helpfile. Code with the return values. Success: The PID of the process that was launched. Failure: Returns 0 and sets @error to non-zero. -> Start second try with second password... That's what Psalty's code does. Change the else tree to a second RunAs with the second password. Just get the returns of RunAs and recode. ;-)) Stefan P.S: Heading for soup..... -
Login to server thats locked and run script
99ojo replied to happy2help's topic in AutoIt General Help and Support
Hi, if you google for "unlock screensaver logon.exe" you will find a link for an unlocking tool. ;-)) Stefan