Snippets ( Graphics )
Animated Gif ~ Author - GaryFrost
Animated Gif ~ Author - GaryFrost
; Animated Gif
Opt("MustDeclareVars", 1)
#include <IE.au3>
_Main()
Func _Main()
Local $pheight = 50, $pwidth = 50, $oIE, $GUIActiveX, $gif
$gif = FileOpenDialog("Select Animated Gif", @ScriptDir, "gif files (*.gif)", 3)
If @error Then Exit
_GetGifPixWidth_Height($gif, $pwidth, $pheight)
$oIE = ObjCreate("Shell.Explorer.2")
GUICreate("Embedded Web control Test", 640, 580)
$GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, $pwidth, $pheight)
$oIE.navigate ("about:blank")
While _IEPropertyGet($oIE, "busy")
Sleep(100)
WEnd
$oIE.document.body.background = $gif
$oIE.document.body.scroll = "no"
GUISetState()
While GUIGetMsg() <> -3
WEnd
EndFunc ;==>_Main
Func _GetGifPixWidth_Height($s_gif, ByRef $pwidth, ByRef $pheight)
If FileGetSize($s_gif) > 9 Then
Local $sizes = FileRead($s_gif, 10)
ConsoleWrite("Gif version: " & StringMid($sizes, 1, 6) & @LF)
$pwidth = Asc(StringMid($sizes, 8, 1)) * 256 + Asc(StringMid($sizes, 7, 1))
$pheight = Asc(StringMid($sizes, 10, 1)) * 256 + Asc(StringMid($sizes, 9, 1))
ConsoleWrite($pwidth & " x " & $pheight & @LF)
EndIf
EndFunc ;==>_GetGifPixWidth_Height
_AreIconsEqual() ~ Author - JohnOne
_AreIconsEqual() ~ Author - JohnOne
;#### Example ####
#include <WinAPI.au3>
#include <Constants.au3>
;get handles to two icons
;Change the numbers 3 or load an icon from another source
Local $sModule = @SystemDir & "\shell32.dll"
Local $hModule = _WinAPI_GetModuleHandle($sModule)
Local $hmyIcon1 = _WinAPI_LoadImage($hModule, 3, $IMAGE_ICON, 0, 0, 0)
Local $hmyIcon2 = _WinAPI_LoadImage($hModule, 3, $IMAGE_ICON, 0, 0, 0)
Local $bEqual = _AreIconsEqual($hmyIcon1, $hmyIcon2)
If @error Then
Exit MsgBox(0, "Error", @error)
EndIf
MsgBox(0, "Icons Equal", $bEqual)
;Checks if two Icons are the same.
Func _AreIconsEqual($hicon1, $hicon2)
Local $aRtn = DllCall("shlwapi.dll", "BOOL", 548, "handle", $hicon1, "handle", $hicon2)
If @error Then
Return SetError(@error)
EndIf
Return $aRtn[0]
EndFunc ;==>_AreIconsEqual
Array Of Pixel Colours ~ Author - Malkey
Array Of Pixel Colours ~ Author - Malkey
;=========================================================
; Produces an array of pixel colours used in an image that are below the colour 0x202020 (array[n][0]),
; Number of times that colour is used (array[n][1]), and,
; the percentage of the numer of times the colour is used over the total number of pixels in the image (array[n][2]).
; Array[0][0] contains the number of unique pixels used in the image below 0x202020 colour.
; Array[0][1] contains the total number of pixels used in the image below 0x202020 colour.
; Array[0][2] contains the percentage of the total number of pixels used in the image below 0x202020 colour.
;============================================================
#include <WinAPI.au3>
#include <ScreenCapture.au3>
#include <GDIPlus.au3>
#include <Array.au3>
Dim $pixels, $iTotalReplace
Local $Path = FileOpenDialog("Choose Image File", @ScriptDir & "", "Images (*.gif;*.png;*.jpg;*.bmp)| All (*.*)")
If $Path <> "" Then
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile($Path)
$width = _GDIPlus_ImageGetWidth($hImage)
$height = _GDIPlus_ImageGetHeight($hImage)
$hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
$aSize = DllCall('gdi32.dll', 'int', 'GetBitmapBits', 'ptr', $hBmp, 'int', 0, 'ptr', 0)
If $aSize[0] Then
$tBits = DllStructCreate('byte[' & $aSize[0] & ']')
DllCall('gdi32.dll', 'int', 'GetBitmapBits', 'ptr', $hBmp, 'int', $aSize[0], 'ptr', DllStructGetPtr($tBits))
$sHex = Hex(DllStructGetData($tBits, 1))
; Selects all pixels below/less than 0x202020
$pixels = StringRegExp($sHex, "([01][0-9A-F][01][0-9A-F][01][0-9A-F])FF", 3)
; Selects all pixels below/less than 0x505050 (Can take a while)
;$pixels = StringRegExp($sHex, "([0-5][0-9A-F][0-5][0-9A-F][0-5][0-9A-F])FF", 3)
$sHexReduced = _ArrayToString($pixels) & "|"
Dim $pixels[1][3]
While StringLen($sHexReduced) > 6
ReDim $pixels[UBound($pixels) + 1][3]
$PixTemp = StringLeft($sHexReduced, 7)
$sHexReduced = StringReplace($sHexReduced, $PixTemp, "", 0)
$numreplacements = @extended
$pixels[UBound($pixels) - 1][1] = $numreplacements
$pixels[UBound($pixels) - 1][0] = StringTrimRight($PixTemp, 1)
$pixels[UBound($pixels) - 1][2] = StringFormat("%1.4f%%", $numreplacements * 100 / ($height * $width))
$iTotalReplace += $numreplacements
WEnd
$pixels[0][0] = UBound($pixels) - 1
$pixels[0][1] = $iTotalReplace
$pixels[0][2] = StringFormat("%1.4f%%", $iTotalReplace * 100 / ($height * $width))
EndIf
_ArraySort($pixels, 0, 1, 0, 0)
_ArrayDisplay($pixels,$Path)
_WinAPI_DeleteObject($hBmp)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
EndIf
_CalcContrastColour() ~ Author - Melba23
_CalcContrastColour() ~ Author - Melba23
#include <GUIConstantsEx.au3>
$hGUI = GUICreate("Test", 500, 500)
$cLabel = GUICtrlCreateLabel("", 100, 100, 300, 300)
$cButton = GUICtrlCreateButton("Change", 10, 450, 80, 30)
GUISetState()
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $cButton
$iColour = Random(0, 0xFFFFFF, 1)
GUISetBkColor($iColour)
$iContrast_Colour = _CalcContrastColour($iColour)
GUICtrlSetBkColor($cLabel, $iContrast_Colour)
EndSwitch
WEnd
Func _CalcContrastColour($iColour, $iTolerance = 30)
Switch $iTolerance
Case 0 To 255
$iTolerance = Int($iTolerance)
Case Else
$iTolerance = 30
EndSwitch
If (Abs(BitAND($iColour, 0xFF) - 0x80) <= $iTolerance And _
Abs(BitAND(BitShift($iColour, 8), 0xFF) - 0x80) <= $iTolerance And _
Abs(BitAND(BitShift($iColour, 16), 0xFF) - 0x80) <= $iTolerance) _
Then Return BitAND((0x7F7F7F + $iColour), 0xFFFFFF)
Return BitXOR($iColour, 0xFFFFFF)
EndFunc ;==>_CalcContrastColour
Custom GUI Cursor ~ Author - Saunders
Custom GUI Cursor ~ Author - Saunders
; Custom GUI Cursor, Mouse over second gui to view.
#include <GuiConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Local $Gui = GuiCreate("Test", 300, 200)
GUISetState()
Local $Gui2 = GuiCreate("Test", 300, 200,750)
GUISetState()
GUIRegisterMsg($WM_SETCURSOR, 'WM_SETCURSOR')
Local $Cur = DllCall("user32.dll", "int", "LoadCursorFromFile", "str","C:\windows\cursors\pen_m.cur")
if @error Then MsgBox(0,"dd","whoopsie!")
While 1
Local $Msg = GUIGetMsg(1)
Select
Case $Msg[0] = $GUI_EVENT_CLOSE
Exit
EndSelect
WEnd
Func WM_SETCURSOR($hWnd, $iMsg, $iWParam, $iLParam)
If $hWnd = $Gui Then
DllCall("user32.dll", "int", "SetCursor", "int", $Cur[0])
Return 0
EndIf
EndFunc
_GUICtrlSetImageEx() ~ Author - guinness
_GUICtrlSetImageEx() ~ Author - guinness
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
_GDIPlus_Startup()
Example()
_GDIPlus_Shutdown()
Func Example()
GUICreate('')
_GUICtrlSetImageEx(@ScriptDir & "Example.png", 5, 5)
GUISetState(@SW_SHOW)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
EndFunc ;==>Example
; Version: 1.00. AutoIt: V3.3.8.1
; Create an image control and set an image file to the control, works with png too.
Func _GUICtrlSetImageEx($sImageFile, $iLeft, $iTop)
Local Const $STM_SETIMAGE = 0x0172
Local $hImage = _GDIPlus_ImageLoadFromFile($sImageFile)
Local $iWidth = _GDIPlus_ImageGetWidth($hImage)
Local $iHeight = _GDIPlus_ImageGetHeight($hImage)
Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
_GDIPlus_ImageDispose($hImage)
Local $iControlID = GUICtrlCreatePic('', $iLeft, $iTop, $iWidth, $iHeight)
_WinAPI_DeleteObject(GUICtrlSendMsg($iControlID, $STM_SETIMAGE, 0, $hBitmap))
_WinAPI_DeleteObject($hBitmap)
Return $iControlID
EndFunc ;==>_GUICtrlSetImageEx
_IconButton() ~ Author - ProgAndy
_IconButton() ~ Author - ProgAndy
;===============================================================================
;
; Function Name: _IconButton()
; Description:: Creates a button with Icon and Text
; Parameter(s): $text - text
; $dll - Icon FileName
; $iconID - ID of icon in File
; $x - top
; $y - left
; $w - width, is min. 40
; $h - height, is min. 55
; Requirement(s): AutoIT :P
; Return Value(s): ControlID of the button, to cnage the Icon use the functions below :)
; Author(s): Prog@ndy
;
;===============================================================================
;
Func _IconButton($text,$dll,$iconID,$x,$y,$w = 50,$h = 60)
Local $space, $spaceh = 9
If $w < 40 Then $w = 40
Local $space = Floor(($w-32)/2)
If $h < 55 Then $h = 55
If $h < 60 Then $spaceh = 5
GUICtrlCreateIcon($dll, $iconID, $x+$space, $y+$spaceh, 32, 32,0) ; --> die letzte 0, damit kein Klick-Ereignis ausgelöst wird (Click-Through)
Return GUICtrlCreateButton($text, $x, $y, $w, $h, BitOR($WS_CLIPSIBLINGS, $BS_BOTTOM, $BS_MULTILINE))
EndFunc
; by Prog@ndy
Func _IconButtonSetIco($btn,$dll, $iconID=0)
GUICtrlSetImage($btn-1,$dll, $iconID)
EndFunc
; by Prog@ndy
Func _IconButtonDelete($btn)
GUICtrlDelete($btn-1)
GUICtrlDelete($btn)
EndFunc
; by Prog@ndy
Func _IconButtonIconSetStyle($btn,$style,$styleEx)
GUICtrlSetStyle($btn-1,$style,$styleEx)
EndFunc
; Gets The Control ID of the Icon, so you can use all GUICtrl... Functions on it :)
; by Prog@ndy
Func _IconButtonIconGetCtrlID($btn)
Return $btn-1
EndFunc
_IconOnButton() ~ Author - Valuater
_IconOnButton() ~ Author - Valuater
; Icon on Button - (made easy)
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
Global $mywin = GUICreate("my gui")
Local $btn1 = _IconOnButton(" Help", 30, 30, 70, 32, 23)
GUISetState()
While 1
Local $msg = GUIGetMsg()
If $msg = $btn1 Then MsgBox(0,0,"You pressed the Icon Button ", 2)
If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd
Func _IconOnButton($BItext, $BIleft, $BItop, $BIwidth, $BIheight, $BIconNum, $BIDLL = "shell32.dll")
GUICtrlCreateIcon($BIDLL, $BIconNum, $BIleft + 5, $BItop + (($BIheight - 16) / 2), 16, 16)
GUICtrlSetState( -1, $GUI_DISABLE)
Local $XS_btnx = GUICtrlCreateButton($BItext, $BIleft, $BItop, $BIwidth, $BIheight, $WS_CLIPSIBLINGS)
Return $XS_btnx
EndFunc ;==>_IconOnButton()
_ImageSize() ~ Author - JScript
_ImageSize() ~ Author - JScript
;Author: JScript - Snippet Version No. = 1.0
;Snippet was Created Using AutoIt Version = 3.3.8.1, Creation Date = 23/05/12.
Local $sImage = FileOpenDialog("choose an image file to measure...", @DocumentsCommonDir, "Images (*.jpg;*.bmp;*.gif;*.png)", 1)
Local $aiSize = _ImageSize($sImage)
MsgBox(4096, "ImageSize", "Image: " & $sImage & @CRLF & @CRLF & "Width: " & $aiSize[0] & @CRLF & "Height: " & $aiSize[1])
Func _ImageSize($ImgFullPath)
Local $hWnd, $hGuiSwitch, $aCtrlSize, $aRetSize[2] = [0, 0]
$hWnd = GUICreate($ImgFullPath, 0, 0, 0, 0, BitOR(0x80000000, 0x20000000), BitOR(0x00000080, 0x00000020))
$hGuiSwitch = GUISwitch($hWnd)
$aCtrlSize = ControlGetPos($hWnd, "", GUICtrlCreatePic($ImgFullPath, 0, 0, 0, 0))
GUIDelete($hWnd)
GUISwitch($hGuiSwitch)
If IsArray($aCtrlSize) Then
$aRetSize[0] = $aCtrlSize[2]; Width
$aRetSize[1] = $aCtrlSize[3]; Height
Return SetError(0, 0, $aRetSize)
EndIf
Return SetError(1, 0, $aRetSize)
EndFunc ;==>_ImageSize
_IsCheckbox() ~ Author - guinness
_IsCheckbox() ~ Author - guinness
; Check if a variable is referencing a Checkbox control.
#include <ButtonConstants.au3>
#include <Constants.au3>
#include <WinAPI.au3>
Example()
Func Example()
Local $hGUI = GUICreate('')
Local $iLabel = GUICtrlCreateRadio('', 0, 0, 500, 500) ; This is considered a 'Button' by _WinAPI_GetClassName too.
Local $iCheckbox = GUICtrlCreateCheckbox('', 0, 0, 100, 20)
GUISetState(@SW_SHOW, $hGUI)
MsgBox(4096, '', 'AutoIt Radio ID: ' & _IsCheckbox($iLabel) & @CRLF & _
'AutoIt Radio Handle: ' & _IsCheckbox(GUICtrlGetHandle($iLabel)) & @CRLF & _
'AutoIt Checkbox ID: ' & _IsCheckbox($iCheckbox) & @CRLF & _
'AutoIt Checkbox Handle: ' & _IsCheckbox(GUICtrlGetHandle($iCheckbox)) & @CRLF)
Return GUIDelete($hGUI)
EndFunc ;==>Example
Func _IsCheckbox($hWnd)
If IsHWnd($hWnd) = 0 Then
$hWnd = GUICtrlGetHandle($hWnd)
EndIf
If _WinAPI_GetClassName($hWnd) = 'Button' Then
Local $iLong = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE)
Return (BitAND($iLong, $BS_CHECKBOX) = $BS_CHECKBOX Or BitAND($iLong, $BS_AUTOCHECKBOX) = $BS_AUTOCHECKBOX)
EndIf
Return False
EndFunc ;==>_IsCheckbox
_IsComboBox() ~ Author - guinness
_IsComboBox() ~ Author - guinness
; Check if a variable is referencing a ComboBox control.
#include <GUIComboBox.au3>
#include <WinAPI.au3>
Example()
Func Example()
Local $hGUI = GUICreate('')
Local $iLabel = GUICtrlCreateLabel('', 0, 0, 500, 500)
Local $iComboBox = GUICtrlCreateCombo('', 0, 0, 500, 500)
Local $hComboBox = _GUICtrlComboBox_Create($hGUI, 'Example', 0, 0, 500, 500)
GUISetState(@SW_SHOW, $hGUI)
MsgBox(4096, '', 'AutoIt Label ID: ' & _IsComboBox($iLabel) & @CRLF & _
'AutoIt Label Handle: ' & _IsComboBox(GUICtrlGetHandle($iLabel)) & @CRLF & _
'AutoIt ComboBox ID: ' & _IsComboBox($iComboBox) & @CRLF & _
'AutoIt ComboBox Handle: ' & _IsComboBox(GUICtrlGetHandle($iComboBox)) & @CRLF & _
'ComboBox UDF Handle: ' & _IsComboBox($hComboBox) & @CRLF)
_GUICtrlComboBox_Destroy($hComboBox)
Return GUIDelete($hGUI)
EndFunc ;==>Example
Func _IsComboBox($hWnd)
Return _WinAPI_GetClassName($hWnd) = 'ComboBox'
EndFunc ;==>_IsComboBox
_IsListBox() ~ Author - guinness
_IsListBox() ~ Author - guinness
; Check if a variable is referencing a ListBox control.
#include <GUIListBox.au3>
#include <WinAPI.au3>
Example()
Func Example()
Local $hGUI = GUICreate('')
Local $iLabel = GUICtrlCreateLabel('', 0, 0, 500, 500)
Local $iListBox = GUICtrlCreateList('', 0, 0, 500, 500)
Local $hListBox = _GUICtrlListBox_Create($hGUI, 'Example', 0, 0, 500, 500)
GUISetState(@SW_SHOW, $hGUI)
MsgBox(4096, '', 'AutoIt Label ID: ' & _IsListBox($iLabel) & @CRLF & _
'AutoIt Label Handle: ' & _IsListBox(GUICtrlGetHandle($iLabel)) & @CRLF & _
'AutoIt ListBox ID: ' & _IsListBox($iListBox) & @CRLF & _
'AutoIt ListBox Handle: ' & _IsListBox(GUICtrlGetHandle($iListBox)) & @CRLF & _
'ListBox UDF Handle: ' & _IsListBox($hListBox) & @CRLF)
_GUICtrlListBox_Destroy($hListBox)
Return GUIDelete($hGUI)
EndFunc ;==>Example
Func _IsListBox($hWnd)
Return _WinAPI_GetClassName($hWnd) = 'ListBox'
EndFunc ;==>_IsListBox
_IsListView() ~ Author - guinness
_IsListView() ~ Author - guinness
; Check if a variable is referencing a ListView control.
#include <GUIListView.au3>
#include <WinAPI.au3>
Example()
Func Example()
Local $hGUI = GUICreate('')
Local $iLabel = GUICtrlCreateLabel('', 0, 0, 500, 500)
Local $iListView = GUICtrlCreateListView(0, 0, 500, 500)
Local $hListView = _GUICtrlListView_Create($hGUI, 'Example', 0, 0, 500, 500)
GUISetState(@SW_SHOW, $hGUI)
MsgBox(4096, '', 'AutoIt Label ID: ' & _IsListView($iLabel) & @CRLF & _
'AutoIt Label Handle: ' & _IsListView(GUICtrlGetHandle($iLabel)) & @CRLF & _
'AutoIt ListView ID: ' & _IsListView($iListView) & @CRLF & _
'AutoIt ListView Handle: ' & _IsListView(GUICtrlGetHandle($iListView)) & @CRLF & _
'ListView UDF Handle: ' & _IsListView($hListView) & @CRLF)
_GUICtrlListView_Destroy($hListView)
Return GUIDelete($hGUI)
EndFunc ;==>Example
Func _IsListView($hWnd)
Return _WinAPI_GetClassName($hWnd) = 'SysListView32'
EndFunc ;==>_IsListView
_IsProgress() ~ Author - guinness
_IsProgress() ~ Author - guinness
; Check if a variable is referencing aProgress control.
#include <WinAPI.au3>
Example()
Func Example()
Local $hGUI = GUICreate('')
Local $iLabel = GUICtrlCreateLabel('', 0, 0, 500, 500)
Local $iProgress = GUICtrlCreateProgress(0, 0, 500, 20)
GUISetState(@SW_SHOW, $hGUI)
MsgBox(4096, '', 'AutoIt Label ID: ' & _IsProgress($iLabel) & @CRLF & _
'AutoIt Label Handle: ' & _IsProgress(GUICtrlGetHandle($iLabel)) & @CRLF & _
'AutoIt Progress ID: ' & _IsProgress($iProgress) & @CRLF & _
'AutoIt Progress Handle: ' & _IsProgress(GUICtrlGetHandle($iProgress)) & @CRLF)
Return GUIDelete($hGUI)
EndFunc ;==>Example
Func _IsProgress($hWnd)
Return _WinAPI_GetClassName($hWnd) = 'msctls_progress32'
EndFunc ;==>_IsProgress
_IsRadio() ~ Author - guinness
_IsRadio() ~ Author - guinness
; Check if a variable is referencing a Radio control.
#include <ButtonConstants.au3>
#include <Constants.au3>
#include <WinAPI.au3>
Example()
Func Example()
Local $hGUI = GUICreate('')
Local $iLabel = GUICtrlCreateCheckbox('', 0, 0, 500, 500) ; This is considered a 'Button' by _WinAPI_GetClassName too.
Local $iRadio = GUICtrlCreateRadio('', 0, 0, 100, 20)
GUISetState(@SW_SHOW, $hGUI)
MsgBox(4096, '', 'AutoIt Checkbox ID: ' & _IsRadio($iLabel) & @CRLF & _
'AutoIt Checkbox Handle: ' & _IsRadio(GUICtrlGetHandle($iLabel)) & @CRLF & _
'AutoIt Radio ID: ' & _IsRadio($iRadio) & @CRLF & _
'AutoIt Radio Handle: ' & _IsRadio(GUICtrlGetHandle($iRadio)) & @CRLF)
Return GUIDelete($hGUI)
EndFunc ;==>Example
Func _IsRadio($hWnd)
If IsHWnd($hWnd) = 0 Then
$hWnd = GUICtrlGetHandle($hWnd)
EndIf
If _WinAPI_GetClassName($hWnd) = 'Button' Then
Local $iLong = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE)
Return (BitAND($iLong, $BS_RADIOBUTTON) = $BS_RADIOBUTTON Or BitAND($iLong, $BS_AUTORADIOBUTTON) = $BS_AUTORADIOBUTTON)
EndIf
Return False
EndFunc ;==>_IsRadio
_IsSlider() ~ Author - guinness
_IsSlider() ~ Author - guinness
; Check if a variable is referencing a Slider control.
#include <WinAPI.au3>
Example()
Func Example()
Local $hGUI = GUICreate('')
Local $iLabel = GUICtrlCreateLabel('', 0, 0, 500, 500)
Local $iSlider = GUICtrlCreateSlider(0, 0, 500, 20)
GUISetState(@SW_SHOW, $hGUI)
MsgBox(4096, '', 'AutoIt Label ID: ' & _IsSlider($iLabel) & @CRLF & _
'AutoIt Label Handle: ' & _IsSlider(GUICtrlGetHandle($iLabel)) & @CRLF & _
'AutoIt Slider ID: ' & _IsSlider($iSlider) & @CRLF & _
'AutoIt Slider Handle: ' & _IsSlider(GUICtrlGetHandle($iSlider)) & @CRLF)
Return GUIDelete($hGUI)
EndFunc ;==>Example
Func _IsSlider($hWnd)
Return _WinAPI_GetClassName($hWnd) = 'msctls_trackbar32'
EndFunc ;==>_IsSlider
_IsTab() ~ Author - guinness
_IsTab() ~ Author - guinness
; Check if a variable is referencing a Tab control.
#include <GUITab.au3>
#include <WinAPI.au3>
Example()
Func Example()
Local $hGUI = GUICreate('')
Local $iLabel = GUICtrlCreateLabel('', 0, 0, 500, 500)
Local $iTab = GUICtrlCreateTab(0, 0, 500, 500)
Local $hTab = _GUICtrlTab_Create($hGUI, 0, 0, 500, 500)
GUISetState(@SW_SHOW, $hGUI)
MsgBox(4096, '', 'AutoIt Label ID: ' & _IsTab($iLabel) & @CRLF & _
'AutoIt Label Handle: ' & _IsTab(GUICtrlGetHandle($iLabel)) & @CRLF & _
'AutoIt Tab ID: ' & _IsTab($iTab) & @CRLF & _
'AutoIt Tab Handle: ' & _IsTab(GUICtrlGetHandle($iTab)) & @CRLF & _
'Tab UDF Handle: ' & _IsTab($hTab) & @CRLF)
_GUICtrlTab_Destroy($hTab)
Return GUIDelete($hGUI)
EndFunc ;==>Example
Func _IsTab($hWnd)
Return _WinAPI_GetClassName($hWnd) = 'SysTabControl32'
EndFunc ;==>_IsTab
_IsTreeView() ~ Author - guinness
_IsTreeView() ~ Author - guinness
; Check if a variable is referencing a TreeView control.
#include <GUITreeView.au3>
#include <WinAPI.au3>
Example()
Func Example()
Local $hGUI = GUICreate('')
Local $iLabel = GUICtrlCreateLabel('', 0, 0, 500, 500)
Local $iTreeView = GUICtrlCreateTreeView(0, 0, 500, 500)
Local $hTreeView = _GUICtrlTreeView_Create($hGUI, 'Example', 0, 0, 500, 500)
GUISetState(@SW_SHOW, $hGUI)
MsgBox(4096, '', 'AutoIt Label ID: ' & _IsTreeView($iLabel) & @CRLF & _
'AutoIt Label Handle: ' & _IsTreeView(GUICtrlGetHandle($iLabel)) & @CRLF & _
'AutoIt TreeView ID: ' & _IsTreeView($iTreeView) & @CRLF & _
'AutoIt TreeView Handle: ' & _IsTreeView(GUICtrlGetHandle($iTreeView)) & @CRLF & _
'TreeView UDF Handle: ' & _IsTreeView($hTreeView) & @CRLF)
_GUICtrlTreeView_Destroy($hTreeView)
Return GUIDelete($hGUI)
EndFunc ;==>Example
Func _IsTreeView($hWnd)
Return _WinAPI_GetClassName($hWnd) = 'SysTreeView32'
EndFunc ;==>_IsTreeView
Move Entire Screen Across ~ Author - Siao
Move Entire Screen Across ~ Author - Siao
#include <WindowsConstants.au3>
#include <WinAPI.au3>
$hScreenDC = _WinAPI_GetWindowDC(0)
$hMemDC = _WinAPI_CreateCompatibleDC($hScreenDC)
$hMemBMP = _WinAPI_CreateCompatibleBitmap($hScreenDC, @DesktopWidth*2, @DesktopHeight)
_WinAPI_DeleteObject(_WinAPI_SelectObject($hMemDC, $hMemBMP))
_WinAPI_BitBlt($hMemDC, 0, 0, @DesktopWidth, @DesktopHeight, $hScreenDC, 0, 0, $SRCCOPY)
_WinAPI_BitBlt($hMemDC, @DesktopWidth, 0, @DesktopWidth, @DesktopHeight, $hScreenDC, 0, 0, $SRCCOPY)
For $i = @DesktopWidth To 0 Step -8
_WinAPI_BitBlt($hScreenDC, 0, 0, @DesktopWidth, @DesktopHeight, $hMemDC, $i, 0, $SRCCOPY)
Sleep(20)
Next
_WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE+$RDW_ALLCHILDREN)
_WinAPI_ReleaseDC(0, $hScreenDC)
_WinAPI_DeleteObject($hMemBMP)
_WinAPI_DeleteDC($hMemDC)
Exit
; Edited - for up/down move - Malkey
#include <WindowsConstants.au3>
#include <WinAPI.au3>
$hScreenDC = _WinAPI_GetWindowDC(0)
$hMemDC = _WinAPI_CreateCompatibleDC($hScreenDC)
$hMemBMP = _WinAPI_CreateCompatibleBitmap($hScreenDC, @DesktopWidth, @DesktopHeight*2)
_WinAPI_DeleteObject(_WinAPI_SelectObject($hMemDC, $hMemBMP))
_WinAPI_BitBlt($hMemDC, 0, 0, @DesktopWidth, @DesktopHeight, $hScreenDC, 0, 0, $SRCCOPY)
_WinAPI_BitBlt($hMemDC, 0, @DesktopHeight, @DesktopWidth, @DesktopHeight, $hScreenDC, 0, 0, $SRCCOPY)
For $i = 0 To @DesktopHeight Step 8 ;scroll Up
;For $i = @DesktopHeight To 0 Step -8 ;scroll Down
_WinAPI_BitBlt($hScreenDC, 0, 0, @DesktopWidth, @DesktopHeight, $hMemDC, 0, $i, $SRCCOPY)
Sleep(20)
Next
_WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE+$RDW_ALLCHILDREN)
_WinAPI_ReleaseDC(0, $hScreenDC)
_WinAPI_DeleteObject($hMemBMP)
_WinAPI_DeleteDC($hMemDC)
Exit
Multi-Color Changing Background ~ Author - monoceres
Multi-Color Changing Background ~ Author - monoceres
; Multi-Color Changing Background
#include <GUIConstantsEx.au3>
Dim $color, $redm = 1, $bluem = 2, $greenm = 3, $index
GUICreate("test")
GUISetState()
While GUIGetMsg() <> -3
Sleep(10)
$index += 0.01
$color = "0x" & Hex(255 * ((Sin($index * $redm) + 1) / 2), 2) & Hex(255 * ((Sin($index * $greenm) + 1) / 2), 2) & Hex(255 * ((Sin($index * $bluem) + 1) / 2), 2)
GUISetBkColor($color)
WEnd
_SetPNGIntoPicControl() ~ Author - monoscout999
_SetPNGIntoPicControl() ~ Author - monoscout999
#include <GDIPlus.au3>
#include <Constants.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
Global Const $SC_MOVE = 0xF010
Global Const $STM_SETIMAGE = 0x172
; This Is For Getting The PNG From a URL
$PngFile = @ScriptDir & "\MyPNG.png"
$Inet = InetGet("http://img26.imageshack.us/img26/7439/boton3p.png", $PngFile)
;Here is the GUI creation
$hGUI = GUICreate("PNG Pic by monoscout999")
GUISetBkColor(0x123456, $hGUI)
$Pic = GUICtrlCreatePic("", 10, 10, 50, 50)
_SetPNGIntoPicControl($Pic, $PngFile)
GUISetState()
While True
$msg = GUIGetMsg()
Switch $msg
Case -3
Exit
Case $GUI_EVENT_PRIMARYDOWN
_ControlMove($Pic)
EndSwitch
WEnd
; Here is the function declared
Func _SetPNGIntoPicControl($iPic, $sPNGFile)
_GDIPlus_Startup()
Local $hImage = _GDIPlus_ImageLoadFromFile($sPNGFile)
Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
_WinAPI_DeleteObject(GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap))
_WinAPI_DeleteObject($hBitmap)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
EndFunc ;==>_SetPNGIntoPicControl
Func _ControlMove($cID)
Local $aCurPos = GUIGetCursorInfo()
If @error Then Return False
If $aCurPos[4] = $cID Then
GUICtrlSendMsg($cID, $WM_SYSCOMMAND, BitOR($SC_MOVE, $HTCAPTION), 0)
EndIf
EndFunc ;==>_ControlMove
_SwitchColor() ~ Author - RazerM
_SwitchColor() ~ Author - RazerM
; Switch BGR to RGB and vice versa
ConsoleWrite(0xFF0000 = SwitchColor(0x0000FF) & @CRLF)
Func _SwitchColor($iColor)
Local $iMask
$iMask = BitXOR(BitAND($iColor, 0xFF) , ($iColor / 0x10000))
Return BitXOR($iColor, ($iMask * 0x10001))
EndFunc ;==>_SwitchColor()
; XP Style For Colours
#include <GuiConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $XS_n, $x = 0
Global $gui = GuiCreate("MyGUI", 350, 42,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
_XPStyle(1)
Local $Pic_1 = GUICtrlCreateLabel("", 10, 10, 340, 20)
GUICtrlSetBkColor($Pic_1,0xff0000) ;Red
Local $Label_2 = GuiCtrlCreateLabel("", 10, 10, 340, 20)
Local $Label_3 = GUICtrlCreateLabel("", 10, 13, 5, 15, $SS_CENTER)
GUICtrlSetBkColor( -1, $GUI_BKCOLOR_TRANSPARENT )
_XPStyle(0)
GuiSetState()
do
Local $msg = GuiGetMsg()
if $msg = $GUI_EVENT_CLOSE then ExitLoop
Local $pos = ControlGetPos($gui,"",$Label_2)
if $pos[0] < 340 then
GUICtrlSetPos($Label_2,$pos[0]+((360/100)*1),10)
GUICtrlSetPos($Label_3, 10, 13, $pos[0]+((360/100)*1),15)
GUICtrlSetData( $Label_3, int($pos[0]+((360/100)*1)) & "%")
EndIf
Sleep(20)
if $x = 0 then
if $pos[0] > 339.9 then
MsgBox(0,"test","Done!")
$x = 1
EndIf
EndIf
$msg = GuiGetMsg()
if $msg = $GUI_EVENT_CLOSE then Exit
until $msg = $GUI_EVENT_CLOSE
Func _XPStyle($OnOff = 1)
If $OnOff And StringInStr(@OSTYPE, "WIN32_NT") Then
$XS_n = DllCall("uxtheme.dll", "int", "GetThemeAppProperties")
DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
Return 1
ElseIf StringInStr(@OSTYPE, "WIN32_NT") And IsArray($XS_n) Then
DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $XS_n[0])
$XS_n = ""
Return 1
EndIf
Return 0
EndFunc ;==>_XPStyle