Leaderboard
Popular Content
Showing content with the highest reputation on 12/08/2014 in all areas
-
A possible use for a game "escape from the maze" edit: the exit is in the lower right ;#AutoIt3Wrapper_AU3Check_Parameters= -q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 ;#Tidy_Parameters=/sf #include-once #include <Array.au3> #include <Misc.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> OnAutoItExitRegister("on_exit") Opt("GUIOnEventMode", 1) Opt("GUIEventOptions", 1) Opt("MustDeclareVars", 1) Global $aGuiSize[2] = [670, 700] Global $sGuiTitle = "Detefons's grid" Global $hGui ; $aBox[0] size of box ; $aBox[1] horizontal space between boxes ; $aBox[2] vertical space between boxes ; $aBox[3] grid's left position ; $aBox[4] grid's top position Global $aBox[5] = [10, 1, 1, 5, 5] ; used to store the pressed keys Global $aPress[6] = [False, False, False, False, False, False] ; $aKeys[0] ctrl ; $aKeys[1] space ; $aKeys[2] left ; $aKeys[3] up ; $aKeys[4] right ; $aKeys[5] down Global $aKeys[6] = [11, 20, 25, 26, 27, 28] ; store old values from x and y Global $iox, $ioy Global $hLabelX, $hLabelY Global $mx, $my ; used to calc a movement's diagonal Global Const $ROOT = Round(Sqrt(2) / 2, 3) Global $aGrid[($aGuiSize[0] - $aBox[3]) / ($aBox[0] + $aBox[1])][($aGuiSize[1] - $aBox[4] - 30) / ($aBox[0] + $aBox[2])] ; $aPos is a shadow array, if a pos[x][y] have no value, is possible walk here ; if have a some value, this is not possible Global $aPos[UBound($aGrid, 1)][UBound($aGrid, 2)] ; limits Global $aLim[4] = [0, 0, UBound($aGrid, 1) - 1, UBound($aGrid, 2) - 1] Global $oActor = ObjCreate("Scripting.Dictionary") $oActor.Add(1, ObjCreate("Scripting.Dictionary")) $oActor.Item(1).Add("x", 1) ; 4) ; start x position $oActor.Item(1).Add("y", 1) ; 10) ; start y position $oActor.Item(1).Add("s", 0.5) ; speed horizontal and vertical $oActor.Item(1).Add("ss", $oActor.Item(1).Item("s") * $ROOT) ; speed diagonal $hGui = GUICreate($sGuiTitle, $aGuiSize[0], $aGuiSize[1], -1, -1, $WS_POPUPWINDOW, $WS_EX_COMPOSITED) GUISetOnEvent($GUI_EVENT_CLOSE, "_quit") ; make the maze --------------------------------------------------------------------- ; portions of code from the following topic: ; http://www.autoitscript.com/forum/topic/141892-maze-generator/ ; ----------------------------------------------------------------------------------- Local $maze = _MyMaze(20, 20) ; generate maze Local $aiSize[2] = [20, 20] Local $aXY Local $color[2] = ["", "0x00AA00"]; [0] = Path ; [1] = Wall ([0] = path must stay empty) ; (see in Grid() function for path color) For $i = 0 To UBound($maze) - 1 $aXY = _GetCellPos($aiSize, $i) $aXY[0] *= 3 $aXY[1] *= 3 add_wall($aXY[1] + 1, $aXY[0] + 0, 1, 1, $color[StringMid($maze[$i], 1, 1)]) ; 10 add_wall($aXY[1] + 2, $aXY[0] + 1, 1, 1, $color[StringMid($maze[$i], 2, 1)]) ; 21 add_wall($aXY[1] + 1, $aXY[0] + 2, 1, 1, $color[StringMid($maze[$i], 3, 1)]) ; 12 add_wall($aXY[1] + 0, $aXY[0] + 1, 1, 1, $color[StringMid($maze[$i], 4, 1)]) ; 01 add_wall($aXY[1] + 0, $aXY[0] + 0, 1, 1, $color[1]) ; 00 add_wall($aXY[1] + 2, $aXY[0] + 0, 1, 1, $color[1]) ; 20 add_wall($aXY[1] + 1, $aXY[0] + 1, 1, 1, $color[0]) ; 11 add_wall($aXY[1] + 0, $aXY[0] + 2, 1, 1, $color[1]) ; 02 add_wall($aXY[1] + 2, $aXY[0] + 2, 1, 1, $color[1]) ; 22 Next ; ----------------------------------------------------------------------------------- $hLabelX = GUICtrlCreateLabel("x " & $oActor.Item(1).Item("x"), 10, 665, 600, 20) $hLabelY = GUICtrlCreateLabel("y " & $oActor.Item(1).Item("y"), 10, 685, 600, 20) grid() GUISetState(@SW_SHOW, $hGui) While Sleep(20) keyboard() If move() Then MsgBox(0, "End of game", "Great! did you find the exit!") Exit EndIf WEnd Func keyboard() For $ii = 0 To 5 If _IsPressed($aKeys[$ii]) And Not $aPress[$ii] Then $aPress[$ii] = True If Not _IsPressed($aKeys[$ii]) And $aPress[$ii] Then $aPress[$ii] = False Next EndFunc ;==>keyboard Func mov_vh($each, $dir, $speed, $sig = 1) ; movement vertical and horizontal Local $iTry = $oActor.Item($each).Item($dir) + $oActor.Item($each).Item($speed) * $sig Switch $dir Case "x" $mx = Round($iTry) $my = Round($oActor.Item($each).Item("y")) Switch $sig Case -1 If $iTry < $aLim[0] Then Return $aLim[0] Case 1 If $iTry > $aLim[2] Then Return $aLim[2] EndSwitch If ($aPos[$mx][$my]) Then Return $oActor.Item($each).Item("x") Case "y" $mx = Round($oActor.Item($each).Item("x")) $my = Round($iTry) Switch $sig Case -1 If $iTry < $aLim[1] Then Return $aLim[1] Case 1 If $iTry > $aLim[3] Then Return $aLim[3] EndSwitch If ($aPos[$mx][$my]) Then Return $oActor.Item($each).Item("y") EndSwitch Return $iTry EndFunc ;==>mov_vh Func move_d($each, $id) ; movement diagonal Switch $id Case 1 $oActor.Item($each).Item("x") = mov_vh($each, "x", "ss") $oActor.Item($each).Item("y") = mov_vh($each, "y", "ss", -1) Case 2 $oActor.Item($each).Item("x") = mov_vh($each, "x", "ss") $oActor.Item($each).Item("y") = mov_vh($each, "y", "ss") Case 3 $oActor.Item($each).Item("x") = mov_vh($each, "x", "ss", -1) $oActor.Item($each).Item("y") = mov_vh($each, "y", "ss") Case 4 $oActor.Item($each).Item("x") = mov_vh($each, "x", "ss", -1) $oActor.Item($each).Item("y") = mov_vh($each, "y", "ss", -1) EndSwitch EndFunc ;==>move_d Func move() For $each In $oActor $iox = $oActor.Item($each).Item("x") $ioy = $oActor.Item($each).Item("y") If $aPress[2] And Not $aPress[3] And Not $aPress[4] And Not $aPress[5] Then $oActor.Item($each).Item("x") = mov_vh($each, "x", "s", -1) If $aPress[4] And Not $aPress[2] And Not $aPress[3] And Not $aPress[5] Then $oActor.Item($each).Item("x") = mov_vh($each, "x", "s") If $aPress[3] And Not $aPress[2] And Not $aPress[4] And Not $aPress[5] Then $oActor.Item($each).Item("y") = mov_vh($each, "y", "s", -1) If $aPress[5] And Not $aPress[2] And Not $aPress[3] And Not $aPress[4] Then $oActor.Item($each).Item("y") = mov_vh($each, "y", "s") If $aPress[3] And $aPress[4] And Not $aPress[2] And Not $aPress[5] Then move_d($each, 1) If $aPress[4] And $aPress[5] And Not $aPress[2] And Not $aPress[3] Then move_d($each, 2) If $aPress[2] And $aPress[5] And Not $aPress[3] And Not $aPress[4] Then move_d($each, 3) If $aPress[2] And $aPress[3] And Not $aPress[4] And Not $aPress[5] Then move_d($each, 4) GUICtrlSetBkColor($aGrid[Round($iox)][Round($ioy)], 0xFFFFFF) GUICtrlSetBkColor($aGrid[Round($oActor.Item($each).Item("x"))][Round($oActor.Item($each).Item("y"))], 0x000000) Next GUICtrlSetData($hLabelX, "$x[" & Round($oActor.Item(1).Item("x")) & "]") GUICtrlSetData($hLabelY, "$y[" & Round($oActor.Item(1).Item("y")) & "]") Return ((Round($oActor.Item(1).Item("x")) = 58) And (Round($oActor.Item(1).Item("y")) = 58)) ; reached the exit of the maze EndFunc ;==>move Func grid() $mx = UBound($aGrid, 1) - 1 $my = UBound($aGrid, 2) - 1 For $ii = 0 To $mx For $jj = 0 To $my $aGrid[$ii][$jj] = GUICtrlCreateLabel("", $aBox[3] + $ii * ($aBox[0] + $aBox[1]), $aBox[4] + $jj * ($aBox[0] + $aBox[2]), $aBox[0], $aBox[0]) If $aPos[$ii][$jj] Then GUICtrlSetBkColor($aGrid[$ii][$jj], $aPos[$ii][$jj]) Else GUICtrlSetBkColor($aGrid[$ii][$jj], 0xDDDDDD) ; <-- Path color EndIf Next Next EndFunc ;==>grid Func _quit() Exit EndFunc ;==>_quit Func on_exit() GUIDelete($hGui) EndFunc ;==>on_exit Func add_wall($iXX, $iYY, $iWW, $iHH, $iColor) For $ii = $iXX To $iXX + $iWW - 1 For $jj = $iYY To $iYY + $iHH - 1 $aPos[$ii][$jj] = $iColor Next Next EndFunc ;==>add_wall ; make the maze --------------------------------------------------------------------- ; portions of code from the following topic: ; http://www.autoitscript.com/forum/topic/141892-maze-generator/ ; ----------------------------------------------------------------------------------- Func _MyMaze($iMazeX, $iMazeY) ; , $iRndSeed = Default, $bShow = True) Local $bShow = False Local $iRndSeed = Random(0, SRandom(@SEC * @MIN), 1) ; 1% of progress Local $aiSize[2] = [$iMazeX, $iMazeY] ;$aiSize[0] Equals Number of Rows in each colum and $aiSize[1] equals number of Colums ;Generate the maze it will be stored in $aCells Local $aCells = Generate_Maze($aiSize) ; This is where the maze will be stored ; It will store witch walls are intact Return $aCells EndFunc ;==>_MyMaze Func Generate_Maze(Const ByRef $aiSize) Local Const $iTotalCells = $aiSize[0] * $aiSize[1] Local $iMoveToCell ; What cell to move to Local $aCellstack[$iTotalCells][2];This stores with sequnce the cell got generated in. used for backtracing. First dimension is Row. Second is Colum Local $iCurrentCellStackNumber = 0 ; Current subscript number to write to in $aCellstack Local $aCurrentCellStack[2] ; USed as a temp storage of a bit of cellstack. First dimension is Row. Second is Colum Local $iUnvisitedCells = $iTotalCells ; Number of cell that are unvisited Local $sNeighbours = '' Local $sNeighbourOk Local $iRndDirection Local $aCurrentCellRowColum ;; setup cell array. Local $aCells[$iTotalCells];This is where the maze will be stored ; It will store witch walls are intact Local $aVisitedCells[$iTotalCells] Local $iCurrentCell = Random(0, $iTotalCells - 1, 1) ;; set random start point/cell ;Make all walls be intact by filling the cells array with 1111 For $i = 0 To $iTotalCells - 1 $aCells[$i] = "1111" $aVisitedCells[$i] = False Next While 1 ;Mark as visited and add to the cell stack $aCurrentCellRowColum = AddToCellStack($iCurrentCell, $iCurrentCellStackNumber, $aCellstack, $aiSize) ;; $iCurrentCell not used in function. ;Check to see if it sould stop createing the maze If $iUnvisitedCells <> 0 Then ;Check to see if the current cell has any neighbours there are unvisited $sNeighbours = _Neighbours($aCurrentCellRowColum, $iCurrentCell, $aVisitedCells, $aiSize) If $sNeighbours <> "0000" Then ;Choose a random unvisited Neighbour Do $iRndDirection = Random(0, 3, 1) $sNeighbourOk = StringMid($sNeighbours, $iRndDirection + 1, 1) Until $sNeighbourOk = "1" Switch $iRndDirection ;Witch side to move to Case 0 ; Move Up $iMoveToCell = $iCurrentCell - $aiSize[1] Case 1 ; Move Right $iMoveToCell = $iCurrentCell + 1 Case 2 ; Move Down $iMoveToCell = $iCurrentCell + $aiSize[1] Case 3 ; Move Left $iMoveToCell = $iCurrentCell - 1 EndSwitch BustWall($iCurrentCell, $iMoveToCell, $iRndDirection, $aCells) $iCurrentCell = $iMoveToCell ;Make the current cell visited $aVisitedCells[$iCurrentCell] = True $iUnvisitedCells -= 1 Else $aCurrentCellStack[0] = $aCellstack[$iCurrentCellStackNumber - 2][0] ; Get row of last item in cellstack $aCurrentCellStack[1] = $aCellstack[$iCurrentCellStackNumber - 2][1] ; Get colum of last item in cellstack $iCurrentCell = _GetCellPos($aiSize, $aCurrentCellStack) ; Combine row and colum to get pos $iCurrentCellStackNumber -= 2 ; This will ensure that the used cell from the cellstack will be overwritten EndIf Else ExitLoop EndIf WEnd Return $aCells EndFunc ;==>Generate_Maze #Region Maze generation functions Func BustWall($Cell1, $Cell2, $iDirection, ByRef $aCells) ; This function will remove the walls in two adjacent cells. Direction is from first cell to second. Direction can be from 0 - 3. 0 = Up, 1 = Right, 2 = Down, 3 = Left $aCells[$Cell1] = StringReplace($aCells[$Cell1], $iDirection + 1, "0", 1, 2) ; Bust the wall between cell1 and cell2 in cell1 FlipDirection_br($iDirection) $aCells[$Cell2] = StringReplace($aCells[$Cell2], $iDirection + 1, "0", 1, 2) ; Bust the wall between cell1 and cell2 in cell2 EndFunc ;==>BustWall Func AddToCellStack($iCurrentCell, ByRef $iCurrentCellStackNumber, ByRef $aCellstack, Const ByRef $aiSize); This function will add the $Cell to the $aCellstack at the subscript of $CurretCellStackNumber ;Convert to Rows and colums Local $aCurrentCellRowColum = _GetCellPos($aiSize, $iCurrentCell) ;Add cell to the cell stack $aCellstack[$iCurrentCellStackNumber][0] = $aCurrentCellRowColum[0] $aCellstack[$iCurrentCellStackNumber][1] = $aCurrentCellRowColum[1] ;Add one to $iCurrentCellStackNumber $iCurrentCellStackNumber += 1 Return $aCurrentCellRowColum EndFunc ;==>AddToCellStack Func _Neighbours(Const ByRef $aCurrentCellRowColum, $Cell, ByRef Const $aVisitedCells, Const ByRef $aiSize) ; Check for Neighbours and store them in a string an 1 means that the neighbour has not been visited and an 0 means the neighbour has been visited it also checks for the edge of the maze. Local $NeighbourRowColum, $sNeighbours = '' Local Const $iTotalCells = $aiSize[0] * $aiSize[1] ;Check Clockwise ;Check Above cell If ($Cell - $aiSize[1] >= 0) And ($aVisitedCells[$Cell - $aiSize[1]] = False) Then $sNeighbours &= "1" Else $sNeighbours &= "0" EndIf ;Check Right Cell $NeighbourRowColum = _GetCellPos($aiSize, $Cell + 1) If ($aCurrentCellRowColum[0] >= $NeighbourRowColum[0]) And ($Cell + 1 < $iTotalCells) And ($aVisitedCells[$Cell + 1] = False) Then $sNeighbours &= "1" Else $sNeighbours &= "0" EndIf ;Check Buttom Cell If ($Cell + $aiSize[1] < $iTotalCells) And ($aVisitedCells[$Cell + $aiSize[1]] = False) Then $sNeighbours &= "1" Else $sNeighbours &= "0" EndIf ;Check Left Cell $NeighbourRowColum = _GetCellPos($aiSize, $Cell - 1) If ($aCurrentCellRowColum[0] <= $NeighbourRowColum[0]) And ($Cell - 1 >= 0) And ($aVisitedCells[$Cell - 1] = False) Then $sNeighbours &= "1" Else $sNeighbours &= "0" EndIf Return $sNeighbours EndFunc ;==>_Neighbours #EndRegion Maze generation functions #Region Global Functions Func _GetCellPos(Const ByRef $aiSize, $vFind) ; This function will make a row and a colum into a Pos to be used with $aCells or $aCellstack, Or it will Make a Pos into an array with row and colum If IsArray($vFind) Then Local $CellPos = $vFind[0] * $aiSize[1] + $vFind[1] Return $CellPos Else Local $aCellRowColum[2] ; Will be used in the _GetCellPos function to temp.. store an array $aCellRowColum[0] = Int($vFind / $aiSize[1]) $aCellRowColum[1] = $vFind - ($aCellRowColum[0] * $aiSize[1]) Return $aCellRowColum EndIf EndFunc ;==>_GetCellPos Func FlipDirection_br(ByRef $iDirection) ; Flips the direction If $iDirection > 1 Then $iDirection -= 2 Else $iDirection += 2 EndIf EndFunc ;==>FlipDirection_br #EndRegion Global Functions2 points
-
Hi Folks. I've written this UDF based on a scipt of Christian Korittke with which you can write a string in a PDF file. You can specify some format of the PDF like font size and type, spacing to the edge a.s.o. Further functions like exact coordinates of the string in the PDF will be included soon. Would you please test it and give feedback to me so I can fix errors and enhance the function? ; Function Name: _StringToPDF() ; Description: Create PDF File ; Parameter(s): $Text - Text in the PDF (I love Autoit) ; $File - Path and Filename of the PDF (c:\Test.pdf) ; $Size - Papersize A4 or A3 ; $Rand_x - Spacing between the text and the vertical edges, Default 20 ; $Rand_y - Spacing between the text and the horizontal edges, Default 24 ; $Schriftart - Fonts (Times-Roman, Helvetica and Courier), Default Courier ; $Fett - Value if the font is bold, Default 0 (normal) ; $Kursiv - Value if the font is italic, Default 0 (normal) ; $Schrift - Size of the font, Default 12 ; $Autor - Name of the autor, Default "unknown" ; $Titel - Title of the PDF, Default "MyPDF" ; ; Author(s): Christian Korittke <Christian_Korittke@web.de> ; Tamer Hosgör <Tamer@TamTech.info> Func _StringToPDF ( $Text, $File, $Size="A4", $Rand_x=20, $Rand_y=24, $Schriftart="Courier", $Fett=0, $Kursiv=0, $Schrift=12, $Autor="unknown", $Titel="MyPDF") If $Size = "A4" Then $Size_x = 210 $Size_y = 297 ElseIf $Size = "A3" Then $Size_x = 420 $Size_y = 297 EndIf $Zeilen = 1 If $Fett = 1 Or $Kursiv = 1 Then If $Schriftart = "Times-Roman" Then If $Fett = 1 Then $Schriftart = "Times-Bold" ElseIf $Kursiv = 1 Then $Schriftart = "Times-Italic" EndIf If $Fett = 1 And $Kursiv = 1 Then $Schriftart = "Times-BoldItalic" ElseIf $Schriftart = "Helvetica" Then If $Fett = 1 Then $Schriftart = "Helvetica-Bold" ElseIf $Kursiv = 1 Then $Schriftart = "Helvetica-Oblique" EndIf If $Fett = 1 And $Kursiv = 1 Then $Schriftart = "Helvetica-BoldOblique" Else If $Fett = 1 Then $Schriftart = "Courier-Bold" ElseIf $Kursiv = 1 Then $Schriftart = "Courier-Oblique" EndIf If $Fett = 1 And $Kursiv = 1 Then $Schriftart = "Courier-BoldOblique" EndIf EndIf If $Schrift = 8 Then $Abstand = 9 ElseIf $Schrift = 9 Then $Abstand = 11 ElseIf $Schrift = 10 Then $Abstand = 12 ElseIf $Schrift = 11 Then $Abstand = 13 ElseIf $Schrift = 12 Then $Abstand = 15 ElseIf $Schrift = 14 Then $Abstand = 17 ElseIf $Schrift = 16 Then $Abstand = 19 ElseIf $Schrift = 18 Then $Abstand = 21 ElseIf $Schrift = 20 Then $Abstand = 24 ElseIf $Schrift = 22 Then $Abstand = 26 ElseIf $Schrift = 24 Then $Abstand = 28 ElseIf $Schrift = 26 Then $Abstand = 30 ElseIf $Schrift = 28 Then $Abstand = 32 ElseIf $Schrift = 36 Then $Abstand = 41 ElseIf $Schrift = 48 Then $Abstand = 55 EndIf If Not StringInStr($Text,@CRLF) = 0 Then $Text = StringSplit($Text,@CRLF) $Zeilen = $Text[0] / 2 + 1 EndIf ; Umrechnung $Wert = 2.834175 $Size_y = Round($Size_y * $Wert) $Size_x = Round($Size_x * $Wert) $Rand_x = Round($Rand_x * $Wert) $Rand_y = Round($Rand_y * $Wert) FileWriteLine($File,"%PDF-1.2") FileWriteLine($File,"%âãÏÓ") FileWriteLine($File,"1 0 obj") FileWriteLine($File,"<<") FileWriteLine($File,"/Author ("&$Autor&")") FileWriteLine($File,"/CreationDate (D:"&@YEAR&@MON&@MDAY&@HOUR&@MIN&@SEC&")") FileWriteLine($File,"/Creator (Ahnungslos)") FileWriteLine($File,"/Producer (Ahnungslos)") FileWriteLine($File,"/Title ("&$Titel&")") FileWriteLine($File,">>") FileWriteLine($File,"endobj") FileWriteLine($File,"4 0 obj") FileWriteLine($File,"<<") FileWriteLine($File,"/Type /Font") FileWriteLine($File,"/Subtype /Type1") FileWriteLine($File,"/Name /F1") FileWriteLine($File,"/Encoding 5 0 R") FileWriteLine($File,"/BaseFont /"&$Schriftart) FileWriteLine($File,">>") FileWriteLine($File,"endobj") FileWriteLine($File,"5 0 obj") FileWriteLine($File,"<<") FileWriteLine($File,"/Type /Encoding") FileWriteLine($File,"/BaseEncoding /WinAnsiEncoding") FileWriteLine($File,">>") FileWriteLine($File,"endobj") FileWriteLine($File,"6 0 obj") FileWriteLine($File,"<<") FileWriteLine($File," /Font << /F1 4 0 R >>") FileWriteLine($File," /ProcSet [ /PDF /Text ]") FileWriteLine($File,">>") FileWriteLine($File,"endobj") FileWriteLine($File,"7 0 obj") FileWriteLine($File,"<<") FileWriteLine($File,"/Type /Page") FileWriteLine($File,"/Parent 3 0 R") FileWriteLine($File,"/Resources 6 0 R") FileWriteLine($File,"/Contents 8 0 R") FileWriteLine($File,"/Rotate 0") FileWriteLine($File,">>") FileWriteLine($File,"endobj") FileWriteLine($File,"8 0 obj") FileWriteLine($File,"<<") FileWriteLine($File,"/Length 9 0 R") FileWriteLine($File,">>") FileWriteLine($File,"stream") FileWriteLine($File,"BT") If $Zeilen = 1 Then FileWriteLine($File,"/F1 "&$Schrift&" Tf") FileWriteLine($File,"1 0 0 1 "&$Rand_y&" "&$Size_y - $Rand_x - $Abstand&" Tm") FileWriteLine($File,"("&$Text&") Tj") Else For $Counter = 1 To $Zeilen FileWriteLine($File,"/F1 "&$Schrift&" Tf") FileWriteLine($File,"1 0 0 1 "&$Rand_y&" "&$Size_y - $Rand_x - $Abstand * $Counter&" Tm") FileWriteLine($File,"("&$Text[$Counter * 2 - 1]&") Tj") Next EndIf FileWriteLine($File,"ET") FileWriteLine($File,"endstream") FileWriteLine($File,"endobj") FileWriteLine($File,"9 0 obj") FileWriteLine($File,"78") FileWriteLine($File,"endobj") FileWriteLine($File,"2 0 obj") FileWriteLine($File,"<<") FileWriteLine($File,"/Type /Catalog") FileWriteLine($File,"/Pages 3 0 R") FileWriteLine($File,">>") FileWriteLine($File,"endobj") FileWriteLine($File,"3 0 obj") FileWriteLine($File,"<<") FileWriteLine($File,"/Type /Pages") FileWriteLine($File,"/Count 1") FileWriteLine($File,"/MediaBox [ 0 0 "&$Size_x&" "&$Size_y&" ]") FileWriteLine($File,"/Kids [ 7 0 R ]") FileWriteLine($File,">>") FileWriteLine($File,"endobj") FileWriteLine($File,"0 10") FileWriteLine($File,"0000000000 65535 f ") FileWriteLine($File,"0000000013 00000 n ") FileWriteLine($File,"0000000591 00000 n ") FileWriteLine($File,"0000000634 00000 n ") FileWriteLine($File,"0000000156 00000 n ") FileWriteLine($File,"0000000245 00000 n ") FileWriteLine($File,"0000000307 00000 n ") FileWriteLine($File,"0000000372 00000 n ") FileWriteLine($File,"0000000453 00000 n ") FileWriteLine($File,"0000000576 00000 n ") FileWriteLine($File,"trailer") FileWriteLine($File,"<<") FileWriteLine($File,"/Size 10") FileWriteLine($File,"/Root 2 0 R") FileWriteLine($File,"/Info 1 0 R") FileWriteLine($File,">>") FileWriteLine($File,"startxref") FileWriteLine($File,"712") FileWriteLine($File,"%%EOF") FileClose($File) EndFunc1 point
-
....or put it in a path that does not have spaces and troubleshoot something else.1 point
-
@JohnOne - I think he means message box when he says popup. I think the issue may be the Arduino window. I have Arduino also and tried to read the text but Au3Info returns some kind of container "SunAwtFrame" - presumably Java that may not behave like a regular window. I could not read the text. As a first step to see if that is right, is the ever a situation in which you are able to read any text from that window before you start searching for the done message? If the answer is no then you may need to consider the >UI Automation Framework to read/find the appropriate text.1 point
-
Sodori, The point I was trying to make is that you are using the wrong variable in the If TimerDiff statement - I was obviously too oblique for a Monday morning. M231 point
-
Local $timer = TimerInit() Local $dif = TimerDiff($timer) ConsoleWrite($dif & @LF) While 1 $dif = TimerDiff($timer) If $dif > 5000 Then ConsoleWrite($dif & @CR) ExitLoop EndIf WEnd Result: 0.127669857481887 5000.006425397641 point
-
Input box returns a string, ctrl read isn't needed. When ctrl read fails, it returns zero. Since you are using it on a string, not a handle, it's functioning normally. Remove ctrl read and your code will function.1 point
-
I'm sure QTP doesn't use a "send" method. 1. Good job on focus, but let's see if we can do the change without it. 2. Try ControlSetText instead of ControlSend. 3. Maybe it wants you to do a mouseover/mousedown/mouseup method first... I had an app that once made me "ControlClick" it before I could set its text. Again, it was managing it's application. I have a feeling, the set text should work. Also, I use the _GUICtrl[Edit/Listview/etc] udf functions as much as possible, so much more versatility. Hope this helps, good luck.1 point
-
Well, thanks Spider001 I was about to reinstall AutoIt, hoping that I would not have to format c:1 point
-
DrawShadowText API, An export function of ComCtl32.dll came across this while reading on MSDN Minimum OS: Windows XP, ComCtl32.dll version 6 or later tested on Win XP and Vista same text formatting and alignment options as _WinAPI_DrawText in helpfile with addition of text color, shadow color and X/Y shadow offset. DrawShadowText Function http://msdn.microsoft.com/en-us/library/bb775639(VS.85).aspx There are GDI+ drop shadow text examples on the forum that offer more shadow formatting options than this API the _CreateShadowTextBitmap bitmap text on a background jpg example is not exactly the best implementation... if the window is hidden, the bitmap is taken from a background window. more XP drop shadow fun: Add a drop shadow to native AutoIt GUI Forms and Dialogs Edit: fixed function header lines wrapping in code boxes CODE;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6#include <GUIConstantsEX.au3> #include <WindowsConstants.au3> #include <FontConstants.au3> #include <WinAPI.au3> Opt('MustDeclareVars', 1) Local $hFont2, $hBmp1, $hBmp2, $hDC1, $hDC2, $hMemDC1, $hMemDC2, $tRECT1, $tRECT2, $pRECT1, $pRECT2 Local $iTextFlags = BitOR($DT_CENTER, $DT_VCENTER, $DT_SINGLELINE) _DrawShadowTextDemo() Func _DrawShadowTextDemo() Local Const $CLEARTYPE_QUALITY = 0x05 Local $hGUI, $Msg, $sTime, $hFont1 Local $cLabel1, $cLabel2, $cLabel3, $cLabel4, $cLabel5 Local $hLabel4, $hLabel5, $hBitmap1, $hBitmap2, $hBitmap3 $hGUI = GUICreate("DrawShadowText API Demo", 400, 420) _GuiSetDropShadow($hGUI, False) If @OSVersion == "WIN_VISTA" Then GUICtrlCreatePic(@WindowsDir & "\Web\Wallpaper\img25.jpg", -1, -1, 401, 300) Else GUICtrlCreatePic(@WindowsDir & "\Web\Wallpaper\Windows XP.jpg", -1, -1, 401, 300) EndIf GUICtrlSetState(-1, $GUI_DISABLE) GUISetBkColor(0xFFFFFF) ;$hFont1 = _WinAPI_CreateFont(60, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _ ;$OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $CLEARTYPE_QUALITY, BitOR($DEFAULT_PITCH, $FF_DONTCARE), "Arial Bold") $hFont1 = _WinAPI_CreateFont(60, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _ $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, BitOR($DEFAULT_PITCH, $FF_DONTCARE), "Arial Bold") $hFont2 = _WinAPI_CreateFont(70, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _ $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, BitOR($DEFAULT_PITCH, $FF_DONTCARE), "Comic Sans MS Bold") $cLabel1 = GUICtrlCreatePic("", 10, 20, 380, 50) $cLabel2 = GUICtrlCreatePic("", 10, 80, 380, 50) $cLabel3 = GUICtrlCreatePic("", 90, 140, 220, 50) $cLabel4 = GUICtrlCreateLabel("", 80, 305, 240, 50) $hLabel4 = GUICtrlGetHandle(-1) $cLabel5 = GUICtrlCreateLabel("", 80, 365, 240, 50) $hLabel5 = GUICtrlGetHandle(-1) $tRECT1 = _WinAPI_GetClientRect($hLabel4) $tRECT2 = _WinAPI_GetClientRect($hLabel5) $pRECT1 = DllStructGetPtr($tRECT1) $pRECT2 = DllStructGetPtr($tRECT2) $hDC1 = _WinAPI_GetWindowDC($hLabel4) $hDC2 = _WinAPI_GetWindowDC($hLabel5) $hMemDC1 = _WinAPI_CreateCompatibleDC($hDC1) $hMemDC2 = _WinAPI_CreateCompatibleDC($hDC2) $hBmp1 = _WinAPI_CreateCompatibleBitmap($hDC1, 240, 50) $hBmp2 = _WinAPI_CreateCompatibleBitmap($hDC2, 240, 50) AdlibEnable("_Time", 100) GUISetState() $sTime = StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC) $hBitmap1 = _CreateShadowTextBitmap($cLabel1, $hFont1, 380, 50, "Shadow Text", $iTextFlags, 0x00FFFFFF, 0x00000000, 6, 6) ;White text/Black shadow _SetBitmapToCtrl($cLabel1, $hBitmap1) Local $sText = "The quick brown fox jumps over the lazy dog" $hBitmap2 = _CreateShadowTextBitmap($cLabel2, 0, 380, 50, $sText, $iTextFlags, 0x00FFFFFF, 0x00000000, 3, 3) ;White text/Black shadow _SetBitmapToCtrl($cLabel2, $hBitmap2) $hBitmap3 = _CreateShadowTextBitmap($cLabel3, $hFont1, 220, 50, $sTime, $iTextFlags, 0x0000D7FF, 0x00000000, -3, -3) ;Gold text/Black shadow _SetBitmapToCtrl($cLabel3, $hBitmap3) Sleep(2000) $hBitmap3 = _CreateShadowTextBitmap($cLabel3, $hFont1, 220, 50, $sTime, $iTextFlags, 0x00000001, 0x0000D7FF , 3, 3) ;Black text/Gold shadow _SetBitmapToCtrl($cLabel3, $hBitmap3) Sleep(2000) $hBitmap3 = _CreateShadowTextBitmap($cLabel3, $hFont1, 220, 50, $sTime, $iTextFlags, 0x0000001, 0x0000CC00, 3, 3) ;Black text/Green shadow _SetBitmapToCtrl($cLabel3, $hBitmap3) Sleep(2000) $hBitmap3 = _CreateShadowTextBitmap($cLabel3, $hFont1, 220, 50, $sTime, $iTextFlags, 0x0000001, 0x00FF0000, 3, 3) ;Black text/Blue shadow _SetBitmapToCtrl($cLabel3, $hBitmap3) Sleep(2000) $hBitmap3 = _CreateShadowTextBitmap($cLabel3, $hFont1, 220, 50, $sTime, $iTextFlags, 0x00000001, 0x00C0C0C0, 3, 3) ;Black text/Grey shadow _SetBitmapToCtrl($cLabel3, $hBitmap3) While 1 $Msg = GUIGetMsg() Switch $Msg Case -3 ExitLoop Case $cLabel1 Case $cLabel2 Case $cLabel3 Case $cLabel4 Case $cLabel5 EndSwitch WEnd GUIDelete() _WinAPI_ReleaseDC($hLabel4, $hDC1) _WinAPI_ReleaseDC($hLabel5, $hDC2) _WinAPI_DeleteDC($hMemDC1) _WinAPI_DeleteDC($hMemDC2) _WinAPI_DeleteObject($hFont1) _WinAPI_DeleteObject($hFont2) _WinAPI_DeleteObject($hBmp1) _WinAPI_DeleteObject($hBmp2) _WinAPI_DeleteObject($hBitmap1) _WinAPI_DeleteObject($hBitmap2) _WinAPI_DeleteObject($hBitmap3) Exit EndFunc ;#FUNCTION#======================================================================================== ; Name...........: _WinAPI_DrawShadowText ; Description ...: Draws formatted text in the specified rectangle with a drop shadow ; Syntax.........: _WinAPI_DrawShadowText($hDC, $szText, ByRef $tRect, $iFlags, $crText, $crShadow, $ixOffset, $iyOffset) ; Parameters ....: $hDC - Identifies the device context ; $sText - The string to be drawn ; $tRect - $tagRECT structure that contains the rectangle for the text ; $iFlags - Specifies the method of formatting the text: *** See Remarks *** ; |$DT_BOTTOM - Justifies the text to the bottom of the rectangle ; |$DT_CALCRECT - Determines the width and height of the rectangle ; |$DT_CENTER - Centers text horizontally in the rectangle ; |$DT_EDITCONTROL - Duplicates the text-displaying characteristics of a multiline edit control ; |$DT_END_ELLIPSIS - Replaces part of the given string with ellipses if necessary ; |$DT_EXPANDTABS - Expands tab characters ; |$DT_EXTERNALLEADING - Includes the font external leading in line height ; |$DT_HIDEPREFIX - Ignores the ampersand (&) prefix character in the text. ; | The letter that follows will not be underlined, but other mnemonic-prefix characters are still processed. ; |$DT_INTERNAL - Uses the system font to calculate text metrics ; |$DT_LEFT - Aligns text to the left ; |$DT_MODIFYSTRING - Modifies the given string to match the displayed text ; |$DT_NOCLIP - Draws without clipping ; |$DT_NOFULLWIDTHCHARBREAK - Prevents a line break at a DBCS (double-wide character string), ; so that the line breaking rule is equivalent to SBCS strings. ; | For example, this can be used in Korean windows, for more readability of icon labels. ; | This value has no effect unless $DT_WORDBREAK is specified ; |$DT_NOPREFIX - Turns off processing of prefix characters ; |$DT_PATH_ELLIPSIS - For displayed text, replaces characters in the middle of the string with ellipses ; | so that the result fits in the specified rectangle. ; | If the string contains backslash (\) characters, ; | $DT_PATH_ELLIPSIS preserves as much as possible of the text after the last backslash. ; | The string is not modified unless the $DT_MODIFYSTRING flag is specified ; |$DT_PREFIXONLY - Draws only an underline at the position of the character following the ampersand (&) prefix character. ; | Does not draw any other characters in the string ; |$DT_RIGHT - Aligns text to the right ; |$DT_RTLREADING - Layout in right to left reading order for bi-directional text ; |$DT_SINGLELINE - Displays text on a single line only ; |$DT_TABSTOP - Sets tab stops. Bits 15-8 of $iFlags specify the number of characters for each tab ; |$DT_TOP - Top-justifies text (single line only) ; |$DT_VCENTER - Centers text vertically (single line only) ; |$DT_WORDBREAK - Breaks words ; |$DT_WORD_ELLIPSIS - Truncates any word that does not fit in the rectangle and adds ellipses ; $crText - Color of the text in hexadecimal COLORREF format: (ABGR) 0x00FFFFFF ; $crShadow - Color of the text shadow in hexadecimal COLORREF format: (ABGR) 0x00FFFFFF ; $ixOffset - Drop shadow X offset integer - positive and negative values ; $iyOffset - Drop shadow Y offset integer - positive and negative values ; "The low-order byte contains a value for the relative intensity of red ; the second byte contains a value for green; and the third byte contains a value for blue. ; The high-order byte must be zero. The maximum value for a single byte is 0xFF". ; Return values .: Success - The height of the text* ; Failure - 0 and error set ; Author ........: rover ; Modified.......: ; Remarks .......: *** Detailed remarks are absent on the MSDN web page, so it is an assumption that the following applies to DrawShadowText as well. ; * "If the function succeeds, the return value is the height of the text in logical units. ; If DT_VCENTER or DT_BOTTOM is specified, the return value is the offset from lpRect->top to the bottom of the drawn text". ; "The DrawText function uses the device context's selected font, text color, and background color to draw the ; text. Unless the $DT_NOCLIP format is used, DrawText clips the text so that it does not appear outside the ; specified rectangle. All formatting is assumed to have multiple lines unless the $DT_SINGLELINE format is ; specified. If the selected font is too large, DrawText does not attempt to substitute a smaller font". ;+ ; Needs WindowsConstants.au3 for pre-defined constants ; Related .......: DrawText, $tagRECT ; Link ..........; @@MsdnLink@@ DrawShadowText ; Example .......; Yes ; =================================================================================================== Func _WinAPI_DrawShadowText($hDC, $szText, ByRef $tRect, $iFlags = 0, $crText = 0, $crShadow = 0, $ixOffset = 0, $iyOffset = 0) If IsDllStruct($tRect) = 0 Or DllStructGetSize($tRect) <> 16 Then Return SetError(1, 1, 0) Local $aResult, $iError $aResult = DllCall("ComCtl32.dll", "int", "DrawShadowText", "hwnd", $hDC, "wstr", $szText, "int", -1, "ptr", _ ;StringLen($szText) DllStructGetPtr($tRect), "dword", $iFlags, "dword", $crText, "dword", $crShadow, "int", $ixOffset, "int", $iyOffset) $iError = @error If @error Or UBound($aResult) <> 10 Then Return SetError($iError, 2, 0) Return SetError($iError, 0, $aResult[0]) EndFunc ;==>_WinAPI_DrawShadowText Func _CreateShadowTextBitmap($CtrlId, $hFont, $iWidth, $iHeight, $sText, $iFlags, $iColText, $iColShadow, $iXOffset, $iYOffset) Local $hDC, $hMemDC, $hBMP, $hOldhBMP, $hOldFont, $tRECT, $hWnd, $hBMP Local Const $STM_GETIMAGE = 0x173 $hWnd = GUICtrlGetHandle($CtrlId) $hBMP = GUICtrlSendMsg($CtrlId, $STM_GETIMAGE, 0, 0) If $hBMP <> 0 Then _WinAPI_DeleteObject($hBMP) GUICtrlSetState($CtrlId, $GUI_SHOW) EndIf $tRECT = _WinAPI_GetClientRect($hWnd) $hDC = _WinAPI_GetWindowDC($hWnd) $hMemDC = _WinAPI_CreateCompatibleDC($hDC) $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight) $hOldhBMP = _WinAPI_SelectObject($hMemDC, $hBMP) $hOldFont = _WinAPI_SelectObject($hDC, $hFont) _WinAPI_DrawShadowText($hDC, $sText, $tRECT, $iFlags, $iColText, $iColShadow, $iXOffset, $iYOffset) _WinAPI_BitBlt($hMemDC, 0, 0, $iWidth, $iHeight, $hDC, 0, 0, $MERGECOPY) _WinAPI_SelectObject($hMemDC, $hOldFont) _WinAPI_SelectObject($hMemDC, $hOldhBMP) _WinAPI_ReleaseDC($hWnd, $hDC) _WinAPI_DeleteDC($hMemDC) Return $hBMP EndFunc ; from Zedna's Resources.au3 Func _SetBitmapToCtrl($CtrlId, $hBitmap) Local Const $STM_SETIMAGE = 0x0172 Local Const $IMAGE_BITMAP = 0 Local Const $SS_BITMAP = 0xE Local Const $GWL_STYLE = -16 Local $hWnd = GUICtrlGetHandle($CtrlId) If $hWnd = 0 Then Return SetError(1, 0, 0) ; set SS_BITMAP style to control ;Local $oldStyle = DllCall("user32.dll", "long", "GetWindowLong", _ ;"hwnd", $hWnd, "int", $GWL_STYLE) ;If @error Then Return SetError(2, 0, 0) ;DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hWnd, _ ;"int", $GWL_STYLE, "long", BitOR($oldStyle[0], $SS_BITMAP)) ;If @error Then Return SetError(3, 0, 0) Local $oldBmp = DllCall("user32.dll", "hwnd", "SendMessage", _ "hwnd", $hWnd, "int", $STM_SETIMAGE, "int", $IMAGE_BITMAP, "int", $hBitmap) If @error Then Return SetError(4, 0, 0) If $oldBmp[0] <> 0 Then _WinAPI_DeleteObject($oldBmp[0]) Return 1 EndFunc Func _Time() Local $obj_orig1 = _WinAPI_SelectObject($hMemDC1, $hBmp1) Local $obj_orig2 = _WinAPI_SelectObject($hMemDC2, $hBmp2) Local $hOldFont1 = _WinAPI_SelectObject($hMemDC1, $hFont2) Local $hOldFont2 = _WinAPI_SelectObject($hMemDC2, $hFont2) _WinAPI_FillRect($hMemDC1, $pRECT1, 0) _WinAPI_FillRect($hMemDC2, $pRECT2, 0) Local $sTime = StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC) _WinAPI_DrawShadowText($hMemDC1, $sTime, $tRECT1, $iTextFlags, 0x00000001, 0x00C0C0C0, -3, -3) _WinAPI_DrawShadowText($hMemDC2, $sTime, $tRECT2, $iTextFlags, 0x00FFFFFF, 0x00C0C0C0, 3, 3) _WinAPI_BitBlt($hDC1, 0, 0, 240, 50, $hMemDC1, 0, 0, $SRCCOPY) _WinAPI_BitBlt($hDC2, 0, 0, 240, 50, $hMemDC2, 0, 0, $SRCCOPY) _WinAPI_SelectObject($hMemDC1, $obj_orig1) _WinAPI_SelectObject($hMemDC2, $obj_orig2) _WinAPI_SelectObject($hMemDC1, $hOldFont1) _WinAPI_SelectObject($hMemDC2, $hOldFont2) EndFunc ;#FUNCTION#======================================================================================== ; Name...........: _GuiSetDropShadow ; Description ...: Sets the drop shadow effect on forms and dialogs for current process ; Syntax.........: _GuiSetDropShadow($hwnd, $fDisrespectUser = True) ; Parameters ....: $hWnd - Handle to parent form or child dialog (GuiCreate(), MsgBox(), FileOpenDialog(), etc.) ; $fDisrespectUser - True: (Default) - set system option for drop shadow if disabled by user ; - False: - do not set system option for drop shadow if disabled by user ; Return values .: Success - 1 ; Failure - 0 @error set and @extended set to point of failure ; Author(s) ........: rover, (lod3n, Rasim for Get/SetClassLong, Kip - RegisterclassEx() for drop shadow idea, ProgAndy - xMsgBox hook) ; Remarks .......: Note: drop shadow is lost if parent form clicked on (If MsgBox created with parent handle) ; hiding, then restoring MsgBox to foreground or moving MsgBox off of form restores drop shadow. ; use 262144 or 4096 flags with MsgBox if using with hParent handle to prevent loss of drop shadow if parent clicked on. ; this behaviour is apparently by design. ;+ ; Minimum Operating Systems: Windows XP ; Related .......: ; Link ..........; @@MsdnLink@@ SetClassLong Function ; Example .......; Yes ; =================================================================================================== Func _GuiSetDropShadow($hwnd, $fDisrespectUser = True) If Not IsHWnd($hwnd) Then Return SetError(1, 1, 0) ;check if hWnd is from current process Local $aResult = DllCall("User32.dll", "int", "GetWindowThreadProcessId", "hwnd", $hwnd, "int*", 0) If @error Or $aResult[2] <> @AutoItPID Then Return SetError(@error, 2, 0) If Not IsDeclared("SPI_GETDROPSHADOW") Then Local Const $SPI_GETDROPSHADOW = 0x1024 If Not IsDeclared("SPI_SETDROPSHADOW") Then Local Const $SPI_SETDROPSHADOW = 0x1025 If Not IsDeclared("CS_DROPSHADOW") Then Local Const $CS_DROPSHADOW = 0x00020000 If Not IsDeclared("GCL_STYLE") Then Local Const $GCL_STYLE = -26 $aResult = DllCall("user32.dll", "int", "SystemParametersInfo", "int", $SPI_GETDROPSHADOW, "int", 0, "int*", 0, "int", 0) Local $iErr = @error If $iErr Or Not IsArray($aResult) Then Return SetError($iErr, 3, 0) ;if 'Show shadows under menus' option not set, try activating it. If Not $aResult[3] And $fDisrespectUser Then ;turn on drop shadows $aResult = DllCall("user32.dll", "int", "SystemParametersInfo", "int", $SPI_SETDROPSHADOW, "int", 0, "int", True, "int", 0) $iErr = @error If $iErr Or Not IsArray($aResult) Or $aResult[0] <> 1 Then Return SetError($iErr, 4, 0) EndIf ;get styles from WndClassEx struct $aResult = DllCall("user32.dll", "dword", "GetClassLong", "hwnd", $hwnd, "int", $GCL_STYLE) $iErr = @error If $iErr Or Not IsArray($aResult) Or Not $aResult[0] Then Return SetError($iErr, 5, 0) Local $OldStyle = $aResult[0] ;add drop shadow style to styles Local $Style = BitOR($OldStyle, $CS_DROPSHADOW) If StringRight(@OSArch, 2) == "64" Then ;if 64 bit windows (NOT TESTED) ;see MSDN SetClassLong remarks ;$aResult = DllCall("user32.dll", "ulong_ptr", "SetClassLongPtr", "hwnd", $hWnd, "int", $GCL_STYLE, "long_ptr", $Style) ;$iErr = @error ;If $iErr Or Not IsArray($aResult) Or Not $aResult[0] Then Return SetError($iErr, 6, 0) Else $aResult = DllCall("user32.dll", "dword", "SetClassLong", "hwnd", $hwnd, "int", $GCL_STYLE, "long", $Style) $iErr = @error If $iErr Or Not IsArray($aResult) Or Not $aResult[0] Then Return SetError($iErr, 7, 0) If $aResult[0] = $OldStyle Then Return SetError($iErr, 0, 1) Return SetError($iErr, 8, 0) EndIf EndFunc;==>_GuiSetDropShadow Screenshot1 point
-
@all This will give a better understanding on how to interprete a PDF file content. Since AU3 can create PDF using this UDF. _StringToPDF Regards ptrex1 point
-
Thanks for the feedback. Here's the script of Christian Korittke from a german AutoIt-Forum, followed by the link to the post. #include <GUIConstants.au3> GUICreate("PDF-Creator",500,520) GUICtrlCreateGroup("Seitenformat",10,30,170,70) GUICtrlCreateGroup("Rand (mm)",190,30,105,70) GUICtrlCreateGroup("Schriftformat",315,30,175,70) GUICtrlCreateRadio("Querformat",20,70) GUICtrlCreateLabel("Autor:",10,475,100,20) GUICtrlCreateLabel("Titel:",120,475,100,20) GUICtrlCreateLabel("links:",200,50,30,20) GUICtrlCreateLabel("oben:",200,75,30,20) $Start = GUICtrlCreateButton("erzeuge PDF",370,480,120,30) GUICtrlSetFont(-1,11,600) $Autor = GUICtrlCreateInput("",10,490,100,20) $Titel = GUICtrlCreateInput("",120,490,100,20) $Text = GUICtrlCreateEdit("Bitte geben sie hier Ihren Text ein.",10,120,480,345) $Schrift = GUICtrlCreateCombo("8",325,48,45,20) GUICtrlSetData(-1,"9|10|11|12|14|16|18|20|22|24|26|28|36|48|72","12") $Schriftart = GUICtrlCreateCombo("Times-Roman",380,48,100,20) GUICtrlSetData(-1,"Helvetica|Courier","Times-Roman") $Size = GUICtrlCreateCombo("A4",110,60,50,20) GUICtrlSetData(-1,"A3","A4") $Format = GUICtrlCreateRadio("Hochformat",20,50) GUICtrlSetState(-1,$GUI_CHECKED) $Rand_y = GUICtrlCreateInput("24",240,48,45,20) GUICtrlCreateUpdown(-1) GUICtrlSetLimit(-1,999,0) $Rand_x = GUICtrlCreateInput("25",240,72,45,20) GUICtrlCreateUpdown(-1) GUICtrlSetLimit(-1,999,0) $Fett = GUICtrlCreateCheckbox("Fett",325,73,35,20) $Kursiv = GUICtrlCreateCheckbox("Kursiv",370,73,60,20) GUISetState () While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit If $msg = $Start Then ExitLoop WEnd $Pfad = FileSaveDialog("Speichern",@DesktopDir,"PDF (*.pdf)",16) If StringRight($Pfad,4) = ".pdf" Then Else $Pfad = $Pfad & ".pdf" EndIf $Fett = GUICtrlRead($Fett) $Kursiv = GUICtrlRead($Kursiv) $Schriftart = GUICtrlRead($Schriftart) $Rand_x = GUICtrlRead($Rand_x) $Rand_y = GUICtrlRead($Rand_y) $Format = GUICtrlRead($Format) $Autor = GUICtrlRead($Autor) $Titel = GUICtrlRead($Titel) $Size = GUICtrlRead($Size) $Text = GUICtrlRead($Text) $Schrift = GUICtrlRead($Schrift) FileDelete($Pfad) $File = FileOpen($Pfad, 1) $Zeilen = 1 If $Size = "A4" Then $Size_x = 210 $Size_y = 297 ElseIf $Size = "A3" Then $Size_x = 297 $Size_y = 420 EndIf If $Fett = $GUI_CHECKED Or $Kursiv = $GUI_CHECKED Then If $Schriftart = "Times-Roman" Then If $Fett = $GUI_CHECKED Then $Schriftart = "Times-Bold" ElseIf $Kursiv = $GUI_CHECKED Then $Schriftart = "Times-Italic" EndIf If $Fett = $GUI_CHECKED And $Kursiv = $GUI_CHECKED Then $Schriftart = "Times-BoldItalic" ElseIf $Schriftart = "Helvetica" Then If $Fett = $GUI_CHECKED Then $Schriftart = "Helvetica-Bold" ElseIf $Kursiv = $GUI_CHECKED Then $Schriftart = "Helvetica-Oblique" EndIf If $Fett = $GUI_CHECKED And $Kursiv = $GUI_CHECKED Then $Schriftart = "Helvetica-BoldOblique" Else If $Fett = $GUI_CHECKED Then $Schriftart = "Courier-Bold" ElseIf $Kursiv = $GUI_CHECKED Then $Schriftart = "Courier-Oblique" EndIf If $Fett = $GUI_CHECKED And $Kursiv = $GUI_CHECKED Then $Schriftart = "Courier-BoldOblique" EndIf EndIf If $Format = $GUI_UNCHECKED Then $Size = $Size_x $Size_x = $Size_y $Size_y = $Size EndIf If $Schrift = 8 Then $Abstand = 9 ElseIf $Schrift = 9 Then $Abstand = 11 ElseIf $Schrift = 10 Then $Abstand = 12 ElseIf $Schrift = 11 Then $Abstand = 13 ElseIf $Schrift = 12 Then $Abstand = 15 ElseIf $Schrift = 14 Then $Abstand = 17 ElseIf $Schrift = 16 Then $Abstand = 19 ElseIf $Schrift = 18 Then $Abstand = 21 ElseIf $Schrift = 20 Then $Abstand = 24 ElseIf $Schrift = 22 Then $Abstand = 26 ElseIf $Schrift = 24 Then $Abstand = 28 ElseIf $Schrift = 26 Then $Abstand = 30 ElseIf $Schrift = 28 Then $Abstand = 32 ElseIf $Schrift = 36 Then $Abstand = 41 ElseIf $Schrift = 48 Then $Abstand = 55 Else $Abstand = 83 EndIf If Not StringInStr($Text,@CRLF) = 0 Then $Text = StringSplit($Text,@CRLF) $Zeilen = $Text[0] / 2 + 1 EndIf ; Umrechnung $Wert = 2.834175 $Size_y = Round($Size_y * $Wert) $Size_x = Round($Size_x * $Wert) $Rand_x = Round($Rand_x * $Wert) $Rand_y = Round($Rand_y * $Wert) FileWriteLine($File,"%PDF-1.2") FileWriteLine($File,"%âãÏÓ") FileWriteLine($File,"1 0 obj") FileWriteLine($File,"<<") FileWriteLine($File,"/Author ("&$Autor&")") FileWriteLine($File,"/CreationDate (D:"&@YEAR&@MON&@MDAY&@HOUR&@MIN&@SEC&")") FileWriteLine($File,"/Creator (Ahnungslos)") FileWriteLine($File,"/Producer (Ahnungslos)") FileWriteLine($File,"/Title ("&$Titel&")") FileWriteLine($File,">>") FileWriteLine($File,"endobj") FileWriteLine($File,"4 0 obj") FileWriteLine($File,"<<") FileWriteLine($File,"/Type /Font") FileWriteLine($File,"/Subtype /Type1") FileWriteLine($File,"/Name /F1") FileWriteLine($File,"/Encoding 5 0 R") FileWriteLine($File,"/BaseFont /"&$Schriftart) FileWriteLine($File,">>") FileWriteLine($File,"endobj") FileWriteLine($File,"5 0 obj") FileWriteLine($File,"<<") FileWriteLine($File,"/Type /Encoding") FileWriteLine($File,"/BaseEncoding /WinAnsiEncoding") FileWriteLine($File,">>") FileWriteLine($File,"endobj") FileWriteLine($File,"6 0 obj") FileWriteLine($File,"<<") FileWriteLine($File," /Font << /F1 4 0 R >>") FileWriteLine($File," /ProcSet [ /PDF /Text ]") FileWriteLine($File,">>") FileWriteLine($File,"endobj") FileWriteLine($File,"7 0 obj") FileWriteLine($File,"<<") FileWriteLine($File,"/Type /Page") FileWriteLine($File,"/Parent 3 0 R") FileWriteLine($File,"/Resources 6 0 R") FileWriteLine($File,"/Contents 8 0 R") FileWriteLine($File,"/Rotate 0") FileWriteLine($File,">>") FileWriteLine($File,"endobj") FileWriteLine($File,"8 0 obj") FileWriteLine($File,"<<") FileWriteLine($File,"/Length 9 0 R") FileWriteLine($File,">>") FileWriteLine($File,"stream") FileWriteLine($File,"BT") If $Zeilen = 1 Then FileWriteLine($File,"/F1 "&$Schrift&" Tf") FileWriteLine($File,"1 0 0 1 "&$Rand_y&" "&$Size_y - $Rand_x - $Abstand&" Tm") FileWriteLine($File,"("&$Text&") Tj") Else For $Counter = 1 To $Zeilen FileWriteLine($File,"/F1 "&$Schrift&" Tf") FileWriteLine($File,"1 0 0 1 "&$Rand_y&" "&$Size_y - $Rand_x - $Abstand * $Counter&" Tm") FileWriteLine($File,"("&$Text[$Counter * 2 - 1]&") Tj") Next EndIf FileWriteLine($File,"ET") FileWriteLine($File,"endstream") FileWriteLine($File,"endobj") FileWriteLine($File,"9 0 obj") FileWriteLine($File,"78") FileWriteLine($File,"endobj") FileWriteLine($File,"2 0 obj") FileWriteLine($File,"<<") FileWriteLine($File,"/Type /Catalog") FileWriteLine($File,"/Pages 3 0 R") FileWriteLine($File,">>") FileWriteLine($File,"endobj") FileWriteLine($File,"3 0 obj") FileWriteLine($File,"<<") FileWriteLine($File,"/Type /Pages") FileWriteLine($File,"/Count 1") FileWriteLine($File,"/MediaBox [ 0 0 "&$Size_x&" "&$Size_y&" ]") FileWriteLine($File,"/Kids [ 7 0 R ]") FileWriteLine($File,">>") FileWriteLine($File,"endobj") FileWriteLine($File,"0 10") FileWriteLine($File,"0000000000 65535 f ") FileWriteLine($File,"0000000013 00000 n ") FileWriteLine($File,"0000000591 00000 n ") FileWriteLine($File,"0000000634 00000 n ") FileWriteLine($File,"0000000156 00000 n ") FileWriteLine($File,"0000000245 00000 n ") FileWriteLine($File,"0000000307 00000 n ") FileWriteLine($File,"0000000372 00000 n ") FileWriteLine($File,"0000000453 00000 n ") FileWriteLine($File,"0000000576 00000 n ") FileWriteLine($File,"trailer") FileWriteLine($File,"<<") FileWriteLine($File,"/Size 10") FileWriteLine($File,"/Root 2 0 R") FileWriteLine($File,"/Info 1 0 R") FileWriteLine($File,">>") FileWriteLine($File,"startxref") FileWriteLine($File,"712") FileWriteLine($File,"%%EOF") FileClose($File) http://autoit.aufwaerts.de/thread.php?thre...amp;hilight=pdf1 point