Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/21/2025 in all areas

  1. Numeric1

    The Taquin Puzzle

    Taquin The Taquin is a solitary puzzle game, popular since the late 19th century, that challenges the player's logic and patience. This code implements a digital version of the Taquin, where the goal is to rearrange a set of 15 numbered tiles from 1 to 15 into ascending order by moving the tiles one at a time, in a frame of 16 spaces. The game is played on a simple and intuitive graphical interface. Goal of the Game The goal of Taquin is to rearrange the 15 tiles into numerical order (from 1 to 15), with an empty space, starting from a randomly shuffled configuration. The player must move the tiles using the empty space by clicking on tiles adjacent to the empty space. Game Features Graphical Interface (GUI): The game uses AutoIt to create a simple graphical interface, where the game board consists of 15 numbered tiles. The interface allows the user to see the tiles and easily move them to solve the puzzle. Game Mechanics: Tiles can only be moved if they are adjacent to the empty space. By clicking on a tile, it moves into the empty space, and the game updates the display after each move. Solution Verification: The game continuously checks if the tiles are in the correct order, and a victory notification is displayed when the tiles are correctly arranged. Random Shuffle: At the start of the game, the tiles are randomly arranged to create a different challenge with each game. Ease of Use: The game is designed to be simple to use, with controls based on mouse clicks to move the tiles. Game Rules Tile Movement: A player can move a tile by clicking on it if it is adjacent to the empty space. The objective is to move the tiles into ascending order. Solution: The game ends when the tiles are arranged in the following order: 1, 2, 3, ..., 15, with the empty space at the end. History of the Game The Taquin was invented in the United States around 1870, before being popularized in Europe and becoming widely recognized. The invention was claimed by Sam Loyd in 1891, when the game became a global phenomenon. It is now a classic among puzzle games. #include-once #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include "AutoItObject.au3" #include <Array.au3> ; #INDEX# ======================================================================================================================= ; Title .........: Puzzle Game ; AutoIt Version : 3.3 ; AutoItObject Version : v1.2.8.2 ; Language ......: English ; Description ...: This script implements a puzzle game using AutoIt and AutoItObject.au3. ; Dependencies ..: AutoItObject.au3, GDIPlus.au3 ; Author ........: Numeric ; ======================================================================================================================= ; Game Overview: ; - The game consists of a grid of tiles. ; - The objective is to arrange the tiles in numerical order by swapping them. ; - The game ends when all tiles are correctly arranged. ; - Tiles are shuffled randomly at the start, and the player can interact with them via mouse clicks. ; Controls: ; - Mouse Click: Select a tile to move. ; - Tiles swap when an adjacent empty tile is clicked. ; Enjoy solving the puzzle! ; ======================================================================================================================= _AutoItObject_Startup() _GDIPlus_Startup() ; Classe Ligne Func CreateLine($startX, $startY, $endX, $endY, $color = 0xFF00FF00, $thickness = 1) If $color = Default Or $color = "" Or Not $color Then $color = 0xFF00FF00 Local $lineObject = _AutoItObject_Class() With $lineObject .AddProperty("StartX", $ELSCOPE_PUBLIC, $startX) .AddProperty("StartY", $ELSCOPE_PUBLIC, $startY) .AddProperty("EndX", $ELSCOPE_PUBLIC, $endX) .AddProperty("EndY", $ELSCOPE_PUBLIC, $endY) .AddProperty("Color", $ELSCOPE_PUBLIC, $color) .AddProperty("Thickness", $ELSCOPE_PUBLIC, $thickness) EndWith Return $lineObject.Object EndFunc ;==>CreateLine Func CreateTile($xPosition, $yPosition, $size, $color = 0xFFFFFFFF) Local $squareObject = _AutoItObject_Class() Local $radius = $size / 2 Local $lines[0] With $squareObject .Create() .AddProperty("Lines", $ELSCOPE_PUBLIC, $lines) .AddProperty("Type", $ELSCOPE_PUBLIC, "Square") .AddProperty("Number", $ELSCOPE_PUBLIC, 0) .AddProperty("X", $ELSCOPE_PUBLIC, $xPosition) .AddProperty("Y", $ELSCOPE_PUBLIC, $yPosition) .AddProperty("Size", $ELSCOPE_PUBLIC, $size) .AddProperty("Color", $ELSCOPE_PUBLIC, $color) .AddProperty("CircleRadius", $ELSCOPE_PUBLIC, $radius) .AddMethod("AddLine", "AddLineToSquare") .AddMethod("DisplayNumber", "DisplayNumberOnSquare") .AddMethod("Move", "MoveSquare") .AddMethod("Resize", "ResizeSquare") .AddMethod("CheckCollision", "CheckSquareCollision") .AddMethod("ContainsPoint", "PointInsideSquare") EndWith Return $squareObject.Object EndFunc ;==>CreateTile Func AddLineToSquare($this, $line) Local $lineArray = $this.Lines _ArrayAdd($lineArray, $line) $this.Lines = $lineArray EndFunc ;==>AddLineToSquare Func DisplayNumberOnSquare($this, $number) Local $lineArray[0] $this.Lines = $lineArray If $number = 0 Then $number = "" Local $segmentSize = $this.Size / 3 Local $centerX = $this.X + ($this.Size / 2) Local $centerY = $this.Y + ($this.Size / 2) Local $segmentPatterns[10][7] = [ _ [1, 1, 1, 1, 1, 1, 0], _ ; 0 [0, 1, 1, 0, 0, 0, 0], _ ; 1 [1, 1, 0, 1, 1, 0, 1], _ ; 2 [1, 1, 1, 1, 0, 0, 1], _ ; 3 [0, 1, 1, 0, 0, 1, 1], _ ; 4 [1, 0, 1, 1, 0, 1, 1], _ ; 5 [1, 0, 1, 1, 1, 1, 1], _ ; 6 [1, 1, 1, 0, 0, 0, 0], _ ; 7 [1, 1, 1, 1, 1, 1, 1], _ ; 8 [1, 1, 1, 1, 0, 1, 1] _ ; 9 ] Local $segmentCoords[7][4] = [ _ [-0.4, -0.4, 0.4, -0.4], _ ; Haut [0.4, -0.4, 0.4, 0.0], _ ; Haut-droite [0.4, 0.0, 0.4, 0.4], _ ; Bas-droite [-0.4, 0.4, 0.4, 0.4], _ ; Bas [-0.4, 0.0, -0.4, 0.4], _ ; Bas-gauche [-0.4, -0.4, -0.4, 0.0], _ ; Haut-gauche [-0.4, 0.0, 0.4, 0.0] _ ; Milieu ] Local $currentOffsetX = -($segmentSize * (StringLen($number) - 1) / 2) For $digitIndex = 0 To StringLen($number) - 1 Local $digit = Number(StringMid($number, $digitIndex + 1, 1)) For $segmentIndex = 0 To 6 If $segmentPatterns[$digit][$segmentIndex] Then Local $x1 = $centerX + $currentOffsetX + $segmentCoords[$segmentIndex][0] * $segmentSize Local $y1 = $centerY + $segmentCoords[$segmentIndex][1] * $segmentSize Local $x2 = $centerX + $currentOffsetX + $segmentCoords[$segmentIndex][2] * $segmentSize Local $y2 = $centerY + $segmentCoords[$segmentIndex][3] * $segmentSize $this.AddLine(CreateLine($x1, $y1, $x2, $y2, Default, 2)) EndIf Next $currentOffsetX += $segmentSize * 1.2 Next EndFunc ;==>DisplayNumberOnSquare Func PointInsideSquare($this, $pointX, $pointY) Return ($pointX >= $this.X And $pointX <= $this.X + $this.Size) And _ ($pointY >= $this.Y And $pointY <= $this.Y + $this.Size) EndFunc ;==>PointInsideSquare Func CheckSquareCollision($this, $otherSquare) If $this.Type = "Square" And $otherSquare.Type = "Square" Then Local $isAdjacentHorizontally = ($this.Y = $otherSquare.Y And $this.Size = $otherSquare.Size) And _ (($this.X + $this.Size = $otherSquare.X) Or ($this.X = $otherSquare.X + $otherSquare.Size)) Local $isAdjacentVertically = ($this.X = $otherSquare.X And $this.Size = $otherSquare.Size) And _ (($this.Y + $this.Size = $otherSquare.Y) Or ($this.Y = $otherSquare.Y + $otherSquare.Size)) Return $isAdjacentHorizontally Or $isAdjacentVertically EndIf Return False EndFunc ;==>CheckSquareCollision Func CreatePuzzleGame($backgroundColor = 0xFF0000FF) Local $window = GUICreate("Puzzle Game", 400, 400) GUISetState() Local $windowSize = WinGetClientSize($window) Local $windowWidth = $windowSize[0] Local $windowHeight = $windowSize[1] Local $graphicsContext[] $graphicsContext["Graphics"] = _GDIPlus_GraphicsCreateFromHWND($window) $graphicsContext["Bitmap"] = _GDIPlus_BitmapCreateFromGraphics($windowWidth, $windowHeight, $graphicsContext["Graphics"]) $graphicsContext["GraphicsObject"] = _GDIPlus_ImageGetGraphicsContext($graphicsContext["Bitmap"]) $graphicsContext["BackgroundBrush"] = _GDIPlus_BrushCreateSolid($backgroundColor) Local $tileSize = Int($windowWidth / 4) Local $tiles[] Local $index = 0 Local $numbers[16] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 10, 11, 12, 13, 14, 15] _ArrayShuffle($numbers) For $row = 0 To 3 For $col = 0 To 3 Local $tile = CreateTile($col * $tileSize, $row * $tileSize, $tileSize) $tile.Number = $numbers[$index] $tile.DisplayNumber($tile.Number) $index += 1 $tiles[$index] = $tile Next Next Local $game = _AutoItObject_Class() With $game .Create() .AddProperty("Tiles", $ELSCOPE_PUBLIC, $tiles) .AddProperty("GraphicsContext", $ELSCOPE_PUBLIC, $graphicsContext) .AddProperty("Window", $ELSCOPE_PUBLIC, $window) .AddProperty("WindowWidth", $ELSCOPE_PUBLIC, $windowWidth) .AddProperty("WindowHeight", $ELSCOPE_PUBLIC, $windowHeight) .AddMethod("Render", "RenderPuzzle") .AddMethod("Reset", "ResetPuzzle") .AddMethod("CheckVictory", "VerifyWinCondition") .AddMethod("Run", "StartGameLoop") .AddMethod("HandleClick", "ProcessMouseClick") .AddMethod("GetTileAtPosition", "FindTileAtCoordinates") .AddMethod("GetEmptyAdjacentTile", "FindEmptyNeighbor") .AddMethod("SwapTiles", "ExchangeTiles") .AddMethod("UpdateDisplay", "RefreshDisplay") .AddDestructor("ReleaseResources") EndWith Return $game.Object EndFunc ;==>CreatePuzzleGame Func StartGameLoop($this) Local $msg While 1 $msg = GUIGetMsg(1) Switch $msg[0] Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_PRIMARYDOWN $this.HandleClick($msg[3], $msg[4]) $this.Render() EndSwitch $this.Render() WEnd EndFunc ;==>StartGameLoop ; Gestion des clics de souris Func ProcessMouseClick($this, $x, $y) Local $clickedTileIndex = $this.GetTileAtPosition($x, $y) If Not $clickedTileIndex Then Return Local $emptyTileIndex = $this.GetEmptyAdjacentTile($clickedTileIndex) If $emptyTileIndex Then $this.SwapTiles($clickedTileIndex, $emptyTileIndex) $this.UpdateDisplay() If $this.CheckVictory() Then MsgBox(0, "Congratulations!", "You have solved the puzzle") $this.Reset() EndIf EndIf EndFunc ;==>ProcessMouseClick ; Trouve une tuile à une position donnée Func FindTileAtCoordinates($this, $x, $y) For $tileKey In MapKeys($this.Tiles) Local $tile = $this.Tiles[$tileKey] If $tile.ContainsPoint($x, $y) Then Return $tileKey EndIf Next Return Null EndFunc ;==>FindTileAtCoordinates ; Trouve une tuile vide adjacente Func FindEmptyNeighbor($this, $tileKey) Local $currentTile = $this.Tiles[$tileKey] Local $tileKeys = MapKeys($this.Tiles) For $key In $tileKeys Local $neighbor = $this.Tiles[$key] If $neighbor.Number = 0 And _ $neighbor <> $currentTile And _ $currentTile.CheckCollision($neighbor) Then Return $key EndIf Next Return Null EndFunc ;==>FindEmptyNeighbor ; Échange les numéros entre deux tuiles Func ExchangeTiles($this, $tile1Key, $tile2Key) Local $tiles = $this.Tiles Local $temp = $tiles[$tile1Key].Number $tiles[$tile2Key].Number = $temp $tiles[$tile1Key].Number = 0 $this.Tiles = $tiles EndFunc ;==>ExchangeTiles ; Met à jour l'affichage des tuiles Func RefreshDisplay($this) For $tile In $this.Tiles $tile.DisplayNumber($tile.Number) Next EndFunc ;==>RefreshDisplay ; Affiche le plateau de jeu Func RenderPuzzle($this) Local $graphicsContext = $this.GraphicsContext Local $graphics = $graphicsContext["GraphicsObject"] Local $pen = _GDIPlus_PenCreate(0xFFFF0000, 2) _GDIPlus_GraphicsClear($graphics, 0xFF000000) Local $tiles = $this.Tiles For $tile In $tiles _GDIPlus_GraphicsDrawRect($graphics, $tile.X, $tile.Y, $tile.Size, $tile.Size, $pen) For $line In $tile.Lines Local $linePen = _GDIPlus_PenCreate($line.Color, $line.Thickness) _GDIPlus_GraphicsDrawLine($graphics, $line.StartX, $line.StartY, $line.EndX, $line.EndY, $linePen) _GDIPlus_PenDispose($linePen) Next Next _GDIPlus_PenDispose($pen) _GDIPlus_GraphicsDrawImageRect($graphicsContext["Graphics"], $graphicsContext["Bitmap"], 0, 0, $this.WindowWidth, $this.WindowHeight) EndFunc ;==>RenderPuzzle Func ResetPuzzle($this) Local $numbers[16] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 10, 11, 12, 13, 14, 15] _ArrayShuffle($numbers) Local $tiles = $this.Tiles For $i = 0 To UBound($tiles) - 1 $tiles[$i].Number = $numbers[$i] $tiles[$i].DisplayNumber($tiles[$i].Number) Next EndFunc ;==>ResetPuzzle ; Vérifie la condition de victoire Func VerifyWinCondition($this) Local $tiles = $this.Tiles For $i = 1 To UBound($tiles) - 1 ; Les cases doivent être triées de 1 à 15, avec la dernière case vide (0) If $tiles[$i].Number <> $i Then Return False EndIf Next Return True EndFunc ;==>VerifyWinCondition ; Libère les ressources Func ReleaseResources($this) Local $graphicsContext = $this.GraphicsContext _GDIPlus_BrushDispose($graphicsContext["BackgroundBrush"]) _GDIPlus_GraphicsDispose($graphicsContext["Graphics"]) _GDIPlus_BitmapDispose($graphicsContext["Bitmap"]) GUIDelete($graphicsContext["BoardWindow"]) _GDIPlus_Shutdown() EndFunc ;==>ReleaseResources Global $game = CreatePuzzleGame() $game.Run() $game = 0 Have fun!
    2 points
  2. ; ;################################## ; Include ;################################## #include <file.au3> ;################################## ; Variables ;################################## $SmtpServer = "MailServer" ; address for the smtp-server to use - REQUIRED $FromName = "Name" ; name from who the email was sent $FromAddress = "your@Email.Address.com" ; address from where the mail should come $ToAddress = "your@Email.Address.com" ; destination address of the email - REQUIRED $Subject = "Userinfo" ; subject from the email - can be anything you want it to be $Body = "" ; the messagebody from the mail - can be left blank but then you get a blank mail ; example html body with inline images. file can be quoted or unquoted, ; but the format ##image#your-filename.jpg## is fixed: ;$as_Body = "<body>E-mail with 2 images inline:<br>" & _ ; "first image: ##image#'C:\path-to-Picture\image1.png'##" & _ ; "second image: ##image#C:\path-to-Picture\image1.png##" & _ ; "<br></body>" ; $AttachFiles = "" ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed $CcAddress = "CCadress1@test.com" ; address for cc - leave blank if not needed $BccAddress = "BCCadress1@test.com" ; address for bcc - leave blank if not needed $Importance = "Normal" ; Send message priority: "High", "Normal", "Low" $Username = "******" ; username for the account used from where the mail gets sent - REQUIRED $Password = "********" ; password for the account used from where the mail gets sent - REQUIRED $IPPort = 25 ; port used for sending the mail $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS $tls = 0 ; enables/disables TLS when required ;~ $SmtpServer = "smtp.gmail.com" ; GMAIL address for the smtp-server to use - REQUIRED ;~ $IPPort=465 ; GMAIL port used for sending the mail ;~ $ssl=1 ; GMAIL enables/disables secure socket layer sending - put to 1 if using httpS ;~ $SmtpServer = "smtp.office365.com" ; O365 address for the smtp-server to use - REQUIRED ;~ $IPPort=25 ; O365 port used for sending the mail ;~ $ssl=1 ; O365 enables/disables secure socket layer sending - put to 1 if using httpS ;~ SmtpServer = "smtp.mail.yahoo.com" ; Yahoo address for the smtp-server to use - REQUIRED ;~ $IPPort = 465 ; Yahoo port used for sending the mail ;~ $ssl = 1 ; Yahoo enables/disables secure socket layer sending - put to 1 if using httpS ;################################## ; Script ;################################## Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl, $tls) If @error Then MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc) EndIf ; ; The UDF 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, $tls = 0) Local $objEmail = ObjCreate("CDO.Message") ; convert the Fromname to UTF-8 basex64 to allow for UTF characters in the name If $s_FromName <> "" Then $s_FromName = "=?utf-8?B?" & _Base64Encode(BinaryToString(StringToBinary($s_FromName, 4), 1)) & '?=' $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 ; add embedded images when defined Local $aImages = 0, $iImgCnt = 0 $aImages = StringRegExp($as_Body, "##image#['""]?([^#'""]*)['""]?##", $STR_REGEXPARRAYGLOBALMATCH) $iImgCnt += 1 For $i = 0 To UBound($aImages) - 1 $iImgCnt += 1 $fileext = StringRegExpReplace($aImages[$i], ".*(\.+.*)", "$1") $as_Body = StringRegExpReplace($as_Body, "(##image#['""]?([^#'""]*)['""]?##)", "<img src=" & $iImgCnt & $fileext & ">", 1) $objBP = $objEmail.AddRelatedBodyPart($aImages[$i], $iImgCnt & $fileext, 1) $objBP.Fields.Item("urn:schemas:mailheader:Content-ID") = "<" & $iImgCnt & $fileext & ">" $objBP.Fields.Update ConsoleWrite('+> Image placed inline: ' & $aImages[$i] & @LF) Next $objEmail.HTMLBody = $as_Body $objEmail.HTMLBodyPart.CharSet = "UTF-8" Else $objEmail.Textbody = $as_Body & @CRLF $objEmail.TextBodyPart.CharSet = "UTF-8" 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 ConsoleWrite('+> File attachment added: ' & $S_Files2Attach[$x] & @LF) $objEmail.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 ; Set security params If $ssl Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True If $tls Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendtls") = True ;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 ; Base64 UDF made by Trancexx https://www.autoitscript.com/forum/topic/84133-winhttp-functions/?do=findComment&comment=1260746 Func _Base64Encode($vInput) Local Const $CRYPT_STRING_BASE64 = 0x00000001 Local Const $CRYPT_STRING_NOCRLF = 0x40000000 $vInput = Binary($vInput) Local $tInput = DllStructCreate("byte[" & BinaryLen($vInput) & "]") DllStructSetData($tInput, 1, $vInput) Local $aCall = DllCall("Crypt32.dll", "bool", "CryptBinaryToStringA", _ "struct*", $tInput, _ "dword", DllStructGetSize($tInput), _ "dword", $CRYPT_STRING_BASE64 + $CRYPT_STRING_NOCRLF , _ "ptr", 0, _ "dword*", 0) If @error Or Not $aCall[0] Then Return SetError(1, 0, "") ; error calculating the length of the needed buffer Local $tOut = DllStructCreate("char[" & $aCall[5] & "]") $aCall = DllCall("Crypt32.dll", "int", "CryptBinaryToStringA", _ "struct*", $tInput, _ "dword", DllStructGetSize($tInput), _ "dword", $CRYPT_STRING_BASE64 + $CRYPT_STRING_NOCRLF, _ "struct*", $tOut, _ "dword*", DllStructGetSize($tOut)) If @error Or Not $aCall[0] Then Return SetError(2, 0, ""); error encoding Return DllStructGetData($tOut, 1) EndFunc Edit: Fixed Bcc ... Edit: Added support for different port and SLL which are used by GMail (Port 465) Edit: Added Importance support (10/2008) Edit: Added $TLS option (07/2020) Edit: Added inline Images option in an HTML body (12/2024) Some interesting Info from the thread:
    1 point
  3. Nine

    Clipboard save and retrieve

    Could you try this simple script ? Seemed to be working fine with me... #include <Constants.au3> #include <GUIConstants.au3> #include <Clipboard.au3> Opt ("MustDeclareVars", 1) Global $aClip _Clipboard_GetAll($aClip) _ClipBoard_Empty() _ClipBoard_SetData ("Some text to set clipboard to",$CF_TEXT) MsgBox (0,"test","Check if clipboard is OK") _ClipBoard_PutAll($aClip) Beep () Func _Clipboard_GetAll(ByRef $avClip) Local $iFormat = 0, $iNum If Not _ClipBoard_Open(0) Then Return SetError(-1, 0, 0) $iNum = _ClipBoard_CountFormats () Dim $avClip[$iNum+1][2] $avClip[0][0] = $iNum For $i = 1 to $iNum $iFormat = _ClipBoard_EnumFormats($iFormat) $avClip[$i][0] = $iFormat Next _ClipBoard_Close() For $i = 1 to $iNum $avClip[$i][1] = _ClipBoard_GetData ($avClip[$i][0]) Next EndFunc Func _ClipBoard_PutAll(ByRef $avClip) Local $bEmpty, $iErr = 0 If Not _ClipBoard_Open(0) Then Return SetError(-2, 0, 0) $bEmpty = _ClipBoard_Empty() _ClipBoard_Close() if not $bEmpty then Return SetError(-3, 0, 0) For $i = 1 To $avClip[0][0] If _ClipBoard_SetData ($avClip[$i][1], $avClip[$i][0]) = 0 Then $iErr += 1 Next If $iErr Then Return SetError(-4, $iErr, 0) Else Return 1 EndIf EndFunc
    1 point
×
×
  • Create New...