Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/11/2020 in all areas

  1. Jon

    AutoIt v3.3.15.1 Beta

    AutoIt v3.3.15.1 Beta View File 3.3.15.1 (10th May, 2020) (Beta) AutoIt: - Changed: PCRE regular expression engine updated to 8.41. - Added #3741: GUISetStyle() example to avoid blank title bar. - Fixed #2806: GUICtrlCreateIcon() doc when filename="". - Fixed #3580: FileSetAttrib() crashing on root folders. - Fixed #3636: Applied the SS_NOPREFIX style to the SplashTextOn dialog to treat an ampersand in the 'text' parameter character in stead of a hotkey mnemonic prefix indicator. - Fixed #3689: GUICtrlSetOnEvent ( controlID, "" ) wasn't disabling the previous set UDF and returned error=1. - Fixed #3707: GUISetOnEvent($GUI_EVENT_CLOSE, "") wasn't disabling the previous set UDF and returned error=1. - Fixed: GUIOnEventMode and TrayOnEventMode options had unnecessary slow downs. - Fixed: Workarounds added to alleviate slow downs on Windows 10 1809 and later (OS bug/design change). AutoItX: - Changed: AutoItX .NET assembly updated to .NET 4.0 / CLR 4. - Changed: AutoIt PowerShell CmdLets updated to .NET 4.0 / CLR 4. - Changed: Updated C++ example. - Fixed #3642: ControlTreeView example. Au3Check: - Fixed #2822: object('item')('item') syntax support. - Fixed #3560: parentheses around function reference. UDFs: - Changed: slight improvement when _DebugReport() display "error code:" different from 0. - Changed: _WinAPI_Reg*() doc and examples. - Changed: _SQLite 3.22.0.0 -> 3.28.0.0. - Added: Extras\AutoUpdateIt\AutoSQLiteUpdateIt.au3 script to download sqlite dll's used by _SQLite_Startup(). - Added #3149: _SQLite_GetTableData2D() simplified version of _SQLite_GetTable2d() returning just data. - Added: RegWrite() doc and example about #requireAdmin. - Added: $ARRAYDISPLAY_ROWPREFIX to change the prefix of the row numbering in _ArrayDisplay(). - Added: _Assert() use if needed _DebugReport(). - Added #3027: _WinAPI_RegEnumKey() return the lastWriteTime of the subkey in @extended. - Added: _WinAPI_RegCreateKey() and _WinAPI_RegOpenkey() can use $hKey as in RegRead(). - Added: _WinAPI_RegDeleteKey() new parameter $iSamDesired. - Added: $ARRAYDISPLAY_CHECKERROR for _ArrayDisplay() avoid display after _Array*() errors. - Added: _DebugArrayDisplay() write a _DebugReport() if @error set when called. - Added: _WinAPI_ShellQueryRecycleBin() example. - Added: $REG_ERROR_MORE_DATA for _WinAPI_RegQueryValue(). - Added: _DebugReportVar() support Array 3D. - Added: _GUICtrl*() using GUICtrlInternals.au3 (Internal maintenability). - Added #3753: _GUICtrlListView_SetImageList sanity check on $iType parameter. - Fixed #3605: _GUICtrlListView_SetBkImage() does not accept control ID. - Fixed: _GUICtrlEdit_GetCueBanner() and _GUICtrlEdit_ShowBalloonTip() using Unicode string. - Fixed: Use _WinAPI_GetString() instead of _WinAPI_WideCharToMultiByte() to handle Unicode. - Fixed #3618: $tagNMLVKEYDOWN, $tagNMTVKEYDOWN, $tagNMTCKEYDOWN structure alignment. - Fixed #3619: _WinAPI_LocalFree() doc. - Fixed #3243: _WinAPI_MoveFileEx() if $sNewFile = 0 and $MOVE_FILE_DELAY_UNTIL_REBOOT - Fixed #3264: _INetSmtpMail() bad $sFirst default value. - Fixed #3265: _INetSmtpMail() bad Bias calculation. - Fixed: _WinAPI_GetErrorMessage(), _WinAPI_GetLastErrorMessage() returning @error. - Fixed: _WinAPI_GUIDFromStringEx() return on error. - Fixed: _WinAPI_EnumProcessHandles() seting @extended if too many Handles. - Fixed #3626: _WinAPI_GetSaveFileName() example. - Fixed: _WinAPI_RegQueryValue() wrong return on success and does not return error $ERROR_MORE_DATA - Fixed #3628: _WinAPI_GetCaretPos() bad return. - Fixed #3632: _Net_Share_ShareCheck() 2nd parameter is a $sResourcePath. - Fixed: _ArrayInsert() range element comparison datatype mismatch. - Fixed #3637: _ArrayDisplay() error when Array is empty and Range parameter exists. - Fixed #3657: _GUICtrlListView_SimpleSort selected item when no selection. - Fixed #3687: Corrected HSL constant values for RGB-HSL-RGB conversion. - Fixed #3699: _ArrayMin, _ArrayxMinIndex, _ArrayMax and _ArrayMinIndex examples - Fixed #3708: _WinAPI_LoadCursor() and _WinAPI_GetIconInfo() must use $OCR_* instead of $IDC_* that are used in AutoIt Mouse builtin. - Fixed #3711: _WinAPI_EnumWindows() and _WinAPI_EnumWindowsPopup() examples. - Fixed #3713: missing $ENM_NONE definition. - Fixed #3716: _ArrayToClip() example. - Fixed #3714: _GUICtrlTreeView_Sort() crash with 1 element TreeView. - Fixed #2962: GUICtrlSetImage() on GUICtrlCreatePIC() with $SS_SUNKEN or WS_EX_DLGMODALFRAME - Fixed #3744: _Crypt_DestroyKey() does not return error on wrong key. - Fixed: $LANG_FRENCH value in _WinAPILangConstants.au3. - Fixed #3733: _FileListToArrayRec() sometimes hanging when ".." filename was returned causing an endless recursion. - Fixed #3737: _ArrayUnique() failed with a single element array when using $iBase parameter. - Fixed #3755: _ArrayInsert/Delete $vRange delimited string failing. - Fixed: _GUICtrlTreeview_*() running in X64 mode. Submitter Jon Submitted 05/09/2020 Category Beta  
    4 points
  2. Hi everyone, Some good news for you among all the gloom of these virus-ridden times: Nine, Subz and Danyfirex have accepted the invitation to become MVPs. Please join me in congratulating them on their new status in our community. Keep safe out there, M23
    3 points
  3. UEZ

    Procedural Graphic using GDI+

    I was inspired by a CSS example to create a procedural graphic without any shader or ray tracing technique. Here the result using GDI+ only: Blue Orb.au3 ;Inspired from https://codepen.io/bradleytaunt/details/VwvzKyb ;Coded by UEZ build 2020-05-07 #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> If @OSBuild < 7600 Then Exit MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "ERROR", "This demo requires GDIPlus v1.1", 10) _GDIPlus_Startup() Global Const $iW = 1200, $iH = 700, $iSize_globe = 450 Global Const $hGUI = GUICreate("GDI+ Procedural Gfx / Blue Orb v1.20 by UEZ", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_TOPMOST) Global Const $hCanvas = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global Const $hImage = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Global Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hImage) _GDIPlus_GraphicsSetSmoothingMode($hGfx, $GDIP_SMOOTHINGMODE_ANTIALIAS8X8) ;~ _GDIPlus_GraphicsSetCompositingQuality($hGfx, $GDIP_COMPOSITINGQUALITYHIGHQUALITY) _GDIPlus_GraphicsSetInterpolationMode($hGfx, $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC) _GDIPlus_GraphicsSetPixelOffsetMode($hGfx, $GDIP_PIXELOFFSETMODE_HALF) ;draw background Global Const $hBrush_bg = _GDIPlus_LineBrushCreate($iW / 2, 0, $iW / 2, $iH / 2, 0xFF1E88E5, 0xFF1565C0, 2) _GDIPlus_LineBrushSetSigmaBlend ($hBrush_bg, 0.95, 1) ;create blurry edge _GDIPlus_GraphicsFillRect($hGfx, 0, 0, $iW, $iH, $hBrush_bg) ;draw blurred text Global Const $hImage_text = _GDIPlus_BitmapCreateFromScan0($iW, $iH / 2) Global Const $hGfx_text = _GDIPlus_ImageGetGraphicsContext($hImage_text) Global Const $hPath_text = _GDIPlus_PathCreate() Global Const $hFamily = _GDIPlus_FontFamilyCreate("Impact") Global Const $hStringFormat = _GDIPlus_StringFormatCreate() Global Const $hBrush_txt = _GDIPlus_LineBrushCreate($iW / 2, 0, $iW / 2, $iH / 2, 0xE0FFFFFF, 0xA01A237E) ;_GDIPlus_BrushCreateSolid(0xF02E86FB) _GDIPlus_LineBrushSetSigmaBlend($hBrush_txt, 0.66, 1) Global Const $hPen_txt = _GDIPlus_PenCreate(0x801A237E, 1) _GDIPlus_StringFormatSetAlign($hStringFormat, 1) _GDIPlus_StringFormatSetLineAlign($hStringFormat, 1) _GDIPlus_GraphicsSetSmoothingMode($hGfx_text, $GDIP_SMOOTHINGMODE_ANTIALIAS8X8) _GDIPlus_GraphicsSetTextRenderingHint($hGfx_text, $GDIP_TextRenderingHintAntialias) _GDIPlus_GraphicsSetPixelOffsetMode($hGfx_text, $GDIP_PIXELOFFSETMODE_HALF) _GDIPlus_GraphicsSetCompositingQuality($hGfx_text, $GDIP_COMPOSITINGQUALITYHIGHQUALITY) Global $tLayout = _GDIPlus_RectFCreate() $tLayout.width = $iW $tLayout.height = $iH / 2 $tLayout.y = -$iH * 0.05 _GDIPlus_PathAddString($hPath_text, "AutoIt rulez!", $tLayout, $hFamily, 0, $iW / 8, $hStringFormat) _GDIPlus_GraphicsFillPath($hGfx_text, $hPath_text, $hBrush_txt) _GDIPlus_GraphicsDrawPath($hGfx_text, $hPath_text, $hPen_txt) Global Const $hEffect_blur_text = _GDIPlus_EffectCreateBlur(20) _GDIPlus_BitmapApplyEffect($hImage_text, $hEffect_blur_text) _GDIPlus_GraphicsDrawImageRect($hGfx, $hImage_text, 0, 0, $iW, $iH / 2) ;draw shadow of the text Global Const $hBrush_txt_shadow = _GDIPlus_BrushCreateSolid(0x40000000) _GDIPlus_GraphicsClear($hGfx_text, 0) _GDIPlus_PathReset($hPath_text) $tLayout.width = $iW $tLayout.height = $iH / 2 $tLayout.y = 0 _GDIPlus_PathAddString($hPath_text, "AutoIt rulez!", $tLayout, $hFamily, 0, $iW / 8, $hStringFormat) _GDIPlus_GraphicsFillPath($hGfx_text, $hPath_text, $hBrush_txt_shadow) Global Const $hEffect_blur_text_shadow = _GDIPlus_EffectCreateBlur(60) _GDIPlus_BitmapApplyEffect($hImage_text, $hEffect_blur_text_shadow) _GDIPlus_GraphicsDrawImageRect($hGfx, $hImage_text, 0, $iH * 0.55, $iW, $iH / 8) ;draw shadow Global Const $iW_shadow1 = $iSize_globe * 0.85, $iH_shadow1 = $iSize_globe * 0.1, $iW_shadow2 = $iSize_globe * 0.60, _ $iW_shadow_Img = $iW_shadow1 * 2, $iH_shadowImg = $iH_shadow1 * 4 Global Const $hImage_shadow = _GDIPlus_BitmapCreateFromScan0($iW_shadow_Img, $iH_shadowImg) Global Const $hGfx_shadow = _GDIPlus_ImageGetGraphicsContext($hImage_shadow) _GDIPlus_GraphicsSetSmoothingMode($hGfx_shadow, $GDIP_SMOOTHINGMODE_ANTIALIAS8X8) Global Const $hBrush_shadow = _GDIPlus_BrushCreateSolid(0x66000000) _GDIPlus_GraphicsFillEllipse($hGfx_shadow, ($iW_shadow_Img - $iW_shadow1) / 2, ($iH_shadowImg / 4 + $iH_shadow1), $iW_shadow1, $iH_shadow1, $hBrush_shadow) _GDIPlus_BrushSetSolidColor($hBrush_shadow, 0xB3000000) _GDIPlus_GraphicsFillEllipse($hGfx_shadow, ($iW_shadow_Img - $iW_shadow2) / 2, ($iH_shadowImg / 4 + $iH_shadow1), $iW_shadow2, $iH_shadow1, $hBrush_shadow) Global Const $hEffect_blur_shadow = _GDIPlus_EffectCreateBlur(32) _GDIPlus_BitmapApplyEffect($hImage_shadow, $hEffect_blur_shadow) _GDIPlus_GraphicsDrawImageRect($hGfx, $hImage_shadow, ($iW - $iW_shadow_Img) / 2, $iH / 2 + $iH_shadow1 * 2.20, $iW_shadow_Img, $iH_shadowImg) ;draw globe Global Const $hPath_globe = _GDIPlus_PathCreate() _GDIPlus_PathAddEllipse($hPath_globe, ($iW - $iSize_globe) / 2, ($iH - $iSize_globe) / 2, $iSize_globe, $iSize_globe) Global Const $hLBrush_globe1 = _GDIPlus_LineBrushCreate($iW / 2, ($iH - $iSize_globe) / 2, $iW / 2, ($iH + $iSize_globe) / 2, 0, 0, 1) Global $aInterpolations[5][2] $aInterpolations[0][0] = 4 $aInterpolations[1][0] = 0xFFFFFFFF $aInterpolations[1][1] = 0 $aInterpolations[2][0] = 0xFFEEEEEE $aInterpolations[2][1] = 0.10 $aInterpolations[3][0] = 0xFF2E86FB $aInterpolations[3][1] = 0.50 $aInterpolations[4][0] = 0xFF1A237E $aInterpolations[4][1] = 1.0 _GDIPlus_LineBrushSetPresetBlend($hLBrush_globe1, $aInterpolations) _GDIPlus_GraphicsFillPath($hGfx, $hPath_globe, $hLBrush_globe1) Global Const $iSize_globe2 = $iSize_globe * 0.85, $iSize_globe2_Img = $iSize_globe2 * 1.5 Global Const $hImage_globe2 = _GDIPlus_BitmapCreateFromScan0($iSize_globe2_Img, $iSize_globe2_Img) Global Const $hGfx_globe2 = _GDIPlus_ImageGetGraphicsContext($hImage_globe2) Global Const $hBrush_globe2 = _GDIPlus_BrushCreateSolid(0x7F000000) ;draw shadow and blur it Global Const $px = ($iSize_globe2_Img - $iSize_globe2) / 2, $py = ($iSize_globe2_Img - $iSize_globe2) / 2 _GDIPlus_GraphicsFillEllipse($hGfx_globe2, $px, $py + ($iSize_globe - $iSize_globe2) * 0.25, $iSize_globe2, $iSize_globe2, $hBrush_globe2) Global Const $hEffect_blur_shadow2 = _GDIPlus_EffectCreateBlur(15) _GDIPlus_BitmapApplyEffect($hImage_globe2, $hEffect_blur_shadow2) ;draw 2nd smaller globe and blur it, too Global Const $hLBrush_globe2 = _GDIPlus_LineBrushCreate($iW / 2, $py, $iW / 2, $py + $iSize_globe2, 0, 0) Dim $aInterpolations[4][2] $aInterpolations[0][0] = 3 $aInterpolations[1][0] = 0xFFFFFFFF $aInterpolations[1][1] = 0 $aInterpolations[2][0] = 0xFF2E86FB $aInterpolations[2][1] = 0.60 $aInterpolations[3][0] = 0xFF283593 $aInterpolations[3][1] = 1.0 _GDIPlus_LineBrushSetPresetBlend($hLBrush_globe2, $aInterpolations) _GDIPlus_GraphicsFillEllipse($hGfx_globe2, $px, $py, $iSize_globe2, $iSize_globe2, $hLBrush_globe2) Global Const $hImage_globe2_blur = _Blur($hImage_globe2, $iSize_globe, $iSize_globe) ;windows gdi+ blur doesn't work properly _GDIPlus_GraphicsDrawImageRect($hGfx, $hImage_globe2_blur, ($iW - $iSize_globe2_Img) / 2 - ($iSize_globe - $iSize_globe2) / 8, ($iH - $iSize_globe2_Img) / 2, $iSize_globe2_Img, $iSize_globe2_Img) GUISetState() _GDIPlus_GraphicsDrawImageRect($hCanvas, $hImage, 0, 0, $iW, $iH) ;~ _GDIPlus_ImageSaveToFile($hImage, @ScriptDir & "\Blue Orb v1.20.png") ;clean-up ressources _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hStringFormat) _GDIPlus_EffectDispose($hEffect_blur_text) _GDIPlus_EffectDispose($hEffect_blur_text_shadow) _GDIPlus_EffectDispose($hEffect_blur_shadow) _GDIPlus_EffectDispose($hEffect_blur_shadow2) _GDIPlus_PathDispose($hPath_text) _GDIPlus_PathDispose($hPath_globe) _GDIPlus_PenDispose($hPen_txt) _GDIPlus_BrushDispose($hBrush_txt) _GDIPlus_BrushDispose($hBrush_txt_shadow) _GDIPlus_BrushDispose($hBrush_bg) _GDIPlus_BrushDispose($hLBrush_globe1) _GDIPlus_BrushDispose($hLBrush_globe2) _GDIPlus_BrushDispose($hBrush_globe2) _GDIPlus_ImageDispose($hImage) _GDIPlus_ImageDispose($hImage_text) _GDIPlus_ImageDispose($hImage_shadow) _GDIPlus_ImageDispose($hImage_globe2) _GDIPlus_ImageDispose($hImage_globe2_blur) _GDIPlus_GraphicsDispose($hCanvas) _GDIPlus_GraphicsDispose($hGfx_text) _GDIPlus_GraphicsDispose($hGfx_shadow) _GDIPlus_GraphicsDispose($hGfx_globe2) _GDIPlus_Shutdown() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete($hGUI) Exit Func _Blur($hBitmap, $iW, $iH, $fScale = 0.0525, $dx1 = 0, $dy1 = 0, $dx2 = 0, $dy2 = 0, $qual = 6) ; by eukalyptus Local $hBmpSmall = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local $hGfxSmall = _GDIPlus_ImageGetGraphicsContext($hBmpSmall) _GDIPlus_GraphicsSetPixelOffsetMode($hGfxSmall, $GDIP_PIXELOFFSETMODE_HALF) Local $hBmpBig = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local $hGfxBig = _GDIPlus_ImageGetGraphicsContext($hBmpBig) _GDIPlus_GraphicsSetPixelOffsetMode($hGfxBig, $GDIP_PIXELOFFSETMODE_HALF) _GDIPlus_GraphicsScaleTransform($hGfxSmall, $fScale, $fScale) _GDIPlus_GraphicsSetInterpolationMode($hGfxSmall, $qual) _GDIPlus_GraphicsScaleTransform($hGfxBig, 1 / $fScale, 1 / $fScale) _GDIPlus_GraphicsSetInterpolationMode($hGfxBig, $qual) _GDIPlus_GraphicsDrawImageRect($hGfxSmall, $hBitmap, 0, $dx1, $iW, $iH + $dy1) _GDIPlus_GraphicsDrawImageRect($hGfxBig, $hBmpSmall, 0, $dx2, $iW, $iH + $dy2) _GDIPlus_BitmapDispose($hBmpSmall) _GDIPlus_GraphicsDispose($hGfxSmall) _GDIPlus_GraphicsDispose($hGfxBig) Return $hBmpBig EndFunc ;==>_Blur I hope you like it. Feel free to post your examples here, too.
    2 points
  4. "Once upon a time ..." than I've made the following: But now exist a new version of the "quricol.dll" for 32 and 64 bit. All parameters can be used now. In the old thread you can see, that is implemented with the help of @TheXman . Thanks for that. Then I revised the GUI and I came up with new possibilities. This has now resulted in a much more powerful tool, which is why I decided to create a new thread on this topic. There are 3 components:     QRCreator.au3         This is the base UDF that need for all. You can write your own applications by using it.     QRCreatorUI         This is the graphical User Interface to deal with all functions of the UDF.         As a special feature, you have a preview that can be enlarged.     QRCreatorCI         This is the Commandline Interface.          With the exception of HBITMAP generation, which is not required on the command line, you can perform all functions of the UDF to generate QR codes. Here more in detail: QRCreator.au3 - functions   _QR_generatePNG        Generates the QR-Code as PNG file for the passed text.   _QR_generateBMP        Generates the QR-Code as BMP file for the passed text.   _QR_getHBitmap        Creates a HBITMAP handle for the QR-Code for the passed text.         Don't forget to delete it, if no more need (_WinAPI_DeleteObject(HBITMAP)).   _QR_copyToClipboard        Copies the QR-Code picture for the passed text to the clipboard.   _QR_FileDefault       Generates a default filename (QR_YYYYMMDD_hhmmss)   _QR_getLastCall()      Asks for the result of the last call (_QR_getHBitmap/_QR_copyToClipboard/_QR_generateBMP/_QR_generatePNG)      Gets a structure with: .success(1/0) .error(@error) .width .type(B/C/[F/R]) .output(hBMP/''/fullpath) .margin .sizept .corrlevel      Types(.type): B (HBITMAP), C (Clipboard), F (File created), R (resized file created) The following parameters will used:   $_sText     The text to encode. Full unicode is supported.   $_sPathOut (ONLY: _QR_generatePNG und _QR_generateBMP)     The full path of the file to create. If only a filename has passed the @ScriptDir will used.     Without a filename the default filename will used (QR_YYYYMMDD_hhmmss).     If the filename exists, it will get a suffix (1..n) until it's unique.   $_iMargin       The QR-Code margin in px   $_iSizePt       Size of the points in the QR-Code (1-4, depends by the correction level)     If a wrong value is passed, it will corrected by the script.   $_iCorrLvl       The used correction level (0-3). Allows to read a QR-Code if some parts damaged.   $_iOutSize (ONLY: _QR_generatePNG und _QR_generateBMP)     As a new feature you can pass a target size for created file.      The size of the file depends by used correction level and the size of created points.      If you pass a value for width (and so for heigth too), the default by the dll created file will resized for this size.      If the passed size is to small it raises an error.   $_iScale (ONLY: _QR_copyToClipboard)     Also new is the ability to scale up the QR-Code copied to clipboard.      It's a factor for linear scaling, based on the default creation size by the dll call. QRCreatorUI.au3   All information for the actions you've done will shown in the statusbar of the GUI.    But this is my own statusbar, that allows formatting. I've attached them too. QRCreatorCI   available command line parameters   ---------------------------------------------------------------------------------------------------------------    REQUIRED NEW: Passing multi-line text via command line break=Placeholder character for a line break (default is ^) Must only be set if the default value is not to be used. For single-line text that contains the default placeholder, set "break=none"! If break is set, this must always be the first parameter!      text=Text for encoding    OPTIONAL      file=path/filename[.ext]  - If ommited, the default will used: @HomeDrive & @HomePath & "\QR_YYYYMMDD_hhmmss"      type=png,bmp,clip         - If ommited, 'png' will used. With clip runs CopyToClipboard.           or combined png/bmp    If file has .ext and type is passed but is different to .ext than will used type      width=int                 - (and height) initializes a resizing of the default created QR-Code                                  Resizing fails, if passed size is smaller as the default generated file.                                REMARK: Only for file creation      scale=int                 - Factor for up scaling the QR-Code                                REMARK: Only for CopyToClipboard      margin=4                  - The margin around the QR-Code in px (Default = 4)      corrlevel=0               - Up to 7%, 15%, 25% or 30% damage [0, 1, 2, 3]. (Default = 0)      sizept=2                  - The size of the painted pixel itself. The value depends on the correction level.                                  Only the smallest point size can be used for the largest correction level.                                  The value will corrected automatically, if wrong.   ---------------------------------------------------------------------------------------------------------------   return values   ---------------------------------------------------------------------------------------------------------------   comma separated string with:     ERROR=@error     RESULT='FullFilePath' or 'CLIPBOARD'     SIZE=width x heigth     SIZEPT=The really used (may be corrected) size of point     MARGIN=The used margin size     CORRLEVEL=The used correction level   --------------------------------------------------------------------------------------------------------------- You find all the stuff also in the function headers. So that you get an impression, here are a few pictures. Gallery QRCode.zip QRCreatorUI.au3 QRCreatorCI.au3
    1 point
  5. Nine

    GIF Animation (cached)

    I had this GIF animation script, but it was kind of slow when multiple GIFs were displayed. And then Bilgus posted a framework of how to use GDI+ Cached Bitmaps. I transformed my script and was very happy of the result. Hope you like it too. I enclosed the GIF, the UDF and the example into the zip file. ps. Hope KaFu won't mind as I used his avatar in the example Version 2023-08-15 * Added support for SetOnEvent GUI, while deletion of controls happens frequently * Optimized some minor code parts * Solved a possible stack overflow issue Version 2022-12-06 * Added support to transparent GIF over window background. The type of GIF that necessitate erasure between frames. Version 2022-04-07 * Added double buffering for all GIF * Added ability to erase each frame before repainting, thru a new optional parameter. This is required when the frames do not cover the whole area, leaving a trace of the previous frame. * Added support for the usage of the Default keyword for optional parameters Version 2020-12-20 * Changed frame delays from 0 to a minimum delay to prevent CPU overload Version 2020-12-02 * Reuse empty slots left by the deletion of GIF controls * Corrected bugs Version 2020-12-01 * Added support to delete a GIF control Version 2020-11-29 * Corrected bug on unregister adlib function (thanks to PixelSearch) Included in the zip file 2 examples. One with multiple GIF. Second with transparent GIF over a window background. Cached GIF Animation.zip
    1 point
  6. The Running Object Table (ROT) is a system global table where objects can register themselves. This makes the objects accessible in processes other than the process where the object was created. IRunningObjectTable and related interfaces provides access to register and maintain objects in the ROT. ThreadsOther threads related to ROT objects: Non-blocking data display functions IPC Techniques through ROT Objects AutoIt and Perl integration through ROT objects Access AutoIt by trancexx is about executing AutoIt commands in other programming languages. The AutoIt command is executed by calling a Call method of the ROT object. The example is based on the AutoItObject UDF. Posts (2021-01-03)This is a list of the most interesting posts below: Usage section with typical examples of the use of ROT objects with the following subsections: Passing array between AutoIt programs Passing array between AutoIt and VBScript Passing data through ROT Objects Executing Object Methods through VBScript VBScript (2021-01-03)VBScript is used as a consistent programming language to demonstrate the ROT technique for communicating between AutoIt and other languages. This is a list of the VBScript posts: Passing array between AutoIt and VBScript (in middle of post) Executing Object Methods through VBScript BasicRegister an objectExamples\1) Basic\0) ROT_RegisterObject.au3 #include <Array.au3> #include "..\..\Includes\IRunningObjectTable.au3" Example() Func Example() Local $sNameId = "DataTransferObject" & ROT_CreateGUID() Local $iHandle = ROT_RegisterObject( Default, $sNameId ) ; Default => Object = Dictionary object If Not $iHandle Then Return ConsoleWrite( "ROT_RegisterObject ERR" & @CRLF ) ConsoleWrite( "ROT_RegisterObject OK" & @CRLF ) Local $aROT_List = ROT_Enumerate() _ArrayDisplay( $aROT_List, "ROT_RegisterObject" ) EndFunc Output in _ArrayDisplay looks like this: DataTransferObject-{05DCB964-FD4B-40EC-A95A-999491347D20} $sNameId (similar to ProgID) is the identification of the ROT object and is used in the ObjGet() function to access the object in this way: Local $oDataTransferObject = ObjGet( "DataTransferObject-{05DCB964-FD4B-40EC-A95A-999491347D20}" ) ROT_CreateGUID() is used to make $sNameId unique. See below. ROT_RegisterObject() is the function that registers the object in the ROT. The Dictionary object is the actual object that is registered in the ROT. The Add method allows you to add a new key/item pair to the object. The key is often a string. The item property can be any COM compatible data type which includes most AutoIt data types. An exception is the DllStruct type which must be converted to a compatible type. Because many different data types can be used in the item property and the item can be identified through a key, the Dictionary object is generally applicable for many different purposes. More information about registering objects in the ROT can be found in this Microsoft documentation. ROT_Enumerate() enumerate the objects, that are registered in the ROT. The program that registers an object in the ROT plays the role of server. One or more programs that access the ROT object with the ObjGet() function play the role of clients. The ROT object is only available as long as the server program is running or until the server program deletes the object with the ROT_Revoke() function. You can find examples of using the functions in Examples\1) Basic\. ROT objects (2020-07-11)The Dictionary object is the default object in the ROT_RegisterObject() function. The object that's passed to this function is the actual object that's registered in the ROT. The Dictionary object works fine when passing data between AutoIt scripts, between AutoIt and VBScript, and between AutoIt and Perl. However, situations may easily arise where it can be an advantage to pass data with a very simple object with just a single property. There are several options for creating such a simple object. This can be done through C# and VB.NET code, as demonstrated in Using C# and VB Code in AutoIt through .NET Framework. And it can be done through the AutoItObject UDF. Examples\4) ROT Objects\ contains examples for creating the ROT object in these three ways. Client.au3 is the same script in all examples: #include <Array.au3> Example() Func Example() Local $sNameId = "DataTransfer" Local $oDataTransfer = ObjGet( $sNameId ) Local $aArray = $oDataTransfer.Item _ArrayDisplay( $aArray ) EndFunc Create object with C# code CSharp\Server.au3: #include "..\..\..\Includes\IRunningObjectTable.au3" #include "..\DotNetAll.au3" Example() Func Example() Local $aArray[1000][10] For $i = 0 To 1000 - 1 For $j = 0 To 10 - 1 $aArray[$i][$j] = $i & "/" & $j Next Next Local $oNetCode = DotNet_LoadCScode( FileRead( "Object.cs" ), "System.dll" ) Local $oCSObject = DotNet_CreateObject( $oNetCode, "CSObjClass" ) $oCSObject.Item = $aArray Local $sNameId = "DataTransfer" ROT_RegisterObject( Ptr( $oCSObject ), $sNameId ) RunWait( @AutoItExe & " /AutoIt3ExecuteScript " & "Client.au3" ) EndFunc CSharp\Object.cs: using System; public class CSObjClass { public object Item { get; set; } } Create object with VB.NET code VB.NET\Server.au3: #include "..\..\..\Includes\IRunningObjectTable.au3" #include "..\DotNetAll.au3" Example() Func Example() Local $aArray[1000][10] For $i = 0 To 1000 - 1 For $j = 0 To 10 - 1 $aArray[$i][$j] = $i & "/" & $j Next Next Local $oNetCode = DotNet_LoadVBcode( FileRead( "Object.vb" ), "System.dll" ) Local $oVBObject = DotNet_CreateObject( $oNetCode, "VBObjClass" ) $oVBObject.Item = $aArray Local $sNameId = "DataTransfer" ROT_RegisterObject( Ptr( $oVBObject ), $sNameId ) RunWait( @AutoItExe & " /AutoIt3ExecuteScript " & "Client.au3" ) EndFunc VB.NET\Object.vb: Imports System Public Class VBObjClass Public Property Item As Object End Class In AutoIt/Perl integration, the very first attempts were performed with the VB.NET object. Check for recognition of the ROT object with this Client.pl script (copied from the AutoIt/Perl example) : use strict; use Win32::OLE; my $oObj = Win32::OLE->GetObject( "DataTransfer" ); Win32::OLE->EnumAllObjects( sub { my $Object = shift; my $Class = Win32::OLE->QueryObjectType( $Object ); printf "Object = %s, Class = %s\n", $Object, $Class; } ); Gave the following output: Object = Win32::OLE=HASH(0x72a51c), Class = _VBObjClass ; VB.NET object Object = Win32::OLE=HASH(0x71b5a8), Class = IDictionary ; Dictionary object Create object with AutoItObject AutoItObject\Server.au3: #include "..\..\..\Includes\IRunningObjectTable.au3" #include "AutoitObject.au3" Example() Func Example() Local $aArray[1000][10] For $i = 0 To 1000 - 1 For $j = 0 To 10 - 1 $aArray[$i][$j] = $i & "/" & $j Next Next _AutoItObject_StartUp() Local $oObject = NewObject(), $sNameId = "DataTransfer" ROT_RegisterObject( Ptr( $oObject ), $sNameId ) Local $oDataTransfer = ObjGet( $sNameId ) $oDataTransfer.Item = $aArray RunWait( @AutoItExe & " /AutoIt3ExecuteScript " & "Client.au3" ) _AutoItObject_Shutdown() EndFunc Func NewObject() Local $oClassObject = _AutoItObject_Class() $oClassObject.AddProperty( "Item" ) Return $oClassObject.Object EndFunc Unique objectsWhen using ROT objects in real code, there is a particular question that needs to be addressed. The question is how to make sure that $sNameId, which clients use to access the object with the ObjGet() function, actually identifies a unique object. Running a server program twice in succession can easily create two ROT objects with the same $sNameId. But how do you actually access the ROT object that was created first and the ROT object that was created last? The answer to the question is to make sure that $sNameId also becomes unique so that you can distinguish between the two objects. To that end, the ROT_CreateGUID() function is created (copy of _WinAPI_CreateGUID()). The function can ensure a unique $sNameId as shown in the example above. The problem and solution is demonstrated in Examples\1) Basic\2) Multiple ROT objects.au3. Time stampsUsing the NoteChangeTime() and GetTimeOfLastChange() methods of the IRunningObjectTable interface, you can set and get timestamps on a ROT object. But these timestamps do not seem particularly useful. Therefore, the methods are not implemented. The UDFThe IRunningObjectTable UDF, Includes\IRunningObjectTable.au3, is a very small UDF with less than 150 lines of code: #include-once ; --- Interface definitions --- Global Const $sIID_IRunningObjectTable = "{00000010-0000-0000-C000-000000000046}" Global Const $dtag_IRunningObjectTable = _ "Register hresult(dword;ptr;ptr;dword*);" & _ "Revoke hresult(dword);" & _ "IsRunning hresult(ptr);" & _ "GetObject hresult(ptr;ptr*);" & _ "NoteChangeTime hresult(dword;struct*);" & _ "GetTimeOfLastChange hresult(ptr;ptr*);" & _ "EnumRunning hresult(ptr*);" Global Const $ROTFLAGS_REGISTRATIONKEEPSALIVE = 0x1 Global Const $ROTFLAGS_ALLOWANYCLIENT = 0x2 Global Const $sIID_IEnumMoniker = "{00000102-0000-0000-C000-000000000046}" Global Const $dtag_IEnumMoniker = _ "Next hresult(ulong;ptr*;ulong*);" & _ "Skip hresult(ulong);" & _ "Reset hresult();" & _ "Clone hresult(ptr*);" Global Const $sIID_IPersist = "{0000010C-0000-0000-C000-000000000046}" Global Const $dtag_IPersist = _ "GetClassID hresult(ptr*);" Global Const $sIID_IPersistStream = "{00000109-0000-0000-C000-000000000046}" Global Const $dtag_IPersistStream = $dtag_IPersist & _ "IsDirty hresult();" & _ "Load hresult(ptr);" & _ "Save hresult(ptr;bool);" & _ "GetSizeMax hresult(uint*);" Global Const $sIID_IMoniker = "{0000000F-0000-0000-C000-000000000046}" Global Const $dtag_IMoniker = $dtag_IPersistStream & _ "BindToObject hresult();" & _ "BindToStorage hresult();" & _ "Reduce hresult();" & _ "ComposeWith hresult();" & _ "Enum hresult();" & _ "IsEqual hresult();" & _ "Hash hresult();" & _ "IsRunning hresult(ptr;ptr;ptr);" & _ "GetTimeOfLastChange hresult(ptr;ptr;ptr);" & _ "Inverse hresult();" & _ "CommonPrefixWith hresult();" & _ "RelativePathTo hresult();" & _ "GetDisplayName hresult(ptr;ptr;wstr*);" & _ "ParseDisplayName hresult();" & _ "IsSystemMoniker hresult(ptr*);" ; --- Windows API functions --- Func ROT_GetRunningObjectTable() Return DllCall( "Ole32.dll", "long", "GetRunningObjectTable", "dword", 0, "ptr*", 0 )[2] EndFunc Func ROT_CreateFileMoniker( $sNameId ) Return DllCall( "Ole32.dll", "long", "CreateFileMoniker", "wstr", $sNameId, "ptr*", 0 )[2] EndFunc Func ROT_CreateBindCtx() Return DllCall( "Ole32.dll", "long", "CreateBindCtx", "dword", 0, "ptr*", 0 )[2] EndFunc ; --- UDF functions --- ; Failure: Returns 0 ; Success: Returns $iHandle ; Registers an object and its identifying moniker in the ROT Func ROT_RegisterObject( $pObject, $sNameId, $iFlags = $ROTFLAGS_REGISTRATIONKEEPSALIVE ) If $pObject = Default Then Local $oDict = ObjCreate( "Scripting.Dictionary" ) $pObject = Ptr( $oDict ) EndIf If Not $pObject Or Not $sNameId Then Return 0 Local $oRunningObjectTable = ObjCreateInterface( ROT_GetRunningObjectTable(), $sIID_IRunningObjectTable, $dtag_IRunningObjectTable ) If Not IsObj( $oRunningObjectTable ) Then Return 0 Local $pMoniker = ROT_CreateFileMoniker( $sNameId ) If Not $pMoniker Then Return 0 Local $iHandle $oRunningObjectTable.Register( $iFlags, $pObject, $pMoniker, $iHandle ) Return $iHandle ? $iHandle : 0 EndFunc ; Returns unique GUID as string ; Copied from _WinAPI_CreateGUID Func ROT_CreateGUID() Local Static $tGUID = DllStructCreate( "struct;ulong Data1;ushort Data2;ushort Data3;byte Data4[8];endstruct" ) DllCall( "Ole32.dll", "long", "CoCreateGuid", "struct*", $tGUID ) Return "-" & DllCall( "Ole32.dll", "int", "StringFromGUID2", "struct*", $tGUID, "wstr", "", "int", 65536 )[2] EndFunc ; Failure: Returns 0 ; Success: Returns $aROT_List ; Enumerates objects and identifying monikers in the ROT Func ROT_Enumerate() Local $oRunningObjectTable = ObjCreateInterface( ROT_GetRunningObjectTable(), $sIID_IRunningObjectTable, $dtag_IRunningObjectTable ) If Not IsObj( $oRunningObjectTable ) Then Return 0 Local $pEnumMoniker $oRunningObjectTable.EnumRunning( $pEnumMoniker ) Local $oEnumMoniker = ObjCreateInterface( $pEnumMoniker, $sIID_IEnumMoniker, $dtag_IEnumMoniker ) If Not IsObj( $oEnumMoniker ) Then Return 0 Local $pMoniker, $oMoniker, $pBindCtx, $sMonikerName, $i = 0 Local $oDict = ObjCreate( "Scripting.Dictionary" ) While( $oEnumMoniker.Next( 1, $pMoniker, NULL ) = 0 ) $pBindCtx = ROT_CreateBindCtx() $oMoniker = ObjCreateInterface( $pMoniker, $sIID_IMoniker, $dtag_IMoniker ) $oMoniker.GetDisplayName( $pBindCtx, NULL, $sMonikerName ) $oDict.Add( "Key" & $i, $sMonikerName ) $i += 1 WEnd Local $aROT_List = $oDict.Items() Return $aROT_List EndFunc ; Failure: Returns 0 ; Success: Returns 1 ; Removes an object and its identifying moniker from the ROT Func ROT_Revoke( $iHandle ) If Not $iHandle Then Return 0 Local $oRunningObjectTable = ObjCreateInterface( ROT_GetRunningObjectTable(), $sIID_IRunningObjectTable, $dtag_IRunningObjectTable ) If Not IsObj( $oRunningObjectTable ) Then Return 0 Return Not $oRunningObjectTable.Revoke( $iHandle ) * 1 EndFunc 7z-fileThe 7z-file contains source code for the UDF and examples. You need AutoIt 3.3.12 or later. Tested on Windows 7 and Windows 10. Comments are welcome. Let me know if there are any issues. IRunningObjectTable.7z
    1 point
  7. water

    While loop doesn't exit

    Why not simply leave the loop like this: While 1 $Question1 = InputBox("Question 1","Question 1? :") If $Question1 <> $Reponse1 Then ExitLoop $Question2 = InputBox("Question 2", "Question 2 :") if $Question2 <> $Reponse2 Then ExitLoop $Question3 = InputBox("Question 3","Question 2 :") If $Question3 <> $Reponse3 Then ExitLoop MsgBox(0, "Resultat", "votre score est :", $false) WEnd
    1 point
  8. Melba23

    While loop doesn't exit

    Nina, Welcome to the AutoIt forum. Your code does exit the While...WEnd loop when $false = 1, but only when it reaches the WEnd line and so after you have answered all the questions. If you want to exit the loop directly after a false response, then you need to use ExitLoop in place of the $false = 1 line. And I am not sure quite why you have $false in your MsgBox line - at present you are using it to give a 1 second timeout if a false response has been given, which i am pretty sure is not what you want. If you want to give a score then you will need to increase $false with each error ($false += 1) and then call the MsgBox like this: sgBox(0, "Resultat", "votre score est : " & 3 - $false) Please ask again if you have further questions. M23
    1 point
  9. Jon

    File location best practices?

    Section 10 https://docs.microsoft.com/en-us/windows/win32/win_cert/certification-requirements-for-windows-desktop-apps#10-apps-must-install-to-the-correct-folders-by-default
    1 point
  10. Jos

    Congrats to the New MVPs

    Welcome to " the other side" Jos
    1 point
  11. I was able to create a 4096 bytes version using FreeBasic and UPX - with Crinkler even 2103 Bytes! Click me to download the executables if you are interessted.
    1 point
  12. thx so much u all guys with your help I created the first own 2d variable in autoit career xD xD xD I'm still afraid there are some mistakes but looking good for now #include <GUIConstants.au3> #include <GuiListView.au3> $GUI = GUICreate("gui") GUISetState() $ListView = GUICtrlCreateListView("Name1|Name2|Surrealneme3|", 10, 10, 250, 350, $LVS_SHOWSELALWAYS) _GUICtrlListView_SetExtendedListViewStyle($ListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES)) _GUICtrlListView_SetColumnWidth($ListView, 10, 0) $LV = GUICtrlGetHandle($ListView) For $i = 0 To 9 GUICtrlCreateListViewItem("name" & $i & "|surname" & $i & "|surrealizm" & $i, $ListView) Next $button_copy = GUICtrlCreateButton("Copy", 300, 70, 70, 25) $button_paste = GUICtrlCreateButton("Paste", 300, 100, 70, 25) $button_exit = GUICtrlCreateButton("Exit", 300, 200, 70, 30) While 1 Switch GUIGetMsg() Case $button_exit, $GUI_EVENT_CLOSE Exit Case $button_copy ; how to modify it to store more then 1 selected item Local $Selected[_GUICtrlListView_GetSelectedCount($LV)][_GUICtrlListView_GetColumnCount($LV)] $k = -1 For $i = 0 To _GUICtrlListView_GetitemCount($LV)-1 If _GUICtrlListView_GetItemSelected($LV, $i) Then $k +=1 For $j = 0 To _GUICtrlListView_GetColumnCount($LV) - 1 $Selected[$k][$j] = _GUICtrlListView_GetItemText($LV, $i, $j) Next EndIf Next Case $button_paste $var = _GUICtrlListView_GetSelectionMark($LV) For $i = 0 To UBound($Selected)-1 _GUICtrlListView_InsertItem($LV,$Selected[$i][0],$var+$i+1) For $j = 0 To _GUICtrlListView_GetColumnCount($LV) - 1 _GUICtrlListView_AddSubItem($LV, $var+$i+1, $Selected[$i][$j], $j) Next Next _GUICtrlListView_ClickItem($LV,$var + UBound($Selected)) EndSwitch WEnd
    1 point
  13. Sniperwolf

    hide password input

    Hi there, I have created a input for a password. The problem I have now is that everyone can see the password in the input during all the time the script is running, can you star it out? Like instead of autoit it shows ******, or something like that.
    1 point
  14. Luig

    AutoChip

    Alright I attempted to port a chip8 emulator in vb6 to autoit. The result is AutoChip. Although it isn't fully functional its a start. It seems to emulate sound correctly but something went wrong in the video. The result varies with different roms. Haven't implemented input yet. My hope is that it can be written in pure autoit if not I will have to code a lib for it in Delphi since I am not fluent in C. Chip8 UDF: #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.6.1 Author: Luig Script Function: CHIP8 Emulator Internal Functions. #ce ---------------------------------------------------------------------------- #include-once #include <GuiConstantsEx.au3> #include <GDIPlus.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> Dim $ram[8193] Dim $stack[257] Dim $v[257] Dim $keydef[17] Global $opcode1, $opcode2, $opcode3, $opcode4, $sp, $key_up, $key_down Global $delaytimer, $soundtimer, $x, $y, $i, $j, $dbg, $Pause, $pc, $Index Global $key_choice $keydef[1] = 103 $keydef[2] = 104 $keydef[3] = 105 $keydef[4] = 100 $keydef[5] = 101 $keydef[6] = 102 $keydef[7] = 97 $keydef[8] = 98 $keydef[9] = 99 $keydef[10] = 96 $keydef[11] = 111 $keydef[12] = 106 $keydef[13] = 107 $keydef[14] = 13 $keydef[15] = 103 $keydef[16] = 110 $dbg = True If $dbg Then $Debug = GUICreate("Debug", 387, 211, 192, 124) $Edit1 = GUICtrlCreateEdit("", 0, 0, 385, 209) GUISetState(@SW_SHOW) EndIf _GDIPlus_Startup() Global $hScreen Global $Black = _GDIPlus_PenCreate(0xFF00FF00) Global $White = _GDIPlus_PenCreate(0xFFFFFFFF) Func OpenRom($File) $a = 1 For $i = 1 to StringLen($File) $ram[0x200 - 1 + $i] = '0x' & StringMid($File, $a, 2) $a += 2 Next Restart_CPU() EndFunc Func Restart_CPU() $pc = 0x200 $ram[0x1000] = 96 $ram[0x1001] = 144 $ram[0x1002] = 144 $ram[0x1003] = 144 $ram[0x1004] = 96 $ram[0x1005] = 96 $ram[0x1006] = 224 $ram[0x1007] = 96 $ram[0x1008] = 96 $ram[0x1009] = 240 $ram[0x100A] = 96 $ram[0x100B] = 144 $ram[0x100C] = 32 $ram[0x100D] = 64 $ram[0x100E] = 240 $ram[0x100F] = 224 $ram[0x1010] = 16 $ram[0x1011] = 96 $ram[0x1012] = 16 $ram[0x1013] = 224 $ram[0x1014] = 160 $ram[0x1015] = 160 $ram[0x1016] = 240 $ram[0x1017] = 32 $ram[0x1018] = 32 $ram[0x1019] = 240 $ram[0x101A] = 128 $ram[0x101B] = 240 $ram[0x101C] = 16 $ram[0x101D] = 240 $ram[0x101E] = 240 $ram[0x101F] = 128 $ram[0x1020] = 240 $ram[0x1021] = 144 $ram[0x1022] = 240 $ram[0x1023] = 240 $ram[0x1024] = 16 $ram[0x1025] = 32 $ram[0x1026] = 64 $ram[0x1027] = 128 $ram[0x1028] = 96 $ram[0x1029] = 144 $ram[0x102A] = 96 $ram[0x102B] = 144 $ram[0x102C] = 96 $ram[0x102D] = 240 $ram[0x102E] = 144 $ram[0x102F] = 240 $ram[0x1030] = 16 $ram[0x1031] = 240 $ram[0x1032] = 96 $ram[0x1033] = 144 $ram[0x1034] = 240 $ram[0x1035] = 144 $ram[0x1036] = 144 $ram[0x1037] = 224 $ram[0x1038] = 144 $ram[0x1039] = 224 $ram[0x103A] = 144 $ram[0x103B] = 224 $ram[0x103C] = 112 $ram[0x103D] = 128 $ram[0x103E] = 128 $ram[0x103F] = 128 $ram[0x1040] = 112 $ram[0x1041] = 224 $ram[0x1042] = 144 $ram[0x1043] = 144 $ram[0x1044] = 144 $ram[0x1045] = 224 $ram[0x1046] = 240 $ram[0x1047] = 128 $ram[0x1048] = 224 $ram[0x1049] = 128 $ram[0x104A] = 240 $ram[0x104B] = 240 $ram[0x104C] = 128 $ram[0x104D] = 224 $ram[0x104E] = 128 $ram[0x104F] = 128 Emulate_CPU() EndFunc Func Emulate_CPU() Sleep(10) If $delaytimer > 1 Then $delaytimer -= 1 If $Pause = False Then Interpret() EndFunc Func getopcode() $opcode1 = BitAND($ram[$pc], 0xF0) $opcode1 /= 2 $opcode1 /= 2 $opcode1 /= 2 $opcode1 /= 2 $opcode2 = BitAND($ram[$pc], 0xF) $opcode3 = BitAND($ram[$pc + 1], 0xF0) $opcode3 /= 2 $opcode3 /= 2 $opcode3 /= 2 $opcode3 /= 2 $opcode4 = BitAND($ram[$pc + 1], 0xF) $pc += 2 EndFunc Func Timer() If $delaytimer > 0 Then $delaytimer = $delaytimer - 1 If $soundtimer > 0 Then $soundtimer = $soundtimer - 1 Beep(500, $soundtimer * 10) $soundtimer = 0 EndIf EndFunc Func Interpret() getopcode() If $dbg Then Print(($pc - 2) & ': ' & $opcode1 & ' ' & $opcode2 & ' ' & $opcode3 & ' ' & $opcode4) Switch $opcode1 Case 0x00 Switch $opcode3 Case 0x0E Switch $opcode4 Case 0x00 If $dbg Then Print('ClearScreen') ClearScreen() Case 0x0E If $dbg Then Print('ReturnFromSub') ReturnFromSub() EndSwitch EndSwitch Case 0x01 If $dbg Then Print('JumpToAddress') JumpToAddress() Case 0x02 If $dbg Then Print('JumpToSub') JumpToSub() Case 0x03 If $dbg Then Print('SkipIfRegEqual') SkipIfRegEqual() Case 0x04 If $dbg Then Print('SkipIfRegNotEqual') SkipIfRegNotEqual() Case 0x05 If $dbg Then Print('SkipIfRegEqualReg') SkipIfRegEqualReg() Case 0x06 If $dbg Then Print('LoadRegWithConstant') LoadRegWithConstant() Case 0x07 If $dbg Then Print('AddConstantToReg') AddConstantToReg() Case 0x08 Switch $opcode4 Case 0x00 If $dbg Then Print('LoadRegWithReg') LoadRegWithReg() Case 0x01 If $dbg Then Print('OrRegWithReg') OrRegWithReg() Case 0x02 If $dbg Then Print('AndRegWithReg') AndRegWithReg() Case 0x03 If $dbg Then Print('XorRegWithReg') XorRegWithReg() Case 0x04 If $dbg Then Print('AddRegToReg') AddRegToReg() Case 0x05 If $dbg Then Print('SubRegFromReg') SubRegFromReg() Case 0x06 If $dbg Then Print('ShiftRegRight') ShiftRegRight() Case 0x07 If $dbg Then Print('RSubRegFromReg') RSubRegFromReg() Case 0x0E If $dbg Then Print('ShiftRegLeft') ShiftRegLeft() EndSwitch Case 0x09 If $dbg Then Print('SkipIfRegNotEqualReg') SkipIfRegNotEqualReg() Case 0x0A If $dbg Then Print('LoadIndexWithConstant') LoadIndexWithConstant() Case 0x0B If $dbg Then Print('JumpToAddressPlusReg0') JumpToAddressPlusReg0() Case 0x0C If $dbg Then Print('CreateRandomNumber') CreateRandomNumber() Case 0x0D If $dbg Then Print('DrawSprite') DrawSprite() Case 0x0E Switch $opcode3 Case 0x09 If $dbg Then Print('SkipIfKeyPressed') SkipIfKeyPressed() Case 0x0A If $dbg Then Print('SkipIfKeyNotPressed') SkipIfKeyNotPressed() EndSwitch Case 0x0F Switch $opcode3 Case 0x00 Switch $opcode4 Case 0x07 If $dbg Then Print('GetDelayTimerIntoReg') GetDelayTimerIntoReg() Case 0x0A If $dbg Then Print('WaitForKeyPress') WaitForKeyPress() EndSwitch Case 0x01 Switch $opcode4 Case 0x05 If $dbg Then Print('SetDelayTimer') SetDelayTimer() Case 0x08 If $dbg Then Print('SetSoundTimer') SetSoundTimer() Case 0x0E If $dbg Then Print('AddRegToIndex') AddRegToIndex() EndSwitch Case 0x02 If $dbg Then Print('PointIndexToFont') PointIndexToFont() Case 0x03 If $dbg Then Print('StoreBCD') StoreBCD() Case 0x05 If $dbg Then Print('StoreRegsAtIndex') StoreRegsAtIndex() Case 0x06 If $dbg Then Print('LoadRegsFromIndex') LoadRegsFromIndex() EndSwitch EndSwitch EndFunc Func ClearScreen() _GDIPlus_GraphicsClear($hScreen, 0x00FFFFFF) EndFunc Func ReturnFromSub() $sp -= 1 $pc = $stack[$sp] EndFunc Func JumpToAddress() For $a = 1 To 8 $opcode2 *= 2 Next For $a = 1 To 4 $opcode3 *= 2 Next $pc = $opcode2 + $opcode3 + $opcode4 EndFunc Func JumpToSub() $stack[$sp] = $pc $sp += 1 For $a = 1 To 8 $opcode2 *= 2 Next For $a = 1 To 4 $opcode3 *= 2 Next $pc = $opcode2 + $opcode3 + $opcode4 EndFunc Func SkipIfRegEqual() For $a = 1 To 4 $opcode3 *= 2 Next If $v[$opcode2] = ($opcode3 + $opcode4) Then $pc +=2 EndFunc Func SkipIfRegNotEqual() For $a = 1 To 4 $opcode3 *= 2 Next If $v[$opcode2] <> ($opcode3 + $opcode4) Then $pc += 2 EndFunc Func SkipIfRegEqualReg() If $v[$opcode2] = $v[$opcode3] Then $pc += 2 EndFunc Func SkipIfRegNotEqualReg() If $v[$opcode2] <> $v[$opcode3] Then $pc += 2 EndFunc Func LoadRegWithConstant() For $a = 1 To 4 $opcode3 *= 2 Next $v[$opcode2] = ($opcode3 + $opcode4) EndFunc Func AddConstantToReg() For $a = 1 To 4 $opcode3 *= 2 Next $x = $v[$opcode2] + ($opcode3 + $opcode4) If $x > 255 Then $x -= 256 $v[$opcode2] = $x EndFunc Func LoadRegWithReg() $v[$opcode2] = $v[$opcode3] EndFunc Func OrRegWithReg() $v[$opcode2] = BitOR($v[$opcode2], $v[$opcode3]) EndFunc Func AndRegWithReg() $v[$opcode2] = BitAND($v[$opcode2], $v[$opcode3]) EndFunc Func XorRegWithReg() $v[$opcode2] = BitXOR($v[$opcode2], $v[$opcode3]) EndFunc Func AddRegToReg() Local $x If $v[$opcode2] >= $v[$opcode3] Then $v[0x0F] = 1 Else $v[0x0F] = 0 EndIf $x = $v[$opcode2] $x -= $v[$opcode3] If $x < 0 Then $x += 256 $v[$opcode2] = $x EndFunc Func SubRegFromReg() Local $x If $v[$opcode2] >= $v[$opcode3] Then $v[0x0F] = 1 Else $v[0x0F] = 0 EndIf $x = $v[$opcode2] $x = $x - $v[$opcode3] If $x < 0 Then $x = $x + 256 $v[$opcode2] = $x EndFunc Func ShiftRegRight() If BitAND($v[$opcode2], 1) Then $v[0x0F] = 1 Else $v[0x0F] = 0 EndIf $v[$opcode2] /= 2 EndFunc Func RSubRegFromReg() Local $x If $v[$opcode2] >= $v[$opcode3] Then $v[0x0F] = 1 Else $v[0x0F] = 0 EndIf $x = $v[$opcode3] $x -= $v[$opcode2] If $x < 0 Then $x += 256 $v[$opcode2] = $x EndFunc Func ShiftRegLeft() If BitAND($v[0x0F], 128) Then $v[0x0F] = 1 Else $v[0x0F] = 0 EndIf $x = $v[$opcode2] * 2 If $x > 255 Then $x -= 256 $v[$opcode2] = $x EndFunc Func LoadIndexWithConstant() For $a = 1 To 8 $opcode2 *= 2 Next For $a = 1 To 4 $opcode3 *= 2 Next $Index = $opcode2 + $opcode3 + $opcode4 EndFunc Func JumpToAddressPlusReg0() For $a = 1 To 8 $opcode2 *= 2 Next For $a = 1 To 4 $opcode3 *= 2 Next $pc = $v[0] + $opcode2 + $opcode3 + $opcode4 EndFunc Func CreateRandomNumber() For $a = 1 To 4 $opcode3 *= 2 Next $v[$opcode2] = BitAND(Int(Random() * 256), ($opcode3 + $opcode4)) EndFunc Func DrawSprite() $v[0x0F] = 0 For $j = 0 To $opcode4 - 1 $datax = $ram[$Index + $j] $i = 0 $x = $v[$opcode2] * 4 $y = $v[$opcode4] * 4 If $datax >= 128 Then drawscreen() $datax -= 128 EndIf $i += 1 If $datax >= 64 Then drawscreen() $datax -= 64 EndIf $i += 1 If $datax >= 32 Then drawscreen() $datax -= 32 EndIf $i += 1 If $datax >= 16 Then drawscreen() $datax -= 16 EndIf $i += 1 If $datax >= 8 Then drawscreen() $datax -= 8 EndIf $i += 1 If $datax >= 4 Then drawscreen() $datax -= 4 EndIf $i += 1 If $datax >= 2 Then drawscreen() $datax -= 2 EndIf $i += 1 If $datax >= 1 Then drawscreen() $datax -= 1 EndIf Next EndFunc Func drawscreen() Local $pointx, $pointy, $height, $width $pointx = 1 + $x + ($i * 4) $pointy = $y + ($j * 4) $width = (1 + $x + ($i * 4) + 3) - $pointx $height = ($y + ($j * 4) + 3) - $pointy If _PixelGetColor_GetPixel($hScreen, 1 + $x + ($i * 4), $y + ($j * 4)) = 0x00FF00 Then _GDIPlus_GraphicsDrawRect($hScreen, $pointx, $pointy, $width, $height, $White) ;_GDIPlus_GraphicsDrawLine($hScreen, 1 + $x + ($i * 4), $y + ($j * 4), 1 + $x + ($i * 4) + 3, $y + ($j * 4) + 3, $White) Else _GDIPlus_GraphicsDrawRect($hScreen, $pointx, $pointy, $width, $height, $Black) ;_GDIPlus_GraphicsDrawLine($hScreen, 1 + $x + ($i * 4), $y + ($j * 4), 1 + $x + ($i * 4) + 3, $y + ($j * 4) + 3, $Black) EndIf EndFunc Func SkipIfKeyPressed() If $key_down = $v[$opcode2] Then $pc += 2 EndFunc Func SkipIfKeyNotPressed() If $key_down <> $v[$opcode2] Then $pc += 2 EndFunc Func WaitForKeyPress() $key_down = 0 While $key_down = 0 Sleep(1) WEnd $v[$opcode2] = $key_down EndFunc Func SetDelayTimer() $delaytimer = $v[$opcode2] EndFunc Func GetDelayTimerIntoReg() $v[$opcode2] = $delaytimer EndFunc Func SetSoundTimer() $soundtimer = $v[$opcode2] EndFunc Func AddRegToIndex() $Index += $v[$opcode2] EndFunc Func PointIndexToFont() $Index = 0x1000 + ($v[$opcode2] * 0x05) EndFunc Func StoreBCD() $num = $v[$opcode2] For $i = 3 To 1 Step -1 $ram[$Index + ($i - 2)] = Mod($num, 10) $num /= 10 Next EndFunc Func StoreRegsAtIndex() For $i = 0 To $opcode2 $ram[$index + $i] = $v[$i] Next EndFunc Func LoadRegsFromIndex() For $i = 0 To $opcode2 $v[$i] = $ram[$Index + $i] Next EndFunc Func Print($String) GUICtrlSetData($Edit1, GUICtrlRead($Edit1) & @CRLF & $String) EndFunc Func _PixelGetColor_GetPixel($iPixelGetColor_MemoryContext,$iX,$iY, $hDll = "gdi32.dll") $iColor = DllCall($hDll,"int","GetPixel","int",$iPixelGetColor_MemoryContext,"int",$iX,"int",$iY) If $iColor[0] = -1 then Return SetError(1,0,-1) $sColor = Hex($iColor[0],6) Return StringRight($sColor,2) & StringMid($sColor,3,2) & StringLeft($sColor,2) EndFunc Emulator: #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.6.1 Author: Luig Script Function: GUI of Emulator. #ce ---------------------------------------------------------------------------- #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include 'CHIP8v2.au3' $Form1 = GUICreate("AutoChip v 1.0", 270, 134, 374, 138) GUISetState(@SW_SHOW) $hScreen = _GDIPlus_GraphicsCreateFromHWND($Form1) ClearScreen() $File = FileOpen(@ScriptDir & '\Pong (19xx)(-)(Chip-8).ch8', 16) $Raw = FileRead($File) FileClose($File) OpenRom(StringTrimLeft($Raw, 2)) ;AdlibRegister('Timer', 17) While 1 Timer() Emulate_CPU() $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd You can get the VB Source here : http://www.zophar.net/chip8/vb-chip-8.html
    1 point
×
×
  • Create New...