Leaderboard
Popular Content
Showing content with the highest reputation on 09/14/2014 in all areas
-
Hello all I am trying to create img2pdf program using The >MPDF UDF. The base of my code is dirived from the img2pdf example. I can make the image itself the a custom size but not the page itself. Any ideas? #include "..\MPDF_UDF.au3" _SelectImages() Func _SelectImages() Local $var = FileOpenDialog("Select images", @ScriptDir & "\", "Images (*.jpg;*.bmp;*gif;*png;*tif;*ico)", 4) If @error Then MsgBox(4096, "", "No File(s) chosen") Else Local $aImgs = StringSplit($var, "|", 3) Dim $cHeight[1] $cHeight[0] = 0 Dim $cWidth[1] $cWidth[0] = 0 _GDIPlus_Startup() For $i = 1 To UBound($aImgs) - 1 $oGdi = _GDIPlus_ImageLoadFromFile($aImgs[0] & "\" & $aImgs[$i]) If @error Then MsgBox(0, "Error", @error) Exit EndIf _ArrayAdd($cWidth, _GDIPlus_ImageGetWidth($oGdi)) _ArrayAdd($cHeight, _GDIPlus_ImageGetHeight($oGdi)) Next _GDIPlus_Shutdown() _OpenAfter(True);open after generation _SetUnit($PDF_UNIT_PT) _SetZoomMode($PDF_ZOOM_CUSTOM, 90) _SetLayoutMode($PDF_LAYOUT_CONTINOUS) ;initialize the pdf _InitPDF(@ScriptDir & "\Image2PDF.pdf") If UBound($aImgs) <> 1 Then ;=== load resources used in pdf === For $i = 1 To UBound($aImgs) - 1 _LoadResImage("img" & $i, $aImgs[0] & "\" & $aImgs[$i]) Next ;load each image on it's own page For $i = 1 To UBound($aImgs) - 1 _SetPaperSize("CUSTOM",$cWidth[$i],$cHeight[$i]) _BeginPage() _InsertImage("img" & $i, 0, 0,$cWidth[$i], $cHeight[$i]) _EndPage() Next Else _LoadResImage("taietel", $aImgs[0]) _BeginPage() ;scale image to paper size! _InsertImage("taietel", 0, 0, _GetPageWidth() / _GetUnit(), _GetPageHeight() / _GetUnit()) _EndPage() EndIf ;then, finally, write the buffer to disk _ClosePDFFile() EndIf EndFunc ;==>_SelectImages ps I have included the my source the udf and the images I am using to test it. Img2Pdf.zip1 point
-
I remember when I first came to AutoIt and looking at them youtube video tutorials by someone or other and was moving the mouse with keyboard. Anyway, I don't know what possessed me but I decided to write one myself, I doubt it's the same as what I seen a few years ago. It's quite basic, and for beginners to look at and figure out what's going on beyond my meagre comments. It simply moves the mouse with arrow keys, and speeds the move up after a delay. Esc to Exit. EDIT: Forgot to mention, I left a nice little bug in the code, which can occur when $BEHAVIOUR Const is set to 1.1 point
-
How to use forums
benyamin200 reacted to Izuno for a topic
Okie, so do I post the code here or can I make another thread to ask for assistance? P.s. Like, I managed to get the box up but no matter what I do it keeps flashing (well flickering) which just looks weird Also I replied faster this time cause din't have to think about what else to say, honest! P.p.s Yeah I thought so too while I was typing that post... which was why it took me so long to press the post button! But yeah, them sudden urges to do something and failing and the gnawing feeling you get from wanting to find out why it din't work out.1 point -
Multi-Monitor Window Snap [beta]
UEZ reacted to jaberwacky for a topic
UEZ, I decided to autoitobjectify one of your scripts. This may not be the best example ever but it should give you a basic idea to go on. ;coded by UEZ 2009-01-09 - thanks to smashly for _GDIPlus_BrushSetSolidColor() function :-) #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0 #AutoIt3Wrapper_UseUpx=n ;~ #AutoIt3Wrapper_Run_After=upx.exe --best "%out%" #AutoIt3Wrapper_Run_After=upx.exe --ultra-brute "%out%" #AutoIt3Wrapper_Run_After=del "Flying Pearl Necklaces_Obfuscated.au3" #include <GuiConstantsEx.au3> #include <GDIPlus.au3> #include "AutoItObject.au3" Opt('MustDeclareVars', 1) Opt("GUIOnEventMode", 1) _main() Func _main() Local Const $Pi = 4 * ATan(1) Local Const $pi_div_90 = $Pi / 90 Local Const $pi_div_120 = $Pi / 120 Local Const $pi_div_75 = $Pi / 75 Local Const $width = 400 Local Const $height = $width Local $k, $xcoord1, $ycoord1, $xcoord2, $ycoord2, $size, $red, $green, $blue Local $GUI = GUICreate("GDI+: Flying Pearl Necklaces by UEZ 2009", $width, $height) GUISetOnEvent($GUI_EVENT_CLOSE, _close) GUISetState(@SW_SHOW) _AutoItObject_Startup() Local $oGDI = _oGDI() $oGDI.Init($GUI, $width, $height) Local $i = -650 Local $l = $i Local $starting_point = 0 Local $min_size = 13 Local $i_p_j, $i_m_j, $h2, $w2, $sin_sp, $cos_sp Do $oGDI.GraphicsClear() ; clear buffer $k = 4096 ; 2^12 $starting_point -= 0.05 For $j = 0 To $k Step 32 $i_p_j = $i + $j $red = ((Sin($i_p_j * 0.001953125) + 1) * 0.5) * 256 ; 2/1024=0.001953125 $green = ((Sin($i_p_j * 0.0078125) + 1) * 0.5) * 256 ; 4/512=0.0078125 $blue = ((Sin($i_p_j * 0.03125) + 1) * 0.5) * 256 ; 8/256=0.03125 $oGDI.Brush1SetSolidColor($red, $green, $blue) $oGDI.Brush2SetSolidColor($red, $green, $blue) $size = $i - $j If $size > -$min_size And $size < $min_size Then $size = $min_size EndIf $i_m_j = $i - $j $sin_sp = Sin($starting_point) $cos_sp = Cos($starting_point) $h2 = $height / 2 $w2 = $width / 2 $xcoord1 = $w2 - ($i_m_j * 0.5) + $sin_sp * -Sin($i_m_j * $pi_div_90) * 64 $ycoord1 = $h2 - ($i_m_j * 0.5) + -$cos_sp * Cos($i_m_j * $pi_div_90) * 32 $oGDI.GraphicsFillEllipse1($xcoord1, $ycoord1, $size) $xcoord2 = $w2 - (-$i_m_j / -1.75) - $sin_sp * Sin($i_m_j * $pi_div_120) * 32 $ycoord2 = $h2 - ($i_m_j / -1.75) - $cos_sp * Cos($i_m_j * $pi_div_75) * 16 $oGDI.GraphicsFillEllipse2($xcoord2, $ycoord2, $size) Next $oGDI.GraphicsDrawImageRect(0, 0, $width, $height) ; copy to bitmap $i += 3 If $i > $k + Abs($l) Then $i = $l EndIf Until Not Sleep(30) EndFunc Func _close() Exit EndFunc #region ; GDI Object Func _oGDI() Local $this = _AutoItObject_Class() $this.AddMethod("Init", "_oGDI_Init") $this.AddMethod("GraphicsClear", "_oGDI_GraphicsClear") $this.AddMethod("Brush1SetSolidColor", "_oGDI_Brush1SetSolidColor") $this.AddMethod("Brush2SetSolidColor", "_oGDI_Brush2SetSolidColor") $this.AddMethod("GraphicsFillEllipse1", "_oGDI_GraphicsFillEllipse1") $this.AddMethod("GraphicsFillEllipse2", "_oGDI_GraphicsFillEllipse2") $this.AddMethod("GraphicsDrawImageRect", "_oGDI_GraphicsDrawImageRect") $this.AddProperty("Graphic", $elscope_private, "") $this.AddProperty("ParticleBitmap", $elscope_private, "") $this.AddProperty("ParticleBuffer", $elscope_private, "") $this.AddProperty("Brush1", $elscope_private, "") $this.AddProperty("Brush2", $elscope_private, "") $this.AddDestructor("dtor", "_oGDI_dtor") Return $this.Object EndFunc Func _oGDI_Init($this, $gui, $width, $height) _GDIPlus_Startup() $this.Graphic = _GDIPlus_GraphicsCreateFromHWND($gui) ; create graphic $this.ParticleBitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $this.Graphic) ; create bitmap $this.ParticleBuffer = _GDIPlus_ImageGetGraphicsContext($this.ParticleBitmap) ; create buffer _GDIPlus_GraphicsSetSmoothingMode($this.ParticleBuffer, 4) ; Antialiasing _GDIPlus_GraphicsClear($this.ParticleBuffer) ; clear buffer $this.Brush1 = _GDIPlus_BrushCreateSolid(0) $this.Brush2 = _GDIPlus_BrushCreateSolid(0) EndFunc Func _oGDI_GraphicsDrawImageRect($this, $x, $y, $w, $h) _GDIPlus_GraphicsDrawImageRect($this.Graphic, $this.ParticleBitmap, $x, $y, $w, $h) EndFunc Func _oGDI_GraphicsFillEllipse1($this, $x, $y, $s) _GDIPlus_GraphicsFillEllipse($this.ParticleBuffer, $x, $y, $s * 0.166666666, $s * 0.166666666, $this.Brush1) EndFunc Func _oGDI_GraphicsFillEllipse2($this, $x, $y, $s) _GDIPlus_GraphicsFillEllipse($this.ParticleBuffer, $x, $y, $s * 0.125, $s * 0.125, $this.Brush2) EndFunc Func _oGDI_Brush1SetSolidColor($this, $r, $g, $b) _GDIPlus_BrushSetSolidColor($this.Brush1, "0xCF" & Hex($r, 2) & Hex($g, 2) & Hex($b, 2)) EndFunc Func _oGDI_Brush2SetSolidColor($this, $r, $g, $b) _GDIPlus_BrushSetSolidColor($this.Brush2, "0xCF" & Hex($b, 2) & Hex($r, 2) & Hex($g, 2)) EndFunc Func _oGDI_GraphicsClear($this) _GDIPlus_GraphicsClear($this.ParticleBuffer, 0xFFFFFFFF) EndFunc Func _oGDI_dtor($this) ; Clean up resources _GDIPlus_BrushDispose($this.Brush1) _GDIPlus_BrushDispose($this.Brush2) _GDIPlus_GraphicsDispose ($this.Graphic) _GDIPlus_BitmapDispose($this.ParticleBitmap) _GDIPlus_GraphicsDispose($this.ParticleBuffer) _GDIPlus_Shutdown() EndFunc #EndRegion edit: overlooked something, fixed now1 point -
Are you able to create a reproducer? EDIT: And just for sanity sake, do you employ a Hotkey which uses Esc and is an exit function by any chance?1 point
-
Detect when any and all windows have moved.
jaberwacky reacted to Gianni for a topic
You are welcome1 point -
Detect when any and all windows have moved.
pixelsearch reacted to jaberwacky for a topic
Ok! Yes. I think this will work. Thank you everybody. #include <APISysConstants.au3> #include <GUIMenu.au3> #include <WinAPIProc.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> Global $hEventProc = DllCallbackRegister(_EventProc, "none", "ptr;dword;hwnd;long;long;dword;dword") Global $hEventHook = _WinAPI_SetWinEventHook($EVENT_MIN, $EVENT_MAX, DllCallbackGetPtr($hEventProc)) OnAutoItExitRegister(OnAutoItExit) Global $iPid = Run(@SystemDir & "\notepad.exe") While ProcessExists($iPid) Sleep(1000) WEnd Func OnAutoItExit() _WinAPI_UnhookWinEvent($hEventHook) DllCallbackFree($hEventProc) EndFunc Func _EventProc($hEventHook, $iEvent, $hWnd, $iObjectID, $iChildID, $iThreadId, $iEventTime) #forceref $hEventHook, $iObjectID, $iChildID, $iThreadId, $iEventTime Switch $iEvent Case $EVENT_SYSTEM_MOVESIZEEND ConsoleWrite("End" & @CRLF) Case $EVENT_SYSTEM_MOVESIZESTART ConsoleWrite("Start" & @CRLF) EndSwitch EndFunc1 point