Leaderboard
Popular Content
Showing content with the highest reputation on 10/27/2023 in all areas
-
In this topic, it was mentioned by @mLipok that it could be doable to manage printers with winspool.drv DLL. It was enough to get my attention on it. I do not remember seeing any UDF gathering all those functions. Func _PRNT_GetDefaultPrinter() Func _PRNT_SetDefaultPrinter($sPrinter) Func _PRNT_OpenPrinter($sName) Func _PRNT_ClosePrinter($hPrinter) Func _PRNT_GetPrinterInfo($hPrinter, $bGlobal, $bRAW = False) Func _PRNT_SetPrinterInfo($hPrinter, $iProp, $iValue, $bGlobal) Func _PRNT_EnumPrinters() Func _PRNT_IsValidDevmode($tDevMode) Func _PRNT_EnumJobs($hPrinter) Version 2023-10-17 *added new functions _PRNT_IsValidDevmode and _PRNT_EnumJobs Version 2023-10-15 * solved a problem where garbage collector would destroy $tDevMode after a while on return of _PRNT_GetPrinterInfo There is a multitude of other functions that could be part of this UDF, but I have decided to stop here and see how you like it. If you have comments or suggestions, they are always welcome. Printer_UDF.zip1 point
-
#include <MsgBoxConstants.au3> ; For $MB_TOPMOST $hGUI = GUICreate("My Simple GUI", 300, 200) GUISetState(@SW_SHOW) MsgBox($MB_TOPMOST, "IsGUIOpen", IsGUIOpen()) GUIDelete($hGUI) MsgBox($MB_TOPMOST, "IsGUIOpen", IsGUIOpen()) Func IsGUIOpen() Return WinExists("My Simple GUI") EndFunc Don't mix GUI functions with Win functions. Basically if you deal with a window created by GUICreate() then you destroy it with GUIDelete(). If you deal with windows that are not created by your script you can use Win functions. PS: IsGUIOpen() can be even simpler, as you can see above1 point
-
Here my simple version of a speech bubble: #include <GDIPlus.au3> _GDIPlus_Startup() Global $iW = 600 Global $iH = 600 Global $hGUI = GUICreate("Test", $iW, $iH) GUISetBkColor(0x808080) GUISetState() _GDIPlus_Startup() Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetTextRenderingHint($hGraphic, $GDIP_TEXTRENDERINGHINTANTIALIAS) _GDIPlus_DrawSpeechBubble($hGraphic, "Blah blah blah" & @CRLF & "blah blah!", 40, -20, 4, 3, 100, "Comic Sans MS", 7, 0xFF000000, 14, 0xFFFFFFFF, 0xFFFF00FF, 0xFF000000, 2, 100, 100) Do Until GUIGetMsg() = -3 _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() Exit ;code by UEZ build 2023-10-27 Func _GDIPlus_DrawSpeechBubble($hGraphic, $sString, $fFontSize = 12, $fAngle = -20, $fScaleX = 1.0, $fScaleY = 1.0, $fSize = 100, $sFontname = "Arial", $fLegSize = 7, $iLineColor = 0xFF000000, $fPenSize = 2, _ $iFillColor = 0xFFFFFFFF, $iTxtColor = 0xFF000000, $iTxtBorderColor = $iTxtColor, $fPenSizeBorder = 1, $fXOffset = $fPenSize / 2, $fYOffset = $fPenSize / 2) Local Const $hPath = _GDIPlus_PathCreate(), $hMatrix = _GDIPlus_MatrixCreate(), $hPen = _GDIPlus_PenCreate($iLineColor, $fPenSize), $hBrush = _GDIPlus_BrushCreateSolid($iFillColor), _ $hBrush_txt = _GDIPlus_BrushCreateSolid($iTxtColor), $hPen_txt = _GDIPlus_PenCreate($iTxtBorderColor, $fPenSizeBorder), _ $hFamily = _GDIPlus_FontFamilyCreate($sFontname), $hFormat = _GDIPlus_StringFormatCreate(), $hFont = _GDIPlus_FontCreate($hFamily, $fFontSize, 0) _GDIPlus_PathAddEllipse($hPath, 1, 1, $fSize, $fSize) _GDIPlus_PathAddEllipse($hPath, $fSize / 2 - $fLegSize, $fSize - $fSize / 4, $fLegSize, $fSize / 2) _GDIPlus_PathWindingModeOutline($hPath, 0, 0.1) _GDIPlus_MatrixTranslate($hMatrix, $fSize / 2, $fSize / 2) _GDIPlus_MatrixRotate($hMatrix, $fAngle) _GDIPlus_MatrixTranslate($hMatrix, -$fSize / 2, -$fSize / 2) _GDIPlus_PathTransform($hPath, $hMatrix) _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0) ;reset matrix _GDIPlus_MatrixScale($hMatrix, $fScaleX, $fScaleY) _GDIPlus_PathTransform($hPath, $hMatrix) _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0) ;reset matrix _GDIPlus_MatrixTranslate($hMatrix, $fXOffset, $fYOffset) _GDIPlus_PathTransform($hPath, $hMatrix) _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) _GDIPlus_PathReset($hPath) _GDIPlus_StringFormatSetAlign($hFormat, 1) _GDIPlus_StringFormatSetLineAlign($hFormat, 1) Local $tLayout = _GDIPlus_RectFCreate($fXOffset, $fYOffset, $fSize * $fScaleX, $fSize * $fScaleY) _GDIPlus_PathAddString($hPath, $sString, $tLayout, $hFamily, 0, $fFontSize, $hFormat) _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush_txt) _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen_txt) ;_GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush_txt) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_PathDispose($hPath) _GDIPlus_PenDispose($hPen) _GDIPlus_PenDispose($hPen_txt) _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BrushDispose($hBrush_txt) EndFunc1 point
-
1 point
-
Autoit v.2 download
argumentum reacted to water for a topic
AutoIt's syntax changed with version 3. So if the OP has some old V2 code he needs AutoIt V21 point -
You must first convert the GDI+ image to a GDI clipboard bitmap format using _WinAPI_CopyImage function. #include <GDIPlus.au3> #include <Clipboard.au3> Example() Func Example() _GDIPlus_Startup() Local Const $iW = 460, $iH = 100 Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH, $GDIP_PXF01INDEXED) ;create an empty bitmap Local $hBmpCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;get the graphics context of the bitmap _GDIPlus_GraphicsClear($hBmpCtxt, 0xFFFFFFFF) ;clear bitmap with color white _GDIPlus_GraphicsDrawString($hBmpCtxt, "AutoIt rulez!", 0, 0, "Comic Sans MS", 52) ;draw some text to the bitmap Local $hBitmapGDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) Local $hClipboard_Bitmap = _WinAPI_CopyImage($hBitmapGDI, 0, 0, 0, BitOR($LR_COPYDELETEORG, $LR_COPYRETURNORG, $LR_MONOCHROME)) _ClipBoard_Open(0) _ClipBoard_SetDataEx($hClipboard_Bitmap, $CF_BITMAP) _ClipBoard_Close() _WinAPI_DeleteObject($hBitmapGDI) _WinAPI_DeleteObject($hClipboard_Bitmap) ;cleanup GDI+ resources _GDIPlus_GraphicsDispose($hBmpCtxt) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() EndFunc ;==>Example1 point
-
Here my 2 cents. I liked @ioa747 approach, much simpler not to rotate. #include <GDIPlus.au3> #include <GUIConstants.au3> #include <Math.au3> #include <WinAPISysWin.au3> ; bubble speech - radian Opt("MustDeclareVars", True) Global Const $SIZE = 250, $CENTER = $SIZE / 2, $DIAMETER = 200, $RADIUS = $DIAMETER / 2, $BORDER = 25 DrawBubble(45, 300, 300, 8, 25, "Hello World !" & @CR & "This is " & @ComputerName) Func DrawBubble($iDegree, $iPosX, $iPosY, $iWidth, $iHeight, $sText) _GDIPlus_Startup() Local $hGUI = GUICreate("Bubble", $SIZE, $SIZE, $iPosX, $iPosY, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUISetBkColor(0xBADBEE) _WinAPI_SetLayeredWindowAttributes($hGUI, 0xBADBEE) GUISetState(@SW_SHOW) Local $hPen = _GDIPlus_PenCreate(0xFF000000, 3) Local $hPenT = _GDIPlus_PenCreate(0xFFEE3333, 4) Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFEE3333) Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsFillEllipse($hGraphic, $BORDER, $BORDER, $DIAMETER, $DIAMETER, $hBrush) _GDIPlus_GraphicsDrawEllipse($hGraphic, $BORDER, $BORDER, $DIAMETER, $DIAMETER, $hPen) Local $aPoints[4][2] = [[3]], $iRadian $iRadian = _Radian(Mod(450 - $iDegree, 360)) $aPoints[1][0] = $CENTER + (($RADIUS + $iHeight) * Cos($iRadian)) $aPoints[1][1] = $CENTER - (($RADIUS + $iHeight) * Sin($iRadian)) $iRadian = _Radian(Mod(450 - $iDegree - $iWidth, 360)) $aPoints[2][0] = $CENTER + ($RADIUS * Cos($iRadian)) $aPoints[2][1] = $CENTER - ($RADIUS * Sin($iRadian)) $iRadian = _Radian(Mod(450 - $iDegree + $iWidth, 360)) $aPoints[3][0] = $CENTER + ($RADIUS * Cos($iRadian)) $aPoints[3][1] = $CENTER - ($RADIUS * Sin($iRadian)) _GDIPlus_GraphicsFillPolygon($hGraphic, $aPoints, $hBrush) _GDIPlus_GraphicsDrawPolygon($hGraphic, $aPoints, $hPen) _GDIPlus_GraphicsDrawLine($hGraphic, $aPoints[2][0], $aPoints[2][1], $aPoints[3][0], $aPoints[3][1], $hPenT) AddText($hGraphic, $sText) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_BrushDispose($hBrush) _GDIPlus_PenDispose($hPen) _GDIPlus_PenDispose($hPenT) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>DrawBubble Func AddText($hGraphic, $sText, $sFontName = "Comic Sans MS", $fSize = 14, $iColor = 0xFFFFFFFF) Local $hBrush = _GDIPlus_BrushCreateSolid($iColor), $hFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hFormat, 1) ;center text horizontally + vertically _GDIPlus_StringFormatSetLineAlign($hFormat, 1) Local $hFamily = _GDIPlus_FontFamilyCreate($sFontName), $hFont = _GDIPlus_FontCreate($hFamily, $fSize) ; calculate string rectangle Local $iRadian = _Radian(135) ; -45° Local $iLeft = $CENTER + ($RADIUS * Cos($iRadian)) Local $iTop = $CENTER - ($RADIUS * Sin($iRadian)) $iRadian = _Radian(315) ; +135° Local $iWidth = $CENTER + ($RADIUS * Cos($iRadian)) - $iLeft Local $iHeight = $CENTER - ($RADIUS * Sin($iRadian)) - $iTop Local $tLayout = _GDIPlus_RectFCreate($iLeft, $iTop, $iWidth, $iHeight) _GDIPlus_GraphicsDrawStringEx($hGraphic, $sText, $hFont, $tLayout, $hFormat, $hBrush) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) EndFunc ;==>AddText1 point
-
Use of autoit for commercial purposes - (Moved)
robertocm reacted to argumentum for a topic
Yes, me. Treat it as if it was opensource. The code can be had, as it is a script after all. C# would have a similar same fate in that regard. Very many C / C++ applications get cracked so, just be mindful of how you code. That is something I will not share and is not me alone that would not say a thing in regards to "what am I doing where and how". But do share chunks of code that could be useful to someone else, hence the participation in this forum. Now is your turn to share what is your job environment and what is that you have in mind.1 point