Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/14/2015 in all areas

  1. Here a version of a splash text variant using GDI+. Requires AutoIt v3.3.12.0 or higher! Source code download: UDF: _SplashTextEx.au3 (previous downloads: 135) Example: Example1.au3 (previous downloads: 127) Might be useful for someone... Please report any bugs.
    3 points
  2. Try this: #include <UpDownConstants.au3> GUICtrlCreateUpdown($input1, $UDS_NOTHOUSANDS)
    1 point
  3. water

    mysterious $i & $h

    That's a hint, right My English isn't good enough to express what was meant. Didn't want to replace a bad sentence with a worse one
    1 point
  4. If I look to Form Builder it uses SysTabControl32 around the button for the resizing. Might be a good idea to have a look to Form Builder or ISN Auto It Studio how it was implemented the GUI builder stuff.
    1 point
  5. kcvinu, I think it's pretty obvious that using the SciTE4AutoIt3 icon for anything else but the SciTE4AutoIt3 suite is considered redundant. If you don't see why, the consider if I was to ask the likes of Facebook or Twitter to use their icon for my own purposes? Yeah they wouldn't like it that much either.
    1 point
  6. I think you might need permission to use it, but if you ask a mod I am sure they can help.
    1 point
  7. UEZ

    Navigating in an image

    Sure. NavigatingImage.au3: #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPIvkeysConstants.au3> #include <GuiStatusBar.au3> #include <GDIPlus.au3> ;#include <Array.au3> Opt( "MustDeclareVars", 1 ) Opt( "WinWaitDelay", 10 ) Global Const $sIniFile = "inifile\Navigating.ini" Global $iImageCols = 23, $iImages = 0 Global $aImages[100][$iImageCols] ; Reg.exp. find: $aImages\[.*\]\[1\] ; ; Tab index is used as index in $aImages ; ; Columns: ; ; 0: Full name ; Constant ; 1: State ; Bit 0 = 1: New ; + check overwrite + check close ; Bit 1 = 2: Paste ; + check overwrite + check close ; Bit 2 = 4: Opened ; - check overwrite ; Bit 3 = 8: Modified ; + check close ; Bit 4 = 16: Saved ; - check overwrite ; Bit 5 = 32: PosSize ; Execute ImagePosSize() ; 2: Width ; Constant ; 3: Height ; Constant ; 4: Bitmap ; Constant ; Dispose ; 5: Context ; Constant ; Dispose ; 6: $aColors ; 7: Not used ; 8: Zoom factor ; 9 - 12: $iXDest, $iYDest, $iWidthDest, $iHeightDest ; 13 - 16: $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc ; 17 - 18: $iXMiddleSrc, $iYMiddleSrc ; 19 - 20: $dxMax, $dyMax ; 21: Frame/grid ; 22: $fGraphics ; ;$aColors ; Columns: ; 0: For color, Back color, Frame/grid, Dark image, Not used ; 5: Transparent image (contains transparent pixels) ; Main windows, controls, handles Global $hGui, $idTab, $hTab, $iTab = 0, $iTabPrev = 0, $iTabHeight, $idTabCtrl, $hPicChild, $idPicture, $hPicture, $hStatus ; Image and graphics variables Global $hBitmap, $hContext, $hGraObj, $hBmpBuf, $hGraphics, $hDC, $hSrcDC Global $hBitmap_Checkerboard, $hBrush_Checkerboard1, $hBrush_Checkerboard2, $hTexture_Checkerboard, $hContext_Checkerboard, _ $iSize_Checkerboard = 32, $iColor1_Checkboard = 0xFFFFFFFF, $iColor2_Checkboard = 0xFFF4F4F4 ; Control program flow Global $fHandleEvents = 0 ; 4: Toolbar button clicked ; 64: Drag tab item with primary mouse button ; 128: Move image with primary mouse button ; 256: Resize GUI and image Global $fXP = ( @OSVersion = "WIN_XP" ) ; Project includes #include "includes\Variables.au3" #include "includes\ModernMenuRaw.au3" #include "includes\NavigatingImage.au3" #include "includes\ToolbarFunctions.au3" #include "includes\TabCtrlFunctions.au3" #include "includes\DrawFunctions.au3" ImageAndPixelEditor() Func ImageAndPixelEditor() ; --- Create GUI --- ; Main GUI (Menu->20; Toolbar->51; Tab->10,32; Status->28) $hGui = GUICreate( "Navigating in an image", $iPicWidth+10+51, $iPicHeight+20+32+28, 500, 50, _ BitXOR( BitOR( $WS_OVERLAPPEDWINDOW, $WS_CLIPCHILDREN ), $WS_MAXIMIZEBOX ) ) GUIRegisterMsg( $WM_NCACTIVATE, "WM_NCACTIVATE" ) GUISetState() ; Main menu Local $idFileMenu = GUICtrlCreateMenu( "File" ) Local $idFileExit = _GUICtrlCreateODMenuItem( "Exit", $idFileMenu, "icons\exit.ico", 0 ) ; New, Open (en fil kan åbnes flere gange), Reload ; Toolbar ToolbarCreate() ; Tab control TabCtrlCreate() ; Statusbar $hStatus = _GUICtrlStatusBar_Create( $hGui ) _GUICtrlStatusBar_SetMinHeight( $hStatus, 24 ) ; GUI width and height Local $aPos = WinGetPos( $hGui ) $iWinWidth = $aPos[2] $iWinHeight = $aPos[3] $iMinWidth = $iWinWidth $iMinHeight = $iWinHeight ; Windows messages GUIRegisterMsg( $WM_ACTIVATE, "WM_ACTIVATE" ) GUIRegisterMsg( $WM_MOUSEWHEEL, "WM_MOUSEWHEEL" ) GUIRegisterMsg( $WM_GETMINMAXINFO, "WM_GETMINMAXINFO" ) GUIRegisterMsg( $WM_SIZING, "WM_SIZING" ) ; Catch key presses Local $hMessageHandler = DllCallbackRegister( "MessageHandler", "long", "int;wparam;lparam" ) Local $hMessageHook = _WinAPI_SetWindowsHookEx( $WH_GETMESSAGE, DllCallbackGetPtr( $hMessageHandler ), 0, _WinAPI_GetCurrentThreadId() ) ; --- Load first image --- ; Start GDIPlus _GDIPlus_Startup() ; Read inifile Local $sImageDir = StringLeft( @ScriptDir, StringInStr( @ScriptDir, "\", 0, -1 ) - 1 ) & "\images" Local $aPics = IniReadSection( $sIniFile, "Open on startup" ), $sImage, $fTrans, $hImage, $fOpen = False, $iNext If Not @error Then For $i = 1 To $aPics[0][0] Step 2 If $aPics[$i][0] = "Image" And $aPics[$i+1][0] = "Transparent" Then $sImage = $sImageDir & "\" & $aPics[$i][1] $fTrans = $aPics[$i+1][1] = "1" ? True : False If $sImage <> $sImageDir And FileExists( $sImage ) Then $iNext = $i + 2 $fOpen = True ExitLoop EndIf EndIf Next EndIf If $fOpen Then ; Open on startup Local $i = StringInStr( $sImage, "\", 0, -1 ) Local $sName = StringRight( $sImage, StringLen( $sImage ) - $i ) _GUICtrlTab_SetItemText( $hTab, $iTab, $sName ) $hImage = _GDIPlus_BitmapCreateFromFile( $sImage ) $iImageWidth = _GDIPlus_ImageGetWidth( $hImage ) $iImageHeight = _GDIPlus_ImageGetHeight( $hImage ) $fTransparent = $fTrans ; Transparent? $aImages[0][1] = 4 ; State: Opened Else ; Default image $sImage = "New1.bmp" $iImageWidth = 256 $iImageHeight = 256 $aImages[0][1] = 3 ; State: New + Paste = default image EndIf ;checkerboard $hBitmap_Checkerboard = _GDIPlus_BitmapCreateFromScan0($iSize_Checkerboard, $iSize_Checkerboard) $hContext_Checkerboard = _GDIPlus_ImageGetGraphicsContext($hBitmap_Checkerboard) $hBrush_Checkerboard1 = _GDIPlus_BrushCreateSolid($iColor1_Checkboard) $hBrush_Checkerboard2 = _GDIPlus_BrushCreateSolid($iColor2_Checkboard) _GDIPlus_GraphicsFillRect($hContext_Checkerboard, 0, 0, $iSize_Checkerboard, $iSize_Checkerboard, $hBrush_Checkerboard1) _GDIPlus_GraphicsFillRect($hContext_Checkerboard, $iSize_Checkerboard / 2, 0, $iSize_Checkerboard / 2, $iSize_Checkerboard / 2, $hBrush_Checkerboard2) _GDIPlus_GraphicsFillRect($hContext_Checkerboard, 0, $iSize_Checkerboard / 2, $iSize_Checkerboard / 2, $iSize_Checkerboard / 2, $hBrush_Checkerboard2) $hTexture_Checkerboard = _GDIPlus_TextureCreate($hBitmap_Checkerboard) _GDIPlus_GraphicsDispose($hContext_Checkerboard) _GDIPlus_BrushDispose($hBrush_Checkerboard1) _GDIPlus_BrushDispose($hBrush_Checkerboard2) ; Image $hBitmap = _GDIPlus_BitmapCreateFromScan0( $iImageWidth, $iImageHeight ) $hContext = _GDIPlus_ImageGetGraphicsContext( $hBitmap ) If $fOpen Then _GDIPlus_GraphicsDrawImageRect( $hContext, $hImage, 0, 0, $iImageWidth, $iImageHeight ) _GDIPlus_ImageDispose( $hImage ) Else _GDIPlus_GraphicsClear( $hContext, 0xFFFFFFFF ) EndIf ; Device contexts $hDC = _WinAPI_GetDC( $hPicture ) $hSrcDC = _WinAPI_CreateCompatibleDC( $hDC ) ; Image info $aImages[0][0] = $sImage ; Full name $aImages[0][2] = $iImageWidth ; Width $aImages[0][3] = $iImageHeight ; Height $aImages[0][4] = $hBitmap ; Bitmap $aImages[0][5] = $hContext ; Context $iImages += 1 ; --- Draw graphics on top of the picture control using buffered drawing --- ; Create pen to draw frame and grid $hPenFrameGrid = _GDIPlus_PenCreate( 0xFFCCCCCC, 1 ) ; Graphics object to draw the contents of the bitmap buffer on top of the picture control $hGraObj = _GDIPlus_GraphicsCreateFromHWND( $hPicture ) ; Bitmap buffer for buffered graphics drawing $hBmpBuf = _GDIPlus_BitmapCreateFromGraphics( $iPicWidth, $iPicHeight, $hGraObj ) ; Graphics context to draw graphics in the bitmap buffer $hGraphics = _GDIPlus_ImageGetGraphicsContext( $hBmpBuf ) ; Positions and sizes ImagePosSize() ; Draw image ImageDraw( True ) ; Open more pictures from inifile, if any If $fOpen Then For $i = $iNext To $aPics[0][0] Step 2 If $aPics[$i][0] = "Image" And $aPics[$i+1][0] = "Transparent" Then $sImage = $sImageDir & "\" & $aPics[$i][1] $fTrans = $aPics[$i+1][1] = "1" ? True : False If $sImage <> $sImageDir And FileExists( $sImage ) Then _ OpenImageAdd( $sImageDir, $aPics[$i][1], $iImages, $fTrans ) EndIf Next EndIf ; Remove focus from tab control GUICtrlSetState( $idLblForColor, $GUI_FOCUS ) ; --- GUI main loop --- Local $iMsg, $aInfo, $fTabContextMenu = False While 1 $iMsg = GUIGetMsg() ;ShowMessageCodesGUI( $iMsg, $sIdentifier = "", $iMaxInSeq = 0, $bOnlyOnce = False ) ;ShowMessageCodesGUI( $iMsg, "GUI msg:", 2 ) If $fHandleEvents Then Select Case BitAND( $fHandleEvents, 4 ) ; Toolbar button clicked Switch $iMsg ; Switch statement is used for grouping of buttons Case $idTbFileButton, $idTbViewButton ToolbarButtonClick( $iMsg ) EndSwitch Case BitAND( $fHandleEvents, 64 ) ; Drag tab item with primary mouse button DragTabItem() Case BitAND( $fHandleEvents, 128 ) ; Move image with primary mouse button ImageMove( $aInfo[0], $aInfo[1] ) Case BitAND( $fHandleEvents, 256 ) ; Resize GUI and image ImageResize() EndSelect Else ; --- View mode --- Switch $iMsg Case $GUI_EVENT_MOUSEMOVE, 0 ContinueLoop Case $idTab, $idTabCtrl $iTab = GUICtrlRead( $idTab ) If $iTabPrev <> $iTab Then ImageSwitch() GUICtrlSetState( $idLblForColor, $GUI_FOCUS ) If $fTabContextMenu Then $fTabContextMenu = False TabContextMenu() EndIf Case $GUI_EVENT_PRIMARYDOWN $aInfo = GUIGetCursorInfo( $hPicChild ) If $aInfo[4] = $idPicture Then ; - Click a point in picture control to center the point (zoom in/out around this point) ; - Click and drag with the mouse to move the image in the picture control $fHandleEvents = BitOR( $fHandleEvents, 128 ) Else $aInfo = GUIGetCursorInfo( $hGui ) If $aInfo[4] = $idTab Then ; Click on a tab item or right to tab items If $iImages > 1 Then Local $aPos = _GUICtrlTab_GetItemRect( $hTab, $iTab ) If $aInfo[0] - 51 > $aPos[0] And $aInfo[0] - 51 < $aPos[2] And $aInfo[1] < $iTabHeight Then _ $fHandleEvents = BitOR( $fHandleEvents, 64 ) EndIf GUICtrlSetState( $idLblForColor, $GUI_FOCUS ) ElseIf $aInfo[1] < 0 Then ; Click in menu bar or title bar areas GUICtrlSetState( $idLblForColor, $GUI_FOCUS ) EndIf EndIf Case $GUI_EVENT_SECONDARYDOWN If GUIGetCursorInfo( $hGui )[4] = $idTab Then $aInfo = GUIGetCursorInfo( $hGui ) If $aInfo[0] > 51 And $aInfo[1] < $iTabHeight Then Local $i = _GUICtrlTab_HitTest( $hTab, $aInfo[0] - 51, $aInfo[1] )[0] If $i = -1 Then continueLoop ; Right click on a tab item If $i = $iTab Then TabContextMenu() Else $fTabContextMenu = True _GUICtrlTab_ClickTab( $hTab, $i ) EndIf EndIf EndIf Case $GUI_EVENT_RESTORE ImageDraw() Case $GUI_EVENT_CLOSE, $idFileExit ExitLoop EndSwitch EndIf WEnd ;_GDIPlus_ImageSaveToFile( $hBitmap, "images\Saved.bmp" ) _WinAPI_UnhookWindowsHookEx( $hMessageHook ) _GDIPlus_PenDispose( $hPenFrameGrid ) For $i = 0 To $iImages - 1 ReleaseImageResources( $i ) Next ;_GDIPlus_BitmapDispose( $hBitmap ) _GDIPlus_BitmapDispose( $hBmpBuf ) ;_GDIPlus_GraphicsDispose( $hContext ) _GDIPlus_GraphicsDispose( $hGraObj ) _GDIPlus_GraphicsDispose( $hGraphics ) _GDIPlus_BrushDispose($hTexture_Checkerboard) _WinAPI_ReleaseDC( $hPicture, $hDC ) _WinAPI_DeleteDC( $hSrcDC ) _GDIPlus_Shutdown() DestroyToolbars() GUIDelete( $hGui ) Exit EndFunc ToolbarFunctions.au3: #include-once ; --- File toolbar --- ; --- File | Open --- Func OpenImages() ; Disable main GUI functionality GUISetState( @SW_DISABLE, $hGui ) ; Main GUI GUIRegisterMsg( $WM_NOTIFY, "" ) ; Toolbar events $fMoveZoom = False ; Move/zoom Local $sWorkingDir = @WorkingDir Local $sProjectDir = StringLeft( @ScriptDir, StringInStr( @ScriptDir, "\", 0, -1 ) - 1 ) Local $sOpen = FileOpenDialog( "Open one or more images", _ $sProjectDir & "\images\", _ "Images (*.bmp;*.gif;*.jpg;*.png)", _ $FD_FILEMUSTEXIST + $FD_PATHMUSTEXIST + $FD_MULTISELECT, _ "", $hGui ) If Not @error Then ; Tab item for first image Local $iTabs = $iImages ;Local $iTabs = _GUICtrlTab_GetItemCount( $hTab ) If StringInStr( $sOpen, "|" ) Then ; Multiple images Local $aOpen = StringSplit( $sOpen, "|" ) Local $sDir = $aOpen[1] For $i = 2 To $aOpen[0] OpenImageAdd( $sDir, $aOpen[$i], $iTabs+$i-2 ) Next Else ; Single images Local $i = StringInStr( $sOpen, "\", 0, -1 ) Local $sFile = StringRight( $sOpen, StringLen( $sOpen ) - $i ) Local $sDir = StringLeft( $sOpen, $i - 1 ) OpenImageAdd( $sDir, $sFile, $iTabs ) EndIf ; Switch tab to first Open image _GUICtrlTab_ClickTab( $hTab, $iTabs ) $iTab = GUICtrlRead( $idTab ) ImageSwitch( True ) ; True => Remove focus EndIf ; Enable main GUI functionality FileChangeDir( $sWorkingDir ) ; Directory GUISetState( @SW_ENABLE, $hGui ) ; Main GUI GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" ) ; Toolbar events $fMoveZoom = True ; Move/zoom While GUIGetMsg() ; No (mouse) events from FileOpenDialog WEnd ; should be passed on to main message loop. EndFunc Func OpenImageAdd( $sDir, $sFile, $iTab, $fTrans = False ) ;ConsoleWrite( $sDir & "\" & $sFile & @CRLF ) Local $sName = $sDir & "\" & $sFile ; Image info, bitmap, context Local $hImage = _GDIPlus_BitmapCreateFromFile( $sName ) Local $iImageWidth = _GDIPlus_ImageGetWidth( $hImage ) Local $iImageHeight = _GDIPlus_ImageGetHeight( $hImage ) Local $hBitmap = _GDIPlus_BitmapCreateFromScan0( $iImageWidth, $iImageHeight ) Local $hContext = _GDIPlus_ImageGetGraphicsContext( $hBitmap ) _GDIPlus_GraphicsFillRect($hContext, 0, 0, $iImageWidth, $iImageHeight, $hTexture_Checkerboard) _GDIPlus_GraphicsDrawImageRect( $hContext, $hImage, 0, 0, $iImageWidth, $iImageHeight ) _GDIPlus_ImageDispose( $hImage ) ; Store image info Local $aColors[6] = [ 0xFF000000, 0xFFFFFFFF, 1, _ ; For, back, frame/grid colors 0, 0, $fTrans ] ; Dark image, not used, transparent image $aImages[$iImages][ 0] = $sName ; Full name $aImages[$iImages][ 1] = 36 ; State: Opened + PosSize $aImages[$iImages][ 2] = $iImageWidth ; Width $aImages[$iImages][ 3] = $iImageHeight ; Height $aImages[$iImages][ 4] = $hBitmap ; Bitmap $aImages[$iImages][ 5] = $hContext ; Context $aImages[$iImages][ 6] = $aColors ; Colors $aImages[$iImages][ 8] = 1 ; Zoom level $aImages[$iImages][17] = -1 ; $iXMiddleSrc $aImages[$iImages][18] = -1 ; $iYMiddleSrc $aImages[$iImages][21] = 3 ; Frame/grid $aImages[$iImages][22] = 11 ; $fGraphics $iImages += 1 ; Create tab item _GUICtrlTab_InsertItem( $hTab, $iTab, $sFile ) EndFunc ; --- File | Close --- Func CloseImage() ; Only one image? If $iImages = 1 Then ; If this is default image (state 3 indicates default), then don't close it If BitAND( $aImages[0][1], 3 ) = 3 Then Return ; Not default image: Close image and create new default image ; Close image ;_GDIPlus_BitmapDispose( $hBitmap ) ;_GDIPlus_GraphicsDispose( $hContext ) ; Create new default image $iImageWidth = 256 $iImageHeight = 256 $hBitmap = _GDIPlus_BitmapCreateFromScan0( $iImageWidth, $iImageHeight ) $hContext = _GDIPlus_ImageGetGraphicsContext( $hBitmap ) _GDIPlus_GraphicsClear( $hContext, 0xFFFFFFFF ) ; Store image info Local $aColors[6] = [ 0xFF000000, 0xFFFFFFFF, 1, _ ; For, back, frame/grid colors 0, 0, False ] ; Dark image, not used, transparent image $aImages[0][ 0] = "New1.bmp" ; Full name $aImages[0][ 1] = 3 ; State: New + Paste ; New + Paste = default image $aImages[0][ 2] = $iImageWidth ; Width $aImages[0][ 3] = $iImageHeight ; Height $aImages[0][ 4] = $hBitmap ; Bitmap $aImages[0][ 5] = $hContext ; Context $aImages[0][ 6] = $aColors ; Colors $aImages[0][ 8] = 1 ; Zoom level $aImages[0][21] = 3 ; Frame/grid $aImages[0][22] = 11 ; $fGraphics ; Update tab _GUICtrlTab_SetItemText( $hTab, $iTab, "New1.bmp" ) $iTabPrev = $iTab ; Update image LoadImageInfo( $iTab ) ; Load info for this image ImagePosSize() ; Calculate image position and size $fGraphics = BitOR( $fGraphics, 4 ) ; Update grid in bitmap buffer ImageDraw( True ) ; Draw image and grid ;Local $sColor = "0x" & Hex( $iCurBackColor, 6 ) ;GUICtrlSetBkColor( $idLblBackColor, $sColor ) Return EndIf $iTabPrev = -1 ;_GDIPlus_BitmapDispose( $hBitmap ) ;_GDIPlus_GraphicsDispose( $hContext ) ReleaseImageResources( $iTab ) _GUICtrlTab_DeleteItem( $hTab, $iTab ) If $iTab = $iImages - 1 Then $iTab -= 1 Else For $i = $iTab To $iImages - 2 For $j = 0 To $iImageCols - 1 $aImages[$i][$j] = $aImages[$i+1][$j] Next Next EndIf $iImages -= 1 _GUICtrlTab_ClickTab( $hTab, $iTab ) EndFunc ; --- File | Save ---
    1 point
  8. weaponx

    StringFormat help/examples

    I wish AutoIt followed more PHP functions like sprintf...sprintf allows binary representation and parameter re-use so you can insert the same string at multiple locations. http://us.php.net/sprintf Here you go. ;Script: String Format Examples ;Author: WeaponX ;//////////////////////////////// ;// Convert FileGetTime result ;//////////////////////////////// $Date = FileGetTime(@WindowsDir & "\notepad.exe", 1, 0) ;Format date for use with Date UDF (YYYY/MM/DD HH:MM:SS) $fDate = StringFormat("%s/%s/%s %s:%s:%s", $Date[0],$Date[1],$Date[2],$Date[3],$Date[4],$Date[5]) ConsoleWrite("Date format: " & $fDate & @CRLF) ;//////////////////////////////// ;// Hex display ;//////////////////////////////// $hex = 0xAABBCC ;Format hex string for display $fHex = StringFormat("%#x", $hex) ConsoleWrite("Hex format: " & $fHex & @CRLF) ;//////////////////////////////// ;// Decimal precision ;//////////////////////////////// $double = 5.12 ;Format float to 4 decimal places $fDouble = StringFormat("%.4f", $double) ConsoleWrite("Decimal precision: " & $fDouble & @CRLF) ;//////////////////////////////// ;// Integer padding ;//////////////////////////////// $integer = 55 ;Pad integer with zeros to 4 digits $fInteger = StringFormat("%04i", $integer) ConsoleWrite("Integer padding: " & $fInteger & @CRLF) ;//////////////////////////////// ;// String justification ;//////////////////////////////// $s = 'string' $t = 'many strings' ConsoleWrite(StringFormat("[%s]", $s) & @CRLF); // standard string output ConsoleWrite(StringFormat("[%10s]", $s) & @CRLF); // right-justification with spaces ConsoleWrite(StringFormat("[%-10s]", $s) & @CRLF); // left-justification with spaces ConsoleWrite(StringFormat("[%010s]", $s) & @CRLF); // zero-padding works on strings too ConsoleWrite(StringFormat("[%10.10s]", $t) & @CRLF); // left-justification but with a cutoff of 10 characters
    1 point
×
×
  • Create New...