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

error! attaching multiple files to email

$
0
0
AutoIt         
#Include<file.au3> Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $s_SmtpServer = "smtp.Gmail.com" ; address for the smtp-server to use - REQUIRED $s_FromName = "test" ; name from who the email was sent $s_FromAddress = "copperman2@Gmail.com" ; address from where the mail should come $s_ToAddress = "copperman2@Gmail.com" ; destination address of the email - REQUIRED $s_Subject = "test2" & @YEAR & @MON & @MDAY & "--" & @MIN & @SEC ; subject from the email - can be anything you want it to be $as_Body = "" ; the messagebody from the mail - can be left blank but then you get a blank mail $s_AttachFiles = "C:\Windows\Help\log\001.bmp;C:\Windows\Help\log\002.bmp" ; the file you want to attach- leave blank if not needed $s_CcAddress = "" ; address for cc - leave blank if not needed $s_BccAddress = "" ; address for bcc - leave blank if not needed $s_Username = "**********" ; username for the account used from where the mail gets sent - Optional (Needed for eg GMail) $s_Password = "********" ; password for the account used from where the mail gets sent - Optional (Needed for eg GMail) $IPPort = 465 ; port used for sending the mail $ssl = 1 ; enables/disables secure socket layer sending - put to 1 if using httpS ;~ $IPPort=465 ; GMAIL port used for sending the mail ;~ $ssl=1 ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS ;################################## ; Script ;################################## Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $rc = _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl) If @error Then MsgBox(0, "Error sending message", "Error code:" & @error & " Rc:" & $rc) EndIf Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Username = "", $s_Password = "",$IPPort=25, $ssl=0) $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]) If FileExists($S_Files2Attach[$x]) Then $objEmail.AddAttachment ($S_Files2Attach[$x]) Else $i_Error_desciption = $i_Error_desciption & @lf & 'File not found to attach: ' & $S_Files2Attach[$x] 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 $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 ; Sent the Message $objEmail.Send if @error then SetError(2) return $oMyRet[1] EndIf 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
@@ Debug(62) : $S_Files2Attach = 
>Error code: 0
@@ Debug(62) : $S_Files2Attach = 
>Error code: 0
 
>Process failed to respond; forcing abrupt termination...
>Exit code: 1    Time: 96.047
 
help please

Text file stripping by string length

$
0
0
I'm looking for the best way to strip a very large file (1+ gig) of all lines with characters less than 6 characters.

I know of filereadline and strlen

I would like to iterate through the entire file (using a buffer) that will rewrite the good characters to a new file in the quickest most effecient way possible.

Doess anyone have an open API or an algorithm free to use? my current code is rather slow and ineffecient..

thanks in advance!


so far it goes like this:
filereadline x if strlen >= 6 then addtobuffer if buffersize >= buffermaxssize then _writebufferandflushit endif
(not actual code but it gets the logic across.)

im using filereadline so i dont have to load the entire text file to memory.

Comparison operator

$
0
0

Suppose $a = 1.2.3.4

$b =  1.2.3.4

 

I just want to compare these values i.e.

 

I am using == operator like

 

if $a == $b Then

 

msgbox(0,0,"pass")

 

else

 

msgbox(0,0,"fail")

 

But it is showing fail however both the vales are equal

 

 

 

help? delay key to Hotkey

$
0
0

be I  wants the checkpoint below  can use  Hotkey  be formed fix  the expansion is /  decrease  the speed in decorating replace using  Sleep()  because  if  we set  Fix  the speed gets down  it affects with other that the intensity of and the speed of the internet  rough

such as  I uses  Hotkey {Home}  press for enhance giving fast goes up to follow the amount time at presses  and  use  hotkey {End}  press for decrease giving slow down decorate follow the amount time that press

While 1     ControlClick($GameHD, "", "", "left", 1, 740, 581)     ControlClick($GameHD, "", "", "left", 1, 750, 583)     ControlClick($GameHD, "", "", "", 2, 397, 481)     ControlClick($GameHD, "", "", "left", 2, 400, 350)     ControlClick($GameHD, "", "", "left", 2, 400, 347) WEnd

soory I am not good english

Why window info Class alway change

$
0
0
I want get handle of windown printer of VB, but class windown alway change when I open again, ex1: CLASS:Afx:40000000:b:10011:6:452c08cd, ex2: CLASS: Afx:40000000:xxxxxxxxxxx. How i can get handle it. Best regards

example method 3

scrip for online game

$
0
0

I have a script for an online game.But it doesn't work.Is there anybody to help me?

 

Regards

Help with ER

$
0
0

Hi folks, I have a problem. I need that with regular expressions, you can replace "x^x" with "x" (where x is any letter) and also need to replace "xy" with "x" (where x, y are any letter)

For example: p^p = p, q^q = q, r^r=r, etc etc.
qq = q

 

I need to check that $1 and $2 are the same, in order to replace the expression for $1 or $2 (in this case is the same)

$inputExpresion = StringRegExpReplace($inputExpresion, "([a-z])^([a-z])", "??????")

 

and

 

How do I verify that the previous character is the same as that continues and so replace the two, with one.

StringRegExpReplace($inputExpresion, "([a-z])+", "?????")

 

 

any solution? Thanks


StdoutRead / StderrRead for RunWait(@ComSpec

$
0
0

Hey,

 

im trying to read the output from a cmd window so I can create an if/else statement for if it errors or is successful, but at the moment I can get the output.

 

Also oddly enough when I put ', $STDERR_CHILD + $STDOUT_CHILD' at the end of the first line, it stops the cmd window from staying open when the switch is set to /c which should keep the window open when its finished, if you remove ', $STDERR_CHILD + $STDOUT_CHILD' then the window stays open like it should

 

Anyone got any ideas?

Local $iPID = RunWait(@ComSpec & " /c " & 'adb tcpip 5555', @SystemDir, @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD) Local $sOutput = "" $sOutput = StdoutRead($iPID) MsgBox($MB_SYSTEMMODAL, "Stdout Read:", $sOutput) $sOutput = StderrRead($iPID) MsgBox($MB_SYSTEMMODAL, "Stderr Read:", $sOutput)

Execute items in for-next loop in random order

$
0
0
Hello everyone

Suppose I have a for-next loop like this:
 
For $i = 1 to 9 ; Do something that involves $i Next
But I don't want $i to go from 1 to 9 in numerical order, but instead I want $i to use the range 1 to 9 randomly (or semi-randomly), and use every number only once, how would I do that?

In other words, instead of letting $i be this:
1 then 2 then 3 then 4 then 5 etc
I want it $i to be e.g. this:
2 then 5 then 7 then 9 then 4 etc
using each of the items 1 to 9 only once.

It doesn't have to be a for-next loop if there is a better way of doing it. The application of this is to read a file with e.g. 9 lines in it, in which I do something with each of the lines (one line at a time) in random order.

If you could just point me in the right direction, please...

Thanks
Samuel

Added: Oh, in this example I used "1 to 9" but the actual file I'm going to process will have about 10 000 lines.

-0 bug

$
0
0

 If we trying to round a very small negative number using decimal places parameter, we will got a -0 as result. After parsing, autoit interprets  this number as a value, that lesser then zero.

 So I can use this as example:
ConsoleWrite(round(cos(270 * (3.141592653589793 / 180)),4))

We know, that cosine of 270 degrees obviously equals 0, but here we got -0.

In this code you can see, how it can a bit screw up our calculations:

;~ Radius of a circle
$radius = 35


   for $i = 0 to 360
      ;~ Here we found positions on a circle using cosins of an angle for X and sine for Y
      $x = Round((Cos(DTR($i)) * $radius), 4)
      $y = Round((Sin(DTR($i)) * $radius), 4)

;~       Here we output our values of true degrees, X and Y positions.
      ConsoleWrite($i & " " & $x & " / " & $y & " ")
      
;~       Here we trying to ouput degrees using arctangent of Y/X (Which is tangent of our angle)
      ConsoleWrite(Round(RTD(ATan($y / $x),$x,$y)) & @LF)
      
   Next

;~ Degrees to radians
Func DTR($deg)
   Return $deg * (3.141592653589793/180)
EndFunc

;~ Radians to degrees
Func RTD($rad, $x, $y)
   if $x >= 0 and $y >= 0 Then
      Return $rad *(180/3.141592653589793)
   Elseif $x < 0 Then
      Return $rad *(180/3.141592653589793) + 180
   Else
      Return $rad *(180/3.141592653589793) + 360
   EndIf
EndFunc

As you can see, on angles 270 and 360 this code ouputs wrong values of angles.

Runwait always returns @error value of 0

$
0
0

Regardless of if the command is successful or the reason of it failing, i always get an error code of 0

        Local $iPID = RunWait(@ComSpec & " /k " & 'adb connect ' & $var_ipaddress, @SystemDir, @SW_SHOW) $var = @error         MsgBox(4096, "err", $var)

Why is it when it passes through successfully i still get an error code of 0?

Script help

$
0
0

Hi

 

thanks in advance :D

 

Can one of you hardcore guys see way may script go's wrong.

 

it's my $input i can't get to continue and insert it in the Run line.

 

I have use the line $rc=_rundos 3 years ago and it worked whit the $input line, but alot have change :huh2:.

 

i'm no big programer so i tryed this.

Plain Text         
#include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Opt("GUIOnEventMode", 1) Global $ExitID, $input _Main() Func _Main()     Local $imagesID, $installID     GUICreate("Fineman Imaging", 310, 80)     GUICtrlCreateLabel("Please select a action!", 10, 10)     $ImagesID = GUICtrlCreateButton("Images", 10, 50, 50, 20)     GUICtrlSetOnEvent($imagesID, "OnYes")     $installID = GUICtrlCreateButton("Install", 80, 50, 50, 20)     GUICtrlSetOnEvent($installID, "OnNo")     $ExitID = GUICtrlCreateButton("Exit", 150, 50, 50, 20)     GUICtrlSetOnEvent($ExitID, "OnExit")     GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit")     GUISetState()  ; display the GUI     While 1         Sleep(1000)     WEnd EndFunc   ;==>_Main ;--------------- Functions --------------- Func OnYes() DriveMapAdd("y:", "\\10.0.1.17\public\teknik_images\ibase", 0)     Local $iLoop = 1              While $iLoop = 1                      $input = InputBox("Image name", "Enter path and file name")                         If @error = 1 Then                            MsgBox(4096, "Error", "You pressed 'Cancel' - try again!")                         Else                            if $input = FileExists("y:\'& $input'.gho") Then     Else          $iLoop = 0     EndIf EndIf WEnd Run(@ComSpec & " /C " & 'Ghost64.exe -clone,mode=restore,src=\\10.0.1.17\public\teknik_images\ibase\'& $input'.gho,dst=1 -sure -auto',"") If @error = 0 Then                            MsgBox(4096, "Error", "error") EndIf drivemapdel ("Y:") EndFunc   ;==>OnYes to image Func OnNo()     DriveMapAdd("y:", "\\10.0.1.17\public\teknik_images\ibase", 0)      $input = InputBox("Image install name", "Enter file name")         If @error = 1 Then             MsgBox(4096, "Error", "You pressed 'Cancel' - try again!") EndIf Run(@ComSpec & " /C " & 'Ghost64.exe -clone,mode=create,src=1,dst=\\10.0.1.17\public\teknik_images\ibase\'& $input' -sure -auto',"") If @error = 0 Then                            MsgBox(4096, "Error", "error") EndIf drivemapdel ("Y:") EndFunc   ;==>OnNo Func OnExit()     If @GUI_CtrlId = $ExitID Then         MsgBox(64, "Exit", "Imaging Canceled")     Else         MsgBox(64, "Cancel", "Action Canceled")     EndIf     Exit EndFunc   ;==>OnExit

Insert and delete columns in a 2d array?

$
0
0

Is there an easy way to delete and insert columns in specific rows in a 2d array without affecting the cols of the other rows?

Since my english is not good enough to get across what i need to do, i'm going to post a snippet to help visualize what i need to do:

AutoIt         
#include <Array.au3> Local $avArray[3][4] $avArray[0][0] = "Col1 Row1" $avArray[1][0] = "Col1 Row2" $avArray[2][0] = "Col1 Row3" $avArray[0][1] = "Col2 Row1" $avArray[1][1] = "Col2 Row2" $avArray[2][1] = "Col2 Row3" $avArray[0][2] = "Col3 Row1" $avArray[1][2] = "Col3 Row2" $avArray[2][2] = "Col3 Row3" _ArrayDisplay($avArray, "Original Array") ;delete a col in a row $avArray[1][1] = "Col3 Row2" $avArray[1][2] = "" _ArrayDisplay($avArray, "Col2 in Row2 removed, Col3 -> Col2, rest untouched") ;insert a col in a row $avArray[2][2] = "New entry" $avArray[2][3] = "Col3 Row2" _ArrayDisplay($avArray, "New entry in Row3 Col3, old Col3 -> Col4")

I hope you understand what i mean. 

Script to change regedit with user input

$
0
0

Hi friends!

 

I'm a little bit stuck in the automatic image installation at the company I'm working for.

 

The script I'll have to create should basically be a script where the user(or me) can input their domain name and password which can be stored in a format where I then can execute it and enter it in the registry at first boot.

 

Registry entries are: 

reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d youruser (Changed by user input)
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /t REG_SZ /d yourpassword (Changed by user input)
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultDomainName /t REG_SZ /d yourdomain (Not changed)
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 1 (Not changed)
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoLogonCount /t REG_DWORD /d 1 (Not changed)
 
These should be stored temporary(Preferable on the local harddrive the image is installed on) and then when executed deleted.
 
Is anyone familiar with these kind of scripts?
Best Regards
Andreas :)

How to handle the window twice

$
0
0
For $i = 1 To 10         If WinExists("My window") Then         ControlClick("My window","NO","[CLASS:Button; INSTANCE:1]")         Sleep(2000)         WinWaitActive("Check your window","test: yahoo.com",2)         ControlClick("Check your window","test: yahoo.com","Button2") ExitLoop         EndIf         Sleep(1000)         Next

Some time "My window" is pop up 1 time and some time it is pop up twice.

The above code handle this window "My window" successfully for the 1st time its thrown but when it occurs 2nd time it unable to handle it.

Please provide some refactoring for the above code so that it can handle the pop up window "My window" 2 times

_IETagNameGetCollection problem

Unable to process successive ControlClicks

$
0
0

Hello,

I for some time developing with AutoIt and I met a weird problem . I searched the forum , not perhaps enough and have found no satisfactory answer.

I try to " check" certain checkboxes in the next window (see capture below), however ALL the boxes are the same INSTANCE and the same CONTROL ID, so I only have the position to manage the problem ,so ControlClick .
Here is the relevant snippet :
 

  1. Global $APPDATA = "Installation de ITESOFT FreeMind 1.9.5!Poste de numérisation!Langue de l'assistant d'installation![CLASS:TNewCheckListBox; INSTANCE:1]"
  2. $appinstall = StringSplit($APPDATA, "!") ;Liste d'arguments fenêtre et contrôles à utiliser pour les clics
  3.  
  4. WinWaitActive($appinstall[1], $appinstall[2])
  5. ;~ MouseClick("left", 53, 184)
  6. ControlClick($appinstall[1], $appinstall[2], "[CLASS:TNewCheckListBox; INSTANCE:1]", "left", 1, 10, 26)
  7. ;~ MouseClick("left", 53, 200)
  8. ControlClick($appinstall[1], $appinstall[2], "[CLASS:TNewCheckListBox; INSTANCE:1]", "left", 1, 10, 41)
  9. ;~ MouseClick("left", 53, 215)
  10. ControlClick($appinstall[1], $appinstall[2], "[CLASS:TNewCheckListBox; INSTANCE:1]", "left", 1, 10, 58)
  11. ;~ MouseClick("left", 53, 232)
  12. ControlClick($appinstall[1], $appinstall[2], "[CLASS:TNewCheckListBox; INSTANCE:1]", "left", 1, 10, 74)
  13. ;~ MouseClick("left", 53, 262)
  14. ControlClick($appinstall[1], $appinstall[2], "[CLASS:TNewCheckListBox; INSTANCE:1]", "left", 1, 10, 105)
  15. ;~ MouseClick("left", 53, 280)
  16. ControlClick($appinstall[1], $appinstall[2], "[CLASS:TNewCheckListBox; INSTANCE:1]", "left", 1, 10, 120)

Following, data capture of the active window

HowToCheckThis.jpg

 

Result: only the first box is checked, if I comment the first ControClick, it is the next to be checked, so it is that the code works ... but individually..
I tried to separate them by a SLEEP (XXXX), same result, only the first uncommented ControlClick works..

Question: how to make them all work or are there a way around the problem ( Mouseclick does not work )

Environment : WIN7 32bit AutoIt v3.3.10.1 2014 Scite 3.3.7.0

Thank you in advance for your advice (PS: excuse my poor english ^_^ )
 

 

StringStripWS Bug?

$
0
0

Small chance i'm too tired to think straight, but I do believe this is a bug.

 

I was reading strings from a file which were 32 bytes in length. Padded with 00's

 

So I thought i'd strip off the exess with StringStripWS. Which docs say can strip CHR(0) as whitespace.

 

Not working, here's a modified from the Example that Duplicates the problem.

All whitespace removed exept the Null Char.

 

#include <StringConstants.au3> #include <MsgBoxConstants.au3> ; Strip leading and trailing whitespace as well as the double spaces (or more) in between the words. Local $sString = "Thisisasentencewithwhitespace." & CHR(0) ConsoleWrite(StringLen($sString) & @CRLF) $sString = StringStripWS($sString, $STR_STRIPTRAILING) ConsoleWrite(StringLen($sString) & @CRLF)
 
Prints to console size of the string before and after as 31.  No Changes.

Mouse Click position changes while recording the screen entry

$
0
0

Hi,

            I am trying to enter the bulk of data hundred of records through spread sheet into my entry screen by simply recording the first entry and then using this recording in autoit passing the fields from spread sheet in send method or by mouse clicking to populate field and hit save button. I am recording my first entry and then using loop to repeat same recording for all the records reading from spreadsheet. My Mouseclick is not working fine and after saving two or three records it start skipping some fields.

 

Any suggestions will be appreciated.

 

Thanks

Viewing all 12506 articles
Browse latest View live


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