-
Posts
682 -
Joined
-
Last visited
-
Days Won
6
DatMCEyeBall last won the day on April 27 2014
DatMCEyeBall had the most liked content!
About DatMCEyeBall
- Birthday 04/06/1999
Profile Information
-
Member Title
I'm young - what's your excuse?
-
Location
South of central Africa.
-
Interests
AutoIt, C++ <== that sort of stuff
DatMCEyeBall's Achievements
-
SEuBo reacted to a post in a topic: DllCallbackRegister with non freezing GUI (Volatile) Example
-
PoojaKrishna reacted to a post in a topic: Monitoring mouse events
-
oapjr reacted to a post in a topic: AutoIt Snippets
-
DatMCEyeBall reacted to a post in a topic: HotKeySet() does not accept lower case letters in ASC notation. Feature or bug?
-
Prevent Dotted Focus Lines on Controls
DatMCEyeBall replied to Melba23's topic in AutoIt Example Scripts
Well, a lot has changed since those versions, so you could say: 「Nah, it doesn't matter」. -
Prevent Dotted Focus Lines on Controls
DatMCEyeBall replied to Melba23's topic in AutoIt Example Scripts
Is that a typo, or was it done on purpose? -
Crop .png files from folder
DatMCEyeBall replied to Insomniac420's topic in AutoIt General Help and Support
Danm javascript never load properly, fixed the code in my post. -
Crop .png files from folder
DatMCEyeBall replied to Insomniac420's topic in AutoIt General Help and Support
#include <File.au3> #include <GDIPlus.au3> #include <MsgBoxConstants.au3> Global Const $sInFolder = "In\" ; The folder where all your original .pngs are Global Const $sOutFolder = "Out\" ; The folder where the new .pngs will be stored ; Generate a list of all the png files in $sInFolder Global $asList = _FileListToArray($sInFolder, "*.png", 1, False) If @error Then Switch @error Case 1 _ErrMsgExit("Folder not found or invalid, " & $sInFolder, -11) Case 2 _ErrMsgExit("Invalid _FileListToArray() filter supplied", -12) Case 3 _ErrMsgExit("Invalid _FileListToArray() Flag", -13) Case 4 _ErrMsgExit("No files found in " & $sInFolder, -14) EndSwitch EndIf ; Crop the images _GDIPlus_Startup() ; I'm assuming that all the input files are different sizes and that the top left (0, 0) ; needs to be cropped into a 500 x 400 frame (NOTE: if the file is too small (under 500 x 400) then a blank space will occur) Global $hImage, $hNewImage, $hCtxt, $sErrorList = "" For $i = 1 To $asList[0] ; Loop through all files $hImage = _GDIPlus_ImageLoadFromFile($asList[$i]) ; Attempt to load file If @error Then _StringAppend($sErrorList, "Error loading file: """ & $asList[$i] & """ @extended = " & @extended) ContinueLoop ; Start the loop again since we can't use this image EndIf $hNewImage = _GDIPlus_BitmapCreateFromScan0(500, 400) ; Creata a blank 500 x 400 bitmap $hCtxt = _GDIPlus_ImageGetGraphicsContext($hNewImage) ; Get the GraphicsContext of an image (so we can write to it) ; _GDIPlus_GraphicsClear($hCtxt, 0xFF000000) ; Uncomment if you want the background to be a solid colour _GDIPlus_GraphicsDrawImageRectRect( _ $hCtxt, $hImage, _ 0, 0, 500, 400, _ ; Source image ($hImage) (X, Y, Width, Height) (ie. Take data from $hImage at XY 0, 0 with a width of 500 and height of 400) 0, 0, 500, 400, _ ; Destination image ($hCtxt -> $hNewImage) (ie. Write to $hNewImage at XY 0, 0 with a width of 500 and height of 400) ) ; Note: Keep the source image and destination image Width / Height the same to prevent resizing ; At this point $hNewImage contains the new data _GDIPlus_GraphicsDispose($hCtxt) ; We no longer need to write to it, so get rid of it _GDIPlus_ImageDispose($hImage) ; We no longer need to read from it, so get rid of it _GDIPlus_ImageSaveToFile($hNewImage, $sOutFolder & $asList[$i]) ; Write $hNewImage to the folder If @error Then _StringAppend($sErrorList, "Error saving file: """ & $sOutFolder & $asList[$i] & """ @extended = " & @extended) EndIf _GDIPlus_ImageDispose($hNewImage) ; Don't need it anymore Next If $sErrorList <> "" Then MsgBox($MB_OK + $MB_ICONWARNING, "Warning", "The following errors have occured:" & @CRLF & @CRLF & $sErrorList) EndIf _GDIPlus_Shutdown() Func _ErrMsgExit($sMsg, $iCode, $iLine = @ScriptLineNumber) If Not @Compiled Then $sMsg = "An error occured on line " & $iLine & ":" & @CRLF & @CRLF & $sMsg MsgBox($MB_OK + $MB_ICONERROR, "Critical error", $sMsg) Exit $iCode EndFunc ;==>_ErrMsgExit Func _StringAppend(ByRef $sString, $sAppend, $sDelim = @CRLF) #cs If $sString = "" Then $sString &= $sAppend Else $sString &= $sDelim & $sAppend EndIf #ce ; Same as above, but with the Ternary operator $sString &= (($sString = "") ? ("") : ($sDelim)) & $sAppend Return 1 EndFunc ;==>_StringAppend -
I'll have more up later today (some other examples that are not Jerome's). Even more when I convert the S3d UDF to C++
- 10 replies
-
- GDI+
- Double buffer
-
(and 1 more)
Tagged with:
-
"Wavy Thing" #include <GDIPlus.au3> #include <Math.au3> ;~ #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w- 7 Opt("GUIOnEventMode", 1) Global Const $nPI = 3.1415926535897932384626433832795 Global Const $nTWOPI = $nPI * 2 Global $iNum = 25 Global $anPosX[$iNum] Global $nUnit, $nTheta, $nX, $nSzX, $nSzY Global $fClose = False Global $iW = 500, $iH = 300 Global $hGUI = GUICreate('"Wavy thing" by Jerome Herr | Written in AutoIt3 by EyeZiS', $iW, $iH) GUISetBkColor(0) GUISetOnEvent(-3, "_Exit") $nUnit = ($iW - 50) / $iNum _GDIPlus_Startup() Global $hCtxt = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hCtxt) Global $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) Global $hBrush = _GDIPlus_BrushCreateSolid(0xFFFCD300) Global $hPen = _GDIPlus_PenCreate(0xFF777777, 1) Global $hTimer = TimerInit() GUISetState() While Not $fClose If TimerDiff($hTimer) >= 33 Then $hTimer = TimerInit() _Draw() _GDIPlus_GraphicsDrawImage($hCtxt, $hBitmap, 0, 0) ConsoleWrite(TimerDiff($hTimer) & @CRLF) EndIf Sleep(33 - TimerDiff($hTimer) - 1) WEnd _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hCtxt) GUIDelete() Func _Draw() _GDIPlus_GraphicsClear($hGraphics, 0xBE000000) For $i = 0 To $iNum - 1 $nSzX = _Map(Sin($nTheta + ($nTWOPI / $iNum) * $i), -1, 1, 5, 10) $nSzY = _Map(Sin($nTheta + ($nPI / $iNum) * $i), -1, 1, 30, $iH / 1.2) $nX = _Map(Sin($nTheta + ($nPI / $iNum / 2) * $i), -1, 1, $i * $nUnit, $iW / 2) _GDIPlus_GraphicsFillDrawRect($hGraphics, $nX + 25, _CenterPoint($nSzY, $iH), $nSzX, $nSzY, $hBrush, $hPen) Next $nTheta += 0.0523 _ModIfGreater($nTheta, $nTWOPI) EndFunc ;==>_Draw Func _Exit() $fClose = True EndFunc ;==>_Exit Func _GDIPlus_GraphicsFillDrawRect($hGraphics, $nX, $nY, $nWidth, $nHeight, $hBrush = 0, $hPen = 0) _GDIPlus_GraphicsFillRect($hGraphics, $nX, $nY, $nWidth, $nHeight, $hBrush) _GDIPlus_GraphicsDrawRect($hGraphics, $nX, $nY, $nWidth, $nHeight, $hPen) Return 1 EndFunc ;==>_GDIPlus_GraphicsFillDrawRect Func _Map($nVar, $nMin1, $nMax1, $nMin2, $nMax2) Return $nMin2 + ($nMax2 - $nMin2) * (($nVar - $nMin1) / ($nMax1 - $nMin1)) EndFunc ;==>_Map Func _ModIfGreater(ByRef $nVar, $nMod) $nVar = ($nVar > $nMod) ? (Mod($nVar, $nMod)) : ($nVar) EndFunc ;==>_ModIfGreater Func _CenterPoint($iCur, $iTotal) Return $iTotal / 2 - $iCur / 2 EndFunc ;==>_CenterPoint
- 10 replies
-
- GDI+
- Double buffer
-
(and 1 more)
Tagged with:
-
"Lava Lamp" #include <GDIPlus.au3> #include <Math.au3> ;~ #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w- 7 Opt("GUIOnEventMode", 1) Global Const $nPI = 3.1415926535897932384626433832795 Global Const $nTWOPI = $nPI * 2 Global $iNum = 125 Global $aiMaxSize[$iNum] Global $anOffset[$iNum] Global $nTheta, $nSz, $nX Global $aiPalette[] = [0x64F58F12, 0x640B9EE7, 0x644EA731, 0x64F4D910, 0x64F334E3] For $i = 0 To $iNum - 1 $aiMaxSize[$i] = Random(50, 120, 1) $anOffset[$i] = Random(0, $nTWOPI) Next Global $fClose = False Global $iW = 500, $iH = 500 Global $hGUI = GUICreate('"Lava Lamp" by Jerome Herr | Written in AutoIt3 by EyeZiS', $iW, $iH) GUISetOnEvent(-3, "_Exit") _GDIPlus_Startup() Global $hCtxt = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hCtxt) Global $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) Global $hBrush = _GDIPlus_BrushCreateSolid() Global $hTimer = TimerInit() GUISetState() While Not $fClose If TimerDiff($hTimer) >= 33 Then $hTimer = TimerInit() _Draw() _GDIPlus_GraphicsDrawImage($hCtxt, $hBitmap, 0, 0) ConsoleWrite(TimerDiff($hTimer) & @CRLF) EndIf Sleep(33 - TimerDiff($hTimer) - 1) WEnd _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hCtxt) GUIDelete() Func _Draw() _GDIPlus_GraphicsClear($hGraphics, 0xFF202020) For $i = 0 To $iNum - 1 _GDIPlus_BrushSetSolidColor($hBrush, $aiPalette[Mod($i, 5)]) $nX = _Map(Sin($nTheta + $anOffset[$i]), -1, 1, 150, 350 - $aiMaxSize[$i]) _GDIPlus_GraphicsFillRect($hGraphics, $nX, $iH / $iNum * $i, $aiMaxSize[$i], 20, $hBrush) Next $nTheta += 0.0523 / 2 _ModIfGreater($nTheta, $nTWOPI) EndFunc ;==>_Draw Func _Exit() $fClose = True EndFunc ;==>_Exit Func _Map($nVar, $nMin1, $nMax1, $nMin2, $nMax2) Return $nMin2 + ($nMax2 - $nMin2) * (($nVar - $nMin1) / ($nMax1 - $nMin1)) EndFunc ;==>_Map Func _ModIfGreater(ByRef $nVar, $nMod) $nVar = ($nVar > $nMod) ? (Mod($nVar, $nMod)) : ($nVar) EndFunc ;==>_ModIfGreater
- 10 replies
-
- GDI+
- Double buffer
-
(and 1 more)
Tagged with:
-
"Trunk in space" #include <GDIPlus.au3> #include <Math.au3> ;~ #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w- 7 Opt("GUIOnEventMode", 1) Global Const $nPI = 3.1415926535897932384626433832795 Global Const $nTWOPI = $nPI * 2 Global $iSz = 300, $iNum = 40 Global $nTheta, $nAngle, $nRad = 200 Global $fClose = False Global $iW = 500, $iH = 500 Global $hGUI = GUICreate('"Trunk in space" by Jerome Herr | Written in AutoIt3 by EyeZiS', $iW, $iH) GUISetOnEvent(-3, "_Exit") _GDIPlus_Startup() Global $hCtxt = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hCtxt) Global $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) Global $hPen = _GDIPlus_PenCreate(0xFFFFFFFF, 6, 2) Global $hBrush = _GDIPlus_BrushCreateSolid() Global $hTimer = TimerInit() GUISetState() While Not $fClose If TimerDiff($hTimer) >= 33 Then $hTimer = TimerInit() _Draw() _GDIPlus_GraphicsDrawImage($hCtxt, $hBitmap, 0, 0) ConsoleWrite(TimerDiff($hTimer) & @CRLF) EndIf Sleep(33 - TimerDiff($hTimer) - 1) WEnd _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hCtxt) GUIDelete() Func _Draw() _GDIPlus_GraphicsClear($hGraphics, 0xFFFFFFFF) $nAngle = 0 Local $nX, $nY, $nS, $nScal Local $iF For $i = 0 To $iNum - 1 $nX = $iW / 2 - $nRad / 2 + Cos($nAngle) * $nRad $nY = $iH / 2.5 + Sin($nAngle) * $nRad $nS = _Map(Sin($nTheta + $nTWOPI / $iNum * $i * 2), -1, 1, 1, 0.7) $nScal = 1 - 0.03 * $i $iF = Int(255 / $iNum * $i) _GDIPlus_BrushSetSolidColor($hBrush, "0xFF" & Hex(_WinAPI_ColorHLSToRGB($iF, 100, 160), 6)) _GDIPlus_GraphicsFillDrawEllipse($hGraphics, 0, $nY, $iSz * $nScal * $nS, $iSz * $nScal * $nS, $hBrush, $hPen) $nAngle -= $nPI / $iNum Next $nTheta += 0.0523 _ModIfGreater($nTheta, $nTWOPI) EndFunc ;==>_Draw Func _GDIPlus_GraphicsFillDrawEllipse($hGraphics, $nX, $nY, $nWidth, $nHeight, $hBrush = 0, $hPen = 0) _GDIPlus_GraphicsFillEllipse($hGraphics, $nX, $nY, $nWidth, $nHeight, $hBrush) _GDIPlus_GraphicsDrawEllipse($hGraphics, $nX, $nY, $nWidth, $nHeight, $hPen) Return 1 EndFunc ;==>_GDIPlus_GraphicsFillDrawEllipse Func _Exit() $fClose = True EndFunc ;==>_Exit Func _Map($nVar, $nMin1, $nMax1, $nMin2, $nMax2) Return $nMin2 + ($nMax2 - $nMin2) * (($nVar - $nMin1) / ($nMax1 - $nMin1)) EndFunc ;==>_Map Func _ModIfGreater(ByRef $nVar, $nMod) $nVar = ($nVar > $nMod) ? (Mod($nVar, $nMod)) : ($nVar) EndFunc ;==>_ModIfGreater
- 10 replies
-
- GDI+
- Double buffer
-
(and 1 more)
Tagged with:
-
BinaryCall UDF - Write Subroutines In C, Call In AutoIt
DatMCEyeBall replied to Ward's topic in AutoIt Example Scripts
This is a great tool for improving scripts that rely on complex equations. Thanks, I might use it over compiling a .dll in some cases- 33 replies
-
- binary
- machine code
-
(and 1 more)
Tagged with:
-
I wrote this after seeing Jerome Herr's post on Tumblr and looking at the code here. A few Google searches later, I came up with these. #include <GDIPlus.au3> #include <Math.au3> ;~ #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w- 7 Opt("GUIOnEventMode", 1) Global Const $nPI = 3.1415926535897932384626433832795 Global Const $nTWOPI = $nPI * 2 Global $iNum = 25 Global $nStep, $nSz, $nTheta $nStep = 20 Global $iMaxRad = ($iNum - 1) * $nStep Global $fClose = False Global $iW = $iMaxRad, $iH = $iMaxRad Global $hGUI = GUICreate('"Wave" by Jerome Herr | Written in AutoIt3 by EyeZiS', $iW, $iH) GUISetOnEvent(-3, "_Exit") _GDIPlus_Startup() Global $hCtxt = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hCtxt) Global $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) Global $hPen = _GDIPlus_PenCreate(0xFFFFFFFF, 3, 2) Global $hTimer = TimerInit() GUISetState() While Not $fClose If TimerDiff($hTimer) >= 33 Then $hTimer = TimerInit() _Draw() _GDIPlus_GraphicsDrawImage($hCtxt, $hBitmap, 0, 0) ConsoleWrite(TimerDiff($hTimer) & @CRLF) EndIf Sleep(33 - TimerDiff($hTimer) - 1) WEnd _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hCtxt) GUIDelete() Func _Draw() _GDIPlus_GraphicsClear($hGraphics, 0xFF000000) Local $nArcEnd, $nOffset, $nDrawOffset For $i = 0 To $iNum - 1 $nSz = $i * $nStep $nOffset = $nTWOPI / $iNum * $i $nDrawOffset = $iMaxRad / 2 - $nSz / 2 $nArcEnd = _Degree(_Map(Sin($nTheta + $nOffset), -1, 1, $nPI, $nTWOPI) - $nPI) _GDIPlus_GraphicsDrawArc($hGraphics, $nDrawOffset, $nDrawOffset, $nSz, $nSz, 0, $nArcEnd, $hPen) _GDIPlus_GraphicsDrawArc($hGraphics, $nDrawOffset, $nDrawOffset, $nSz, $nSz, 180, $nArcEnd, $hPen) Next $nTheta += 0.0523 If $nTheta > $nTWOPI Then $nTheta = Mod($nTheta, $nTWOPI) EndIf EndFunc ;==>_Draw Func _Exit() $fClose = True EndFunc ;==>_Exit Func _Map($nVar, $nMin1, $nMax1, $nMin2, $nMax2) Return $nMin2 + ($nMax2 - $nMin2) * (($nVar - $nMin1) / ($nMax1 - $nMin1)) EndFunc ;==>_Map Playing with hue: #include <GDIPlus.au3> #include <Math.au3> #include <WinAPIGdi.au3> ;~ #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w- 7 Opt("GUIOnEventMode", 1) Global Const $nPI = 3.1415926535897932384626433832795 Global Const $nTWOPI = $nPI * 2 Global $iNum = 25 Global $nStep, $nSz, $nTheta Global $iStHue = 0 $nStep = 20 Global $iMaxRad = ($iNum - 1) * $nStep Global $fClose = False Global $iW = $iMaxRad, $iH = $iMaxRad Global $hGUI = GUICreate('"Wave" by Jerome Herr | Written in AutoIt3 by EyeZiS', $iW, $iH) GUISetOnEvent(-3, "_Exit") _GDIPlus_Startup() Global $hCtxt = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hCtxt) Global $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) Global $hPen = _GDIPlus_PenCreate(0xFFFFFFFF, 3, 2) Global $hTimer = TimerInit() GUISetState() While Not $fClose If TimerDiff($hTimer) >= 33 Then $hTimer = TimerInit() _Draw() _GDIPlus_GraphicsDrawImage($hCtxt, $hBitmap, 0, 0) ConsoleWrite("Draw: " & TimerDiff($hTimer) & @CRLF) EndIf Sleep(33 - TimerDiff($hTimer) - 1) WEnd _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hCtxt) GUIDelete() Func _Draw() _GDIPlus_GraphicsClear($hGraphics, 0x7F000000) Local $nArcEnd, $nOffset, $nDrawOffset For $i = 0 To $iNum - 1 $nSz = $i * $nStep $nOffset = $nTWOPI / $iNum * $i $nDrawOffset = $iMaxRad / 2 - $nSz / 2 $nArcEnd = _Degree(_Map(Sin($nTheta + $nOffset), -1, 1, $nPI, $nTWOPI) - $nPI) _GDIPlus_PenSetColor($hPen, "0xFF" & Hex(_WinAPI_ColorHLSToRGB($iStHue + $i, 120, 240), 6)) _GDIPlus_GraphicsDrawArc($hGraphics, $nDrawOffset, $nDrawOffset, $nSz, $nSz, 0, $nArcEnd, $hPen) _GDIPlus_GraphicsDrawArc($hGraphics, $nDrawOffset, $nDrawOffset, $nSz, $nSz, 180, $nArcEnd, $hPen) Next $nTheta += 0.0523 $iStHue += 0.5 _ModIfGreater($nTheta, $nTWOPI) _ModIfGreater($iStHue, 239) EndFunc ;==>_Draw Func _Exit() $fClose = True EndFunc ;==>_Exit Func _Map($nVar, $nMin1, $nMax1, $nMin2, $nMax2) Return $nMin2 + ($nMax2 - $nMin2) * (($nVar - $nMin1) / ($nMax1 - $nMin1)) EndFunc ;==>_Map Func _ModIfGreater(ByRef $nVar, $nMod) $nVar = ($nVar > $nMod) ? (Mod($nVar, $nMod)) : ($nVar) EndFunc >#6 - Trunk in space >#7 - Lava Lamp >#8 - Wavy Thing
- 10 replies
-
- GDI+
- Double buffer
-
(and 1 more)
Tagged with:
-
Let's wait for a dev to come along then.
-
Melba23, User preferences and Seminko's too... I wonder what the Rube Goldberg solution would be.
-
Melba23; Seminko, He can use the $CBS_DROPDOWNLIST style, no need for unnecessary checks.
-
So AutoIt externally references it's structs by pointers, or does it convert the internal "handle" into a real one?