Jump to content
Sign in to follow this  

Recommended Posts

GUI Fun!


Not enough posts here are about just plain fun stuff to do with AutoIt, at least not lately.  So I figure, why not dig up one of my old UDFs, clean it up a bit, and throw it very emphatically at you lot of misfits!

One way of mucking about with AutoIt and Windows that can be entertaining is creating shaped GUIs. Sure, GUIs with regions are nothing new here or in general on the Windows platform. But have you ever just wanted to stare at colorful shapes flying across your screen, for no apparent reason?  Well, my friend, you've come to the right place.

The first UDF I've put up pretty simple.  Boxes, circles, triangles, diamonds, and stars are what I bring you, in technicolor wonder.  I will probably add a few more examples when I find the time..

However, its my hope that more people add to this thread - and maybe provide links to other topics or posts where some nifty GUI fun is to be had!

GUI related Threads & UDFs of Interest

My Examples

I  should point out other GUI manipulation UDF's I've uploaded in the past, as they too can provide some amusement.

 

Okay, on to the new stuff!

_GUIShapes is a UDF with functions to create GUI's shapes like Circles, Boxes, Triangles, Stars, and Diamonds.  These GUI's have no interactive elements or controls and are click-through-able, meaning that a click on the GUI will pass through to whatever window is underneath.

_LineTraverser is a UDF with functions to create a well, line traverser. Given a start and end point, it will allow you to step through a given line without needing to do any extra work on your behalf.  This uses Bresenham's line algorithm to calculate the individual steps. I know this one isn't related to GUI, but its what I used for my second 'GUI fun' example below.

Pacman Line-Traversing GUI (>static or >animated). That's right, I managed to animate a GUI! Check it!  (now included in the ZIP)

Examples that follow will be bundled with the ZIP.  Have fun!

Updates:

2014-01-17:

- New _LineTraverser UDF with floating point math to replace the old (now renamed _LineTraverserB)

- Added Pacman examples

2014-01-17 'Hotfix':

- Fixed majorly borked Atan2() code

GUIShapesExample - whacky shapes flying all over the screen!!!

#include "_GUIShapes.au3"
;~ #include <WinAPI.au3>    ; already included in <_GUIShapes.au3>
; ========================================================================================================
; <GUIShapesExample.au3>
;
; Example use of <_GUIShapes.au3> UDF
;
; This example creates a bunch of random GUI shapes with random attributes, and moves
; everything around - randomly.
;
; Author: Ascend4nt
; ========================================================================================================

; ---------------------- MAIN CODE -------------------------------

Local $iShapeGUIs = 20, $aShapeGUIs[$iShapeGUIs], $iTimer, $iRand, $aRet
Local $iRandX, $iRandY, $iRandColor, $iRandLength
Local $iTriangles = 0, $iCircles = 0, $iStars = 0, $iDiamonds = 0, $iBoxes = 0

For $i = 0 To $iShapeGUIs - 1

    ; Everything random!
    $iRandX = Random(0, @DesktopWidth - 20, 1)
    $iRandY = Random(0, @DesktopHeight - 20, 1)
    $iRandLength = Random(12, 300, 1)
    $iRandColor = Random(0x111111, 0xFFFFFF, 1)

    ; Choose a GUI shape at random, with semi-random attributes
    Switch Random(0, 5, 1)
        Case 0
            $aShapeGUIs[$i] = _TriangleGUICreate($iRandX, $iRandY, $iRandLength, BitAND($iTriangles, 1) * Random(1, 10, 1), Default, Mod($i, 4), $iRandColor)
            $iTriangles += 1
        Case 1
            $aShapeGUIs[$i] = _CircleGUICreate($iRandX, $iRandY, $iRandLength, BitAND($iCircles, 1) * Random(1, 10, 1), Default, $iRandColor)
            $iCircles += 1
        Case 2
            $aShapeGUIs[$i] = _StarGUICreate($iRandX, $iRandY, $iRandLength, BitAND($iStars, 1) * Random(1, 10, 1), $iRandColor)
            $iStars += 1
        Case 3
            $aShapeGUIs[$i] = _DiamondGUICreate($iRandX, $iRandY, $iRandLength, Default, BitAND($iDiamonds, 1) * Random(1, 10, 1), $iRandColor)
            $iDiamonds += 1
        Case Else ; 4
            $aShapeGUIs[$i] = _BoxGUICreate($iRandX, $iRandY, $iRandLength, BitAND($iBoxes, 1) * Random(1, 10, 1), Default, $iRandColor)
            $iBoxes += 1
    EndSwitch

    ; Show the randomly created GUI
    GUISetState(@SW_SHOWNOACTIVATE, $aShapeGUIs[$i])

; And set a random transparency too
    WinSetTrans($aShapeGUIs[$i], '', Random(50, 255, 1))
Next
ConsoleWrite("GUI Totals: Triangles:" & $iTriangles & ", Circles:" & $iCircles & ", Stars:" & $iStars & ", Diamonds:" & $iDiamonds & ", Boxes:" & $iBoxes & @CRLF)

; Timer for moving shapes
$iTimer = TimerInit()
While 1
    ; Exit on 'ESC' keypress (BitAND() test for down-state)
    If BitAND(_WinAPI_GetAsyncKeyState(0x1B), 0x8000) Then ExitLoop

    Sleep(10)

    ; Move a random GUI every 30+ms
    If TimerDiff($iTimer) >= 30 Then
        $iRand = Random(0, $iShapeGUIs - 1, 1)
        ; Set GUI above other windows
        WinSetOnTop($aShapeGUIs[$iRand], "", 1)
        ; Move to a random position
        WinMove($aShapeGUIs[$iRand], "", Random(0, @DesktopWidth - 20, 1), Random(0, @DesktopHeight - 20, 1), Default, Default, 2)
        ; Reset timer
        $iTimer = TimerInit()
    EndIf
WEnd

_

LineTraverserExample - Where's the ball? Huh, where is it, Fido?! Ooh, there it is! Fetch the ball! Gooood circle..

#include "_GUIShapes.au3"
#include "_LineTraverser.au3"
;~ #include <WinAPI.au3>
; ========================================================================================================
; <LineTraverserExample.au3>
;
; Simple Example of using the <_LineTraverser.au3> and <_GuiShapes.au3> UDF's
;
;    A little red-ball will display, and a hollow ball will move towards it.
;    A line will be drawn to show how the path from the hollow ball to the red-ball target should work,
;    and then the hollow ball moves to it in $iStep increments.
;
;
; Author: Ascend4nt
; ========================================================================================================

Global Const $iStep = 2

Local $hHollowCircle, $hDestCircle, $iExt
Local $iXTarget, $iYTarget, $aLineTraverser

; Create the 2 circle GUIs
$hHollowCircle = _CircleGUICreate(Random(0, @DesktopWidth - 20, 1), Random(0, @DesktopHeight - 20, 1), 81, 10, Default, Random(0x111111, 0xFFFFFF, 1))
$hDestCircle = _CircleGUICreate(1, 1, 17, 0, 17, 0xFF0000)

; Set initial target point
$iXTarget = Random(0, @DesktopWidth - 20, 1)
$iYTarget = Random(0, @DesktopHeight - 20, 1)

; Source/Target are same to start off with
$aLineTraverser = _LineTraverserCreate($iXTarget, $iYTarget, $iXTarget, $iYTarget)

; Move windows to start positions
WinMove($hHollowCircle, '', $aLineTraverser[0], $aLineTraverser[1])
; + Center of hollow circle, - half of target circle
WinMove($hDestCircle, '', $iXTarget + 40 - 8, $iYTarget + 40 - 8)

; Transparency on 'seeker' circle
WinSetTrans($hHollowCircle, '', 150)

; Show both GUIs, and put on top of all windows
WinSetState($hDestCircle, '', @SW_SHOWNOACTIVATE)
WinSetState($hHollowCircle, '', @SW_SHOWNOACTIVATE)
WinSetOnTop($hHollowCircle, '', 1)
WinSetOnTop($hDestCircle, '', 1)

While 1
    ; Exit on 'ESC' keypress (in down state)
    If BitAND(_WinAPI_GetAsyncKeyState(0x1B), 0x8000) Then ExitLoop

    ; < 10 ms sleep with an API call
    DllCall("kernel32.dll",'none','Sleep','dword',3)

    If Not _LineTraverserStep($aLineTraverser, $iStep) Then
        $iExt = @extended

        ; Was there movement? Then moooove
        If $iExt Then
            WinMove($hHollowCircle, '', $aLineTraverser[0], $aLineTraverser[1])
        EndIf
        $aPos = WinGetPos($hHollowCircle)

        ; Debug check.  Should never be hit, so long as Window is moved to each step (including any last steps - see @extended)
        If $iXTarget <> $aPos[0] Or $iYTarget <> $aPos[1] Then
            ConsoleWrite("Mismatch: TargetX:" & $iXTarget & ", TraverserX:" & $aLineTraverser[0] & ", Current X:" & $aPos[0] & _
                    ", TargetY:" & $iYTarget & ", TraverserY:" & $aLineTraverser[1] & ", Current Y:" & $aPos[1] & ", @extended:" & $iExt & @CRLF)
                EndIf

        ; A little extra sleep to make it clear we've reached our destination.
        DllCall("kernel32.dll",'none','Sleep','dword',6)

        ; Now we'll set a new destination (with a visible line)
        Dim $iXTarget = Random(0, @DesktopWidth - 20, 1), $iYTarget = Random(0, @DesktopHeight - 20, 1)

        ; Create a new Line-Traverser (no need to explicitly destroy the last one, it was just an array of numbers)
        $aLineTraverser = _LineTraverserCreate($aLineTraverser[0], $aLineTraverser[1], $iXTarget, $iYTarget)

        ; + Center of hollow circle, - center of target circle
        WinMove($hDestCircle, '', $iXTarget + 40 - 8, $iYTarget + 40 - 8)

;~     Draw the line on-screen to give a visual indicator of the path that the hollow circle should take
;~     (note that the line will be overwritten by ANY screen activity, but that's fine for the example)

        ; Get DC to screen
        $hDC = _WinAPI_GetDC(0)
        ; Create pen and select it into DC
        $hPen = _WinAPI_CreatePen(0, 3, 0xFFFFFF)
        $hPenOld = _WinAPI_SelectObject($hDC, $hPen)
        ; Note we add 40 (for the center of the hollow circle GUI)
        _WinAPI_DrawLine($hDC, $aPos[0] + 40 - 1, $aPos[1] + 40 - 1, $iXTarget + 40 - 1, $iYTarget + 40 - 1)
        ; Select the old pen back
        _WinAPI_SelectObject($hDC, $hPenOld)
        ; Clean up pen and then release DC
        _WinAPI_DeleteObject($hPen)
        _WinAPI_ReleaseDC(0, $hDC)
        ; What fun drawing with GDI is  =|
    Else
        WinMove($hHollowCircle, '', $aLineTraverser[0], $aLineTraverser[1])
    EndIf
WEnd

GUIShapesFun.zip ~prev downloads: 60

Edited by Ascend4nt

Share this post


Link to post
Share on other sites

Interesting is the word that springs to mind.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites

Interesting is the word that springs to mind.

You are known for your wordy posts ;)  But hey, I forgot about your GUI Design Concepts thread - added a link to it.

Additionally, uploaded my 'LineTraverser' example


Share this post


Link to post
Share on other sites

 I forgot about your GUI Design Concepts thread - added a link to it.

Oh yeh, didn't cross my mind when I posted my response or did it?! -_0


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites

jaberwacky, thats pretty funny that I didn't think of that. It could work, though I'd want a bit more flash from it..

Lakes, thats an interesting challenge.  I don't know what the overhead is for creating regions, but what you request would need to create a new region applied to the GUI for each new target the PacGui has to chase.  I would need to break out my maths to calculate angles and convert them into lines, but I'm sure it could be done. Asking it to 'chomp' like pacman would be too much transitioning though.. unless perhaps 2 GUI's are swapped out for each other.  Hmm..  its something I'll ponder doing :)


Share this post


Link to post
Share on other sites

Well, Lakes.. I hope you're happy!  After hours of wading through mathematics crap I finally figured out that up was down and vice versa. And well.. Pacman has cometh forth to do its evil bidding upon your computer screen!

This was actually pretty fun to figure out the maths with, although I totally forgot that the cartesian coordinate system does not match the Windows coordinate system. And I didn't want to tweak around with Mapping modes or whatnot.. so I just flipped things around and hacked out a coordinate system that works (a counterclockwise upside-down one, but hey.. thats pretty much how I see the world) ;)

Here it is (you'll need the ZIP from the first post):

*Edit: Fixed borked ATan() related maths

Pacman Line-Traversing GUI Goodness

#include "_LineTraverser.au3"
#include "_GUIShapes.au3"
#include <WinAPI.au3>
; ========================================================================================================
; <LineTraverserPacmanExample.au3>
;
; Simple Example of using the <_LineTraverser.au3> and <_GuiShapes.au3> UDF's
;
;    A little red-ball displays, while a 'Pacman' GUI moves towards it along a line
;    An actual line is drawn onscreen to show the path from 'Pacman' to the red-ball target GUI,
;    and then the PacGUI moves to it in $iStep increments.
;
; Additional Functions:
;    _GUIApplyPacman()    ; Converts a square GUI into a Pacman-shaped GUI. Regions are recreated
;                        ; each time, based on the input
;    Atan2_Radians()        ; An 'atan2()' function
;
; Author: Ascend4nt
; ========================================================================================================

Global Const $iStep = 2

Local $hPacMan, $hDestCircle, $iExt
Local $iXTarget, $iYTarget, $aLineTraverser

; Create the Pacman GUI and apply shape to it
$hPacMan = GUICreate("", 81, 81,Random(0, @DesktopWidth - 20, 1), Random(0, @DesktopHeight - 20, 1), 0x80000000, 0x08000080 + 0x20)
GUISetBkColor(Random(0x111111, 0xFFFFFF, 1), $hPacMan)
_GUIApplyPacman($hPacMan, 0)

; Red-dot GUI
$hDestCircle = _CircleGUICreate(1, 1, 17, 0, 17, 0xFF0000)

; Set initial target point
$iXTarget = Random(0, @DesktopWidth - 20, 1)
$iYTarget = Random(0, @DesktopHeight - 20, 1)

; Source/Target are same to start off with
$aLineTraverser = _LineTraverserCreate($iXTarget, $iYTarget, $iXTarget, $iYTarget)

; Move windows to start positions
WinMove($hPacMan, '', $aLineTraverser[0], $aLineTraverser[1])
; + Center of hollow circle, - half of target circle
WinMove($hDestCircle, '', $iXTarget + 40 - 8, $iYTarget + 40 - 8)

; Transparency on 'seeker' circle
WinSetTrans($hPacMan, '', 150)

; Show both GUIs, and put on top of all windows
WinSetState($hDestCircle, '', @SW_SHOWNOACTIVATE)
WinSetState($hPacMan, '', @SW_SHOWNOACTIVATE)
WinSetOnTop($hPacMan, '', 1)
WinSetOnTop($hDestCircle, '', 1)

While 1
    ; Exit on 'ESC' keypress (in down state)
    If BitAND(_WinAPI_GetAsyncKeyState(0x1B), 0x8000) Then ExitLoop

    ; < 10 ms sleep with an API call
    DllCall("kernel32.dll",'none','Sleep','dword',3)

    If Not _LineTraverserStep($aLineTraverser, $iStep) Then
        $iExt = @extended

        ; Was there movement? Then moooove
        If $iExt Then
            WinMove($hPacMan, '', $aLineTraverser[0], $aLineTraverser[1])
        EndIf
        $aPos = WinGetPos($hPacMan)

        ; Debug check.  Should never be hit, so long as Window is moved to each step (including any last steps - see @extended)
        If $iXTarget <> $aPos[0] Or $iYTarget <> $aPos[1] Then
            ConsoleWrite("Mismatch: TargetX:" & $iXTarget & ", TraverserX:" & $aLineTraverser[0] & ", Current X:" & $aPos[0] & _
                    ", TargetY:" & $iYTarget & ", TraverserY:" & $aLineTraverser[1] & ", Current Y:" & $aPos[1] & ", @extended:" & $iExt & @CRLF)
                EndIf

        ; A little extra sleep to make it clear we've reached our destination.
        DllCall("kernel32.dll",'none','Sleep','dword',6)

        ; Now we'll set a new destination (with a visible line)
        Dim $iXTarget = Random(0, @DesktopWidth - 20, 1), $iYTarget = Random(0, @DesktopHeight - 20, 1)

        ; Create a new Line-Traverser (no need to explicitly destroy the last one, it was just an array of numbers)
        $aLineTraverser = _LineTraverserCreate($aLineTraverser[0], $aLineTraverser[1], $iXTarget, $iYTarget)

        ; + Center of hollow circle, - center of target circle
        WinMove($hDestCircle, '', $iXTarget + 40 - 8, $iYTarget + 40 - 8)

        ; Apply Pacman GUI with calculated angle of line it should point towards
        _GUIApplyPacman($hPacMan, Atan2_Radians($iYTarget - $aLineTraverser[1], $iXTarget - $aLineTraverser[0]))

    ; Draw the line on-screen to give a visual indicator of the path that the hollow circle should take
    ; (note that the line will be overwritten by ANY screen activity, but that's fine for the example)

        ; Get DC to screen
        $hDC = _WinAPI_GetDC(0)
        ; Create pen and select it into DC
        $hPen = _WinAPI_CreatePen(0, 3, 0xFFFFFF)
        $hPenOld = _WinAPI_SelectObject($hDC, $hPen)
        ; Note we add 40 (for the center of the hollow circle GUI)
        _WinAPI_DrawLine($hDC, $aPos[0] + 40 - 1, $aPos[1] + 40 - 1, $iXTarget + 40 - 1, $iYTarget + 40 - 1)
        ; Select the old pen back
        _WinAPI_SelectObject($hDC, $hPenOld)
        ; Clean up pen and then release DC
        _WinAPI_DeleteObject($hPen)
        _WinAPI_ReleaseDC(0, $hDC)
        ; What fun drawing with GDI is  =|
        ;Sleep(4000)
    Else
        WinMove($hPacMan, '', $aLineTraverser[0], $aLineTraverser[1])
    EndIf
WEnd
Exit


; =================================================================================================================
; Func _GUIApplyPacman($hGUI, $fAngleInRads)
;
; Takes a GUI and applies a 'Pacman' shape to it. The angle of Pacman's mouth is based upon the $fAngleinRads
; variable (the mouth is a 90 degree angle rotated towards the angle given)
;
; Returns:
;  Success: 1, @error = 0
;  Failure: 0, @error set
;
; Author: Ascend4nt
; =================================================================================================================

Func _GUIApplyPacman($hGUI, $fAngleInRads)
    Local $aPos, $aVertices, $hEllipseRgn = 0, $hPieRegion = 0
    Local $iCenterXY

    $aPos = WinGetPos($hGUI)
    If @error Then Return SetError(1, 0, 0)

    $iCenterXY = $aPos[2] / 2
    #cs
    ;; --------------
    ; Vertices array:
    ; ---------------
    ; These vertices make up the mouth. 0.78539816 is a 45 degree difference (in Radians)
    ; Note that the multipler should typically be Radius, not $aPos[2] as here, if we were creating a line
    ; to the circumference of the circle. However, that would cause a weird triangle-inside-a-circle effect
    ; when combining Regions. So we overextend it and let Windows clip the line at the GUI borders,
    ; which does its job of covering up the outer parts of the circle
    ; ----------------------------------------------------------------
    #ce
    Dim $aVertices[3][2] = [ _
        [ $iCenterXY, $iCenterXY ], _    ; We over-extend the lines here ($aPos[2] is way longer than the radius)
        [ $iCenterXY + $aPos[2] * Cos($fAngleInRads - 0.78539816), $iCenterXY + $aPos[2] * Sin($fAngleInRads - 0.78539816) ], _
        [ $iCenterXY + $aPos[2] * Cos($fAngleInRads + 0.78539816), $iCenterXY + $aPos[2] * Sin($fAngleInRads + 0.78539816) ] _
    ]

    Do

        ; Create a Basic Elliptical region
        $hEllipseRgn = _WinAPI_CreateEllipticRgn(_WinAPI_CreateRect(0, 0, $aPos[2], $aPos[3]))
        If $hEllipseRgn = 0 Then
            SetError(10)
            ExitLoop
        EndIf

        ; Create the Pacman Pie area
        $hPieRegion = _WinAPI_CreatePolygonRgn($aVertices, 0, -1, 1)
        If $hPieRegion = 0 Then
            SetError(12)
            ExitLoop
        EndIf

        ; Combine, put resulting region in $hEllipseRgn. RGN_AND = 1, RGN_OR = 2, RGN_XOR = 3, RGN_DIFF = 4
        If Not _WinAPI_CombineRgn($hEllipseRgn, $hEllipseRgn, $hPieRegion, 4) Then
            SetError(14)
            ExitLoop
        EndIf
        ; Don't need this anymore (already combined with the Region injected into the GUI)
        _WinAPI_DeleteObject($hPieRegion)


        ; Set the region into the GUI. (GUI will then own it so there's no need to delete it)
        If Not _WinAPI_SetWindowRgn($hGUI, $hEllipseRgn, True) Then
            SetError(16)
            ExitLoop
        EndIf

        Return 1
    Until 1

    Local $iErr = @error, $iExt = @extended

    ; Cleanup
    _WinAPI_DeleteObject($hEllipseRgn)
    _WinAPI_DeleteObject($hPieRegion)

    Return SetError($iErr, $iExt, 0)
EndFunc   ;==>_GUIApplyPacman


; =================================================================================================================
; Func Atan2_Radians($fY, $fX)
;
; Atan2() implementation, based on Wikipedia description.  See notes
;
; atan2() differs from atan() in that it maps atan(Y/X) to correct Quadrants
;
; References:
; https://en.wikipedia.org/wiki/Atan2
; https://en.wikipedia.org/wiki/Radian
; https://en.wikipedia.org/wiki/Cosine#Unit-circle_definitions
;
; Returns: Atan2() result in radians (for the flipped counterclockwise system)
;
; Author: Ascend4nt
; =================================================================================================================

Func Atan2_Radians($fY, $fX)
    Local Const $f_PI = 3.14159265
    Local Const $f_PIHalf = $f_PI / 2
;~     ConsoleWrite("Atan2 entry, $fY = " & $fY & ", $fX = " & $fX & @CRLF)
    If $fX = 0 Then
        ; Technically 'undefined'
        If $fY = 0 Then Return 0.0

        If $fY < 0 Then
            Return -$f_PIHalf
        Else ; $fY >= 0
            Return $f_PIHalf
        EndIf
    EndIf

    Local $fTmp = ATan($fY / $fX)

    If $fX < 0 Then
        If $fY < 0 Then
            Return $fTmp - $f_PI
        Else
            Return $fTmp + $f_PI
        EndIf
    Else ; $fX > 0    ; already checked == 0 at start
        Return $fTmp
    EndIf
EndFunc   ;==>Atan2_Radians
Edited by Ascend4nt

Share this post


Link to post
Share on other sites

The Pacman animation with the dots is missing  ;)

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

well, helloooo Mr Fancypants! hehe..  hey I know yer a master of the fine arts of GDI+ and GUIs, but making a Pacman GUI that animates is just plain nonsense!  The only thing I could do is swap out different GUIs to make it look like its animating.. OR change the Region every frame or so, but I wanted to avoid the latter in case it sucked up a lot of time, though swapping GUIs could be done simply enough.

Oh, and for some reason I can't change the line style no matter what Pen size/style I choose.. maybe its a limitation of drawing onto the desktop? I've tried CreatePenIndrect as well.. hmm

Anyway, Sifu UEZ.. what do you have up your sleeve?  I bet with GDI+ you could create a dotted line on the desktop. But what would u suggest as far as GUI 'animation' here? The idea is to not draw on the GUI itself..


Share this post


Link to post
Share on other sites

For the dotted lines I would use circles by calculating the slope of the start / end point, divide the line (way from start to end point) into n pieces and place my circles on this line (vector).

The animation of the pacman might be a little more complicated but you have alreay a solution for it. ;) You have to animate it by changing the angle of the "mouth" during the way from start to end point.

Anyhow, as you already said it is "plain nonsense!".

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

For the dotted lines I would use circles by calculating the slope of the start / end point, divide the line (way from start to end point) into n pieces and place my circles on this line (vector).

 

I do remember that line slop algorithm from algebra :)  I have that _LineTraverser UDF included in the ZIP which can be used to traverse a line in any number of steps.  Of course, it uses Bresenham's line algorithm, which was optimized so it wouldn't use floating point math.  However, in this day it makes little sense to use that, especially in a scripted language.. I may create a simplified version using the line algorithm.  But yes, planting circles along a line is a nice idea.. maybe every 5 spaces a circle of radius 3..

The animation of the pacman might be a little more complicated but you have alreay a solution for it. ;) You have to animate it by changing the angle of the "mouth" during the way from start to end point.

 

Yes, I had mentioned that I wasn't too sure about how much time/CPU adjusting Regions would take up.  However, out of curiosity I did an experiment, and it doesn't seem to take up much resources at all.. especially if its paced out.  The result is further below..

Anyhow, as you already said it is "plain nonsense!".

Of course, practicing nonsense is part of the fun of living ;).  I also have a 'bouncing ball' GUI example laying around too that I figure I should add here, once I clean up the simple 'physics'.  I bet you have something along those lines already in GDI+?  Might be fun to do as a GUI.

So here's the 'chomping' version of pacman.  No dots.. yet

Pacman Line-Traversing GUI, Take 2

*edit: Removed - See >Post below for the newer version.

Edited by Ascend4nt

Share this post


Link to post
Share on other sites

Well done!! :thumbsup:

Overlay the finished version (with dots) onto a map and submit (with video) to BBC Click

They use an animation like this to show where they are traveling to.

Fame for you and Autoit, Double Win! :)


2015 - Still no flying cars, instead blankets with sleeves.

Share this post


Link to post
Share on other sites

Updated

2014-01-17:

- New _LineTraverser UDF with floating point math to replace the old (now renamed _LineTraverserB)

- Added Pacman examples

2014-01-17 'Hotfix':

- Fixed majorly borked Atan2() code

Lakes, thanks but I've about had enough of the PacGUI! haha..

Ah, and here's the final Pacman animated GUI example. The 'final' dot doesn't seem to always line up, and squares happen to draw better than ellipses so you'll have to make do - or improve it as you wish :)

*Edit: Note, this example will eat up memory quickly.

This is due to a bug in Windows where it doesn't properly dispose of previous Regions that have been applied to a Window. Unfortunately, there's no way to get at the region once Window takes over it either...

In the future I may create a versoin with the 3 different 'animations' as 3 different GUI's and try swapping them in and out. It should alleviate the memory leak problem..

Pacman (Animated) Line-Traversing GUI, The Final Act

#include "_LineTraverser.au3"
#include "_GUIShapes.au3"
#include <WinAPI.au3>
; ========================================================================================================
; <LineTraverserPacmanExample.au3>
;
; Simple Example of using the <_LineTraverser.au3> and <_GuiShapes.au3> UDF's
;
;    A little red-ball displays, while a 'Pacman' GUI moves towards it along a line
;    An actual line is drawn onscreen to show the path from 'Pacman' to the red-ball target GUI,
;    and then the PacGUI moves to it in $iStep increments.
;
; Additional Functions:
;    _DrawPlainOldLine()        ; Draws a line on the screen
;    _DrawPacmanDottedLine()    ; Draws a special Pacman-Dotted line
;    _GUIApplyPacman()        ; Converts a square GUI into a Pacman-shaped GUI. Regions are recreated
;                            ; each time, based on the input
;    Atan2_Radians()            ; An 'atan2()' vfunction
;
; Author: Ascend4nt
; ========================================================================================================

Global Const $iStep = 2

Local $hPacMan, $hDestCircle, $iExt, $iStepsTaken = 0, $iMode = 0, $fLineAngleRads = 0
Local $iXTarget, $iYTarget, $aLineTraverser

; Create the Pacman GUI and apply shape to it
$hPacMan = GUICreate("", 81, 81, Random(0, @DesktopWidth - 20, 1), Random(0, @DesktopHeight - 20, 1), 0x80000000, 0x08000080 + 0x20)
GUISetBkColor(Random(0x111111, 0xFFFFFF, 1), $hPacMan)
_GUIApplyPacman($hPacMan, 0)

; Pink-dot GUI
$hDestCircle = _CircleGUICreate(1, 1, 17, 0, 17, 0xDE8394)

; Set initial target point
$iXTarget = Random(0, @DesktopWidth - 20, 1)
$iYTarget = Random(0, @DesktopHeight - 20, 1)

; Source/Target are same to start off with
$aLineTraverser = _LineTraverserCreate($iXTarget, $iYTarget, $iXTarget, $iYTarget)

; Move windows to start positions
WinMove($hPacMan, '', $aLineTraverser[0], $aLineTraverser[1])
; + Center of hollow circle, - half of target circle
WinMove($hDestCircle, '', $iXTarget + 40 - 8, $iYTarget + 40 - 8)

; Transparency on 'seeker' circle
WinSetTrans($hPacMan, '', 150)

; Show both GUIs, and put on top of all windows
WinSetState($hDestCircle, '', @SW_SHOWNOACTIVATE)
WinSetState($hPacMan, '', @SW_SHOWNOACTIVATE)
WinSetOnTop($hPacMan, '', 1)
WinSetOnTop($hDestCircle, '', 1)

While 1
    ; Exit on 'ESC' keypress (in down state)
    If BitAND(_WinAPI_GetAsyncKeyState(0x1B), 0x8000) Then ExitLoop

    ; < 10 ms sleep with an API call
    ;DllCall("kernel32.dll",'none','Sleep','dword',4)

    ; Slower allows to see mouth transitions better
    Sleep(10)

    If Not _LineTraverserStep($aLineTraverser, $iStep) Then
        $iExt = @extended

        ; Was there movement? Then moooove
        If $iExt Then
            WinMove($hPacMan, '', $aLineTraverser[0], $aLineTraverser[1])
        EndIf
        $aPos = WinGetPos($hPacMan)

        ; Debug check.  Should never be hit, so long as Window is moved to each step (including any last steps - see @extended)
        If $iXTarget <> $aPos[0] Or $iYTarget <> $aPos[1] Then
            ConsoleWrite("Mismatch: TargetX:" & $iXTarget & ", TraverserX:" & $aLineTraverser[0] & ", Current X:" & $aPos[0] & _
                    ", TargetY:" & $iYTarget & ", TraverserY:" & $aLineTraverser[1] & ", Current Y:" & $aPos[1] & ", @extended:" & $iExt & @CRLF)
        EndIf

        ; A little extra sleep to make it clear we've reached our destination.
        DllCall("kernel32.dll", 'none', 'Sleep', 'dword', 6)

        ; Now we'll set a new destination (with a visible line)
        Dim $iXTarget = Random(0, @DesktopHeight - 20, 1), $iYTarget = Random(0, @DesktopHeight - 20, 1)

        ;ConsoleWrite("New target: X: " & $iXTarget & ", Y: " & $iYTarget & ", FROM X: " & $aLineTraverser[0] & ", Y: " & $aLineTraverser[1] & @CRLF)

        ; Create a new Line-Traverser (no need to explicitly destroy the last one, it was just an array of numbers)
        $aLineTraverser = _LineTraverserCreate($aLineTraverser[0], $aLineTraverser[1], $iXTarget, $iYTarget)

        ; + Center of hollow circle, - center of target circle
        WinMove($hDestCircle, '', $iXTarget + 40 - 8, $iYTarget + 40 - 8)

        ; Apply Pacman GUI with calculated angle of line it should point towards
        $fLineAngleRads = Atan2_Radians($iYTarget - $aLineTraverser[1], $iXTarget - $aLineTraverser[0])
        _GUIApplyPacman($hPacMan, $fLineAngleRads)

        ; Draw the line on-screen to give a visual indicator of the path that the hollow circle should take
        ; (note that the line will be overwritten by ANY screen activity, but that's fine for the example)

        ; Add 40 for the center of the hollow circle GUI
        _DrawPacmanDottedLine($aPos[0] + 40 - 1, $aPos[1] + 40 - 1, $iXTarget + 40 - 1, $iYTarget + 40 - 1)
        ; Or
;~         _DrawPlainOldLine($aPos[0] + 40 - 1, $aPos[1] + 40 - 1, $iXTarget + 40 - 1, $iYTarget + 40 - 1)

    Else
        $iStepsTaken += 1
        If $iStepsTaken > 7 Then
            $iMode += 1
            ;If $iMode > 2 Then $iMode = 0    ; Function masks off the needed bits
            _GUIApplyPacman($hPacMan, $fLineAngleRads, $iMode)
            $iStepsTaken = 0
        EndIf
        WinMove($hPacMan, '', $aLineTraverser[0], $aLineTraverser[1])
    EndIf
WEnd
Exit

; =================================================================================================================
; Func _DrawPlainOldLine($iX1, $iY1, $iX2, $iY2)
;
; Draws a white line on the screen
;
; Author: Ascend4nt
; =================================================================================================================

Func _DrawPlainOldLine($iX1, $iY1, $iX2, $iY2)
    Local $hDC, $hPen, $hPenOld, $hBrush, $hBrushOld
    ; Get DC to screen
    $hDC = _WinAPI_GetDC(0)

    ; Create Pen (outline) [PS_SOLID = 0, PS_DASH = 1, PS_DOT = 2, PS_DASHDOT = 3, PS_DASHDOTDOT = 4, PS_NULL = 5]
    ; Seems no styles other than PS_SOLID work even if Width is <= 1, at least on the desktop DC in Win7
    $hPen = _WinAPI_CreatePen(0, 3, 0xFFFFFF)

    ; Alternatively, get a Stock Pen.. (width 1 unfortunately)
    ; WHITE_PEN = 6, BLACK_PEN = 7, NULL_PEN = 8
    ;$hPen = _WinAPI_GetStockObject(6)

    ; Create (or Get) Brush (fill)
    ; Doesn't seem to make a difference for Lines actually
    ; WHITE_BRUSH = 0, BLACK_BRUSH = 4, HOLLOW_BRUSH = 5
    $hBrush = _WinAPI_GetStockObject(0)
    ; BS_SOLID = 0, BS_HOLLOW = 1, BS_HATCHED = 2
;~     $hBrush = _WinAPI_CreateBrushIndirect(1, 0xFFFFFF, 0)

    ; Select Pen and Brush (saving old)
    $hPenOld = _WinAPI_SelectObject($hDC, $hPen)
    $hBrushOld = _WinAPI_SelectObject($hDC, $hBrush)

    _WinAPI_DrawLine($hDC, $iX1, $iY1, $iX2, $iY2)

    ; Select the old Brush and Pen back
    _WinAPI_SelectObject($hDC, $hBrushOld)
    _WinAPI_SelectObject($hDC, $hPenOld)

    ; Clean up pen & brush and then release DC
    _WinAPI_DeleteObject($hPen)
    ; _WinAPI_DeleteObject($hBrush)    ; No need to delete Stock Objects
    _WinAPI_ReleaseDC(0, $hDC)
    Return True
EndFunc   ;==>_DrawPlainOldLine

; =================================================================================================================
; Func _DrawPacmanDottedLine($iX1, $iY1, $iX2, $iY2)
;
; Draws a series of 'dots' on a given line.
;
; Unfortunately, in my tests, the Ellipse creates a bunch of artifacts, so the Rectangle is used to plot
; the dots.  Some versions of Pacman look like they use squares anyway..
;
; Author: Ascend4nt
; =================================================================================================================

Func _DrawPacmanDottedLine($iX1, $iY1, $iX2, $iY2)
    Local $hDC, $hPen, $hPenOld, $hBrush, $hBrushOld
    Local $aLineTraverser

    ; Line traverser for plotting Pac dots..
    $aLineTraverser = _LineTraverserCreate($iX1, $iY1, $iX2, $iY2)

    ; Get DC to screen
    $hDC = _WinAPI_GetDC(0)

    ; Create Pen (outline) [PS_SOLID = 0, PS_DASH = 1, PS_DOT = 2, PS_DASHDOT = 3, PS_DASHDOTDOT = 4, PS_NULL = 5]
    $hPen = _WinAPI_CreatePen(5, 3, 0x00FFFF)

    ; Create (or Get) Brush (fill)
    ; [BS_SOLID = 0, BS_HOLLOW = 1, BS_HATCHED = 2]
    ; {Hatch Styles} HS_HORIZONTAL  = 0, HS_VERTICAL  = 1, HS_FDIAGONAL  = 2,
    ;     HS_BDIAGONAL  = 3, HS_CROSS  = 4, HS_DIAGCROSS  = 5, HS_API_MAX  = 12
    $hBrush = _WinAPI_CreateBrushIndirect(0, 0xFFFF00, 0)

    ; Select Pen and Brush (saving old)
    $hPenOld = _WinAPI_SelectObject($hDC, $hPen)
    $hBrushOld = _WinAPI_SelectObject($hDC, $hBrush)

    ; We try to avoid drawing on the target circle
    While _LineTraverserStepsRemaining($aLineTraverser) > 30
        ; Steps of 20
        _LineTraverserStep($aLineTraverser, 20)
;~         _WinAPI_Ellipse($hDC, _WinAPI_CreateRect($aLineTraverser[0] - 5, $aLineTraverser[1] - 5, $aLineTraverser[0] + 5, $aLineTraverser[1] + 5))
        _WinAPI_Rectangle($hDC, _WinAPI_CreateRect($aLineTraverser[0] - 5, $aLineTraverser[1] - 5, $aLineTraverser[0] + 5, $aLineTraverser[1] + 5))
    WEnd

    ; Select the old Brush and Pen back
    _WinAPI_SelectObject($hDC, $hBrushOld)
    _WinAPI_SelectObject($hDC, $hPenOld)

    ; Clean up pen & brush and then release DC
    _WinAPI_DeleteObject($hPen)
    _WinAPI_DeleteObject($hBrush)
    _WinAPI_ReleaseDC(0, $hDC)
    Return True
EndFunc   ;==>_DrawPacmanDottedLine


; =================================================================================================================
; Func _GUIApplyPacman($hGUI, $fAngleInRads, $nMouthMode = 0)
;
; Takes a GUI and applies a 'Pacman' shape to it. The angle of Pacman's mouth is based upon the $fAngleinRads
; variable. It also has 3 modes - mouth closed, partially open, or open to 90 degrees (rotated to face given angle)
;
; Parameters:
;  $hGUI = GUI that will have a 'Pacman' Region applied to it
;  $fAngleInRads = The Angle which the 'mouth' should center on, given in Radians (Degrees * PI / 180)
;  $iMouthMode = 'Mode' of mouth: 0 (default) = 90 degree span, 1 = 40 degree span, 2 = closed (basic circle Region)
;
; Returns:
;  Success: 1, @error = 0
;  Failure: 0, @error set
;
; Author: Ascend4nt
; =================================================================================================================

Func _GUIApplyPacman($hGUI, $fAngleInRads, $iMouthMode = 0)
    Local $aPos, $aVertices, $hEllipseRgn = 0, $hPieRegion = 0
    Local $iCenterXY, $fMouthAngleRad

    $aPos = WinGetPos($hGUI)
    If @error Then Return SetError(1, 0, 0)

    $iCenterXY = $aPos[2] / 2

    $iMouthMode = BitAND($iMouthMode, 3)
    Switch $iMouthMode
        Case 1
            ; 20 Degrees
            $fMouthAngleRad = 0.34906585
        Case 2
            ; No adjustment necessary, we're using a full circle
            $fMouthAngleRad = 0
        Case Else
            ; 45 Degrees
            $fMouthAngleRad = 0.78539816
    EndSwitch

    Do
        ; Create a Basic Elliptical region
        $hEllipseRgn = _WinAPI_CreateEllipticRgn(_WinAPI_CreateRect(0, 0, $aPos[2], $aPos[3]))
        If $hEllipseRgn = 0 Then
            SetError(10)
            ExitLoop
        EndIf

        ; Everything OTHER than Mode 2 gets a 'mouth' applied
        If $iMouthMode <> 2 Then
            #cs
                ;; --------------
                ; Vertices array:
                ; ---------------
                ; These vertices make up the mouth.
                ; Note that the multipler should typically be Radius, not $aPos[2] as here, if we were creating a line
                ; to the circumference of the circle. However, that would cause a weird triangle-inside-a-circle effect
                ; when combining Regions (leaving whats known as a 'Chord' behind). So we overextend it and let
                ; Windows clip the line at the GUI borders, which does its job of covering up the outer parts of the circle
                ; -----------------------------------------------------------------------------------------------------
            #ce
            Dim $aVertices[3][2] = [ _
                    [$iCenterXY, $iCenterXY], _    ; We over-extend the lines here ($aPos[2] is way longer than the radius)
                    [$iCenterXY + $aPos[2] * Cos($fAngleInRads - $fMouthAngleRad), $iCenterXY + $aPos[2] * Sin($fAngleInRads - $fMouthAngleRad)], _
                    [$iCenterXY + $aPos[2] * Cos($fAngleInRads + $fMouthAngleRad), $iCenterXY + $aPos[2] * Sin($fAngleInRads + $fMouthAngleRad)] _
                    ]

            ; Create the Pacman Pie area
            $hPieRegion = _WinAPI_CreatePolygonRgn($aVertices, 0, -1, 1)
            If $hPieRegion = 0 Then
                SetError(12)
                ExitLoop
            EndIf

            ; Combine, put resulting region in $hEllipseRgn. (RGN_AND = 1, RGN_OR = 2, RGN_XOR = 3, RGN_DIFF = 4)
            If Not _WinAPI_CombineRgn($hEllipseRgn, $hEllipseRgn, $hPieRegion, 4) Then
                SetError(14)
                ExitLoop
            EndIf

            ; Don't need this anymore (already combined with the Region injected into the GUI)
            _WinAPI_DeleteObject($hPieRegion)
        EndIf

        ; Set the region into the GUI. (GUI will then own it so there's no need to delete it)
        If Not _WinAPI_SetWindowRgn($hGUI, $hEllipseRgn, True) Then
            SetError(16)
            ExitLoop
        EndIf

        Return 1
    Until 1

    Local $iErr = @error, $iExt = @extended

    ; Cleanup
    _WinAPI_DeleteObject($hEllipseRgn)
    _WinAPI_DeleteObject($hPieRegion)

    Return SetError($iErr, $iExt, 0)
EndFunc   ;==>_GUIApplyPacman


; =================================================================================================================
; Func Atan2_Radians($fY, $fX)
;
; Atan2() implementation, based on Wikipedia description.  See notes
;
; atan2() differs from atan() in that it maps atan(Y/X) to correct Quadrants
;
; References:
; https://en.wikipedia.org/wiki/Atan2
; https://en.wikipedia.org/wiki/Radian
; https://en.wikipedia.org/wiki/Cosine#Unit-circle_definitions
;
; Returns: Atan2() result in radians (for the flipped counterclockwise system)
;
; Author: Ascend4nt
; =================================================================================================================

Func Atan2_Radians($fY, $fX)
    Local Const $f_PI = 3.14159265
    Local Const $f_PIHalf = $f_PI / 2
;~     ConsoleWrite("Atan2 entry, $fY = " & $fY & ", $fX = " & $fX & @CRLF)
    If $fX = 0 Then
        ; Technically 'undefined'
        If $fY = 0 Then Return 0.0

        If $fY < 0 Then
            Return -$f_PIHalf
        Else ; $fY >= 0
            Return $f_PIHalf
        EndIf
    EndIf

    Local $fTmp = ATan($fY / $fX)

    If $fX < 0 Then
        If $fY < 0 Then
            Return $fTmp - $f_PI
        Else
            Return $fTmp + $f_PI
        EndIf
    Else ; $fX > 0    ; already checked == 0 at start
        Return $fTmp
    EndIf
EndFunc   ;==>Atan2_Radians
Edited by Ascend4nt

Share this post


Link to post
Share on other sites

When im trying to compile my file it has a error with my script and i can't fix it. Please Help..

This error on all the examples. ERROR: $IMAGE_BITMAP previously declared as a 'Const'.

Share this post


Link to post
Share on other sites

Kudos and a hearty "hear hear" for this post.

I suck at GUI design, I hate it, and my programs look terrible.  While "having fun" doesn't necessarily lead to efficient GUI design, you never know when you'll stumble across a diamond in the rough that is just what one needs to spice up a boring grey window with buttons.

I vote for more!

Share this post


Link to post
Share on other sites

 

Updated

2014-01-17:

- New _LineTraverser UDF with floating point math to replace the old (now renamed _LineTraverserB)

- Added Pacman examples

2014-01-17 'Hotfix':

- Fixed majorly borked Atan2() code

Lakes, thanks but I've about had enough of the PacGUI! haha..

Ah, and here's the final Pacman animated GUI example. The 'final' dot doesn't seem to always line up, and squares happen to draw better than ellipses so you'll have to make do - or improve it as you wish :)

*Edit: Note, this example will eat up memory quickly.

This is due to a bug in Windows where it doesn't properly dispose of previous Regions that have been applied to a Window. Unfortunately, there's no way to get at the region once Window takes over it either...

In the future I may create a versoin with the 3 different 'animations' as 3 different GUI's and try swapping them in and out. It should alleviate the memory leak problem..

Pacman (Animated) Line-Traversing GUI, The Final Act

#include "_LineTraverser.au3"
#include "_GUIShapes.au3"
#include <WinAPI.au3>
; ========================================================================================================
; <LineTraverserPacmanExample.au3>

Where can I get a hold of the 2 includes that I can't find on any search?

#include "_LineTraverser.au3"

#include "_GUIShapes.au3"

I would love to have those 2 includes. I have collected a good 1,009 includes from all over Autoit forum. These two are the only ones I have not been able to find. Can you please post them?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By thedemons
      Introduction
      ImGui is a popular library written by ocornut, it can make awesome user interface based on directx. It is being used by many big apps/games.  The UI is nice and flexible, easy to use because of frame-by-frame drawing. So I decided to convert the entire ImGui library to AutoIt
      At first it's just an experiment, i converted some basic draw functions of imgui, compile to a dll, then using DllCall in autoit to call the functions. I was testing to see how much FPS i can get in autoit, and i was expected a low FPS, since autoit is slow. Suprisingly, the FPS turned out to be so high, it works really fast, even when drawing 1000 buttons at the same time. Features
      More than +270 functions converted from ImGui (compiled dll). Has 90% of the capability of what you can do in C++; Usable ImGuiIO and ImGuiStyle, so you can set whatever configurations you like. Preview
          
      Usage
      #include <WinAPI.au3> #include "ImGui.au3" ; Create a window Local $hwnd = _ImGui_GUICreate("AutoIt ImGui", 1024, 768) _WinAPI_ShowWindow($hwnd) ; Set style color _ImGui_StyleColorsLight() ;~ _ImGui_StyleColorsDark() Local $f_value = 5 While 1 ; when the user click close button on the window, this will return false if Not _ImGui_PeekMsg() Then Exit ; must call _ImGui_BeginFrame() _ImGui_Begin("Another window") _ImGui_Text("Hello there..") If _ImGui_Button("click me") Then $f_value = 5 _ImGui_SliderFloat("slider", $f_value, 2, 20) If _ImGui_IsItemHovered() Then _ImGui_ToolTip("what r u doing?") _ImGui_End() ; must call _ImGui_EndFrame() Wend  
      Remark
      Most of the functions were converted automatically. I haven't tested all of them yet, if some function doesn't work for you, please tell me. Still missing some features of ImGui, please tell me if you needed any. Run \tools\imgui-au3-setup.au3 to add _ImGui functions to SciTE auto-complete. Source Code
      Require: DirectX GitHub: imgui-autoit
    • By MesterPerfect
      good morning
      this is the first post here in the autoit forums
      i hope that you can help me in my problem
      i have a JSON encoded
      it a map of my forums
      where i want to make a treeview that have the same type of map
      e.g
      a system (as category)
      windows (as sub category)
      software (as an child item in the windows category)
      .....
      i don't know how to do that
      so, i know that i can do that using the json functions
      but i need your help about how we can do it as the type that i told you
      by the way i need to put the sub info for each item in an array that give me the ability to manage my items
      e.g
      can post thread
      can reply
      message cound ...
      you just give me a small example and i can continue.
      am sorry if this against the rules of the forum.
      but i realy searched a lot but i couldn't
      i hope some one give me the way.
      thank you very much in advance
       
      here is the link of json forum
      https://www.autoitscript.com/forum/topic/148114-a-non-strict-json-udf-jsmn/
      and here is my encoded json file
       
      { "tree_map": { "0": [ 1, 5, 6, 7 ], "1": [ 2 ], "2": [ 4 ], "5": [ 3 ], "6": [ 8 ], "8": [ 9, 10 ] }, "nodes": [ { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 1, "node_id": 1, "node_name": null, "node_type_id": "Category", "parent_node_id": 0, "title": "Main category", "type_data": {} }, { "breadcrumbs": [ { "node_id": 1, "title": "Main category", "node_type_id": "Category" } ], "description": "", "display_in_list": true, "display_order": 1, "node_id": 2, "node_name": null, "node_type_id": "Forum", "parent_node_id": 1, "title": "Main forum", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 1, "title": "Main category", "node_type_id": "Category" }, { "node_id": 2, "title": "Main forum", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 1, "node_id": 4, "node_name": null, "node_type_id": "Forum", "parent_node_id": 2, "title": "my forums1", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 2, "node_id": 5, "node_name": null, "node_type_id": "Category", "parent_node_id": 0, "title": "Perfect", "type_data": {} }, { "breadcrumbs": [ { "node_id": 5, "title": "Perfect", "node_type_id": "Category" } ], "description": "", "display_in_list": true, "display_order": 2, "node_id": 3, "node_name": null, "node_type_id": "Forum", "parent_node_id": 5, "title": "ahmed", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 3, "node_id": 6, "node_name": null, "node_type_id": "Forum", "parent_node_id": 0, "title": "autoit", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 6, "title": "autoit", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 3, "node_id": 8, "node_name": null, "node_type_id": "Forum", "parent_node_id": 6, "title": "examples", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 6, "title": "autoit", "node_type_id": "Forum" }, { "node_id": 8, "title": "examples", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 3, "node_id": 9, "node_name": null, "node_type_id": "Forum", "parent_node_id": 8, "title": "GUI", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 6, "title": "autoit", "node_type_id": "Forum" }, { "node_id": 8, "title": "examples", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 31, "node_id": 10, "node_name": null, "node_type_id": "Forum", "parent_node_id": 8, "title": "windowEX", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 4, "node_id": 7, "node_name": null, "node_type_id": "Category", "parent_node_id": 0, "title": "vbs", "type_data": {} } ] }  
    • By Tosyk
      Hi,
      Please help me to beat the flashing of input field:
      #include <File.au3> #Include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ColorConstants.au3> AutoItSetOption("MustDeclareVars", 1) HotKeySet("{ESC}", "Terminate") Local $i Local $sSourceFile, $sDestFileA, $sDestFile3, $sRunWaitA, $sParamsA, $sNewFileNameA, $sFileLogPath, $iFileSize, $ScriptNameWoExt Local $hGUI, $ProgressBar1, $Label, $Progress, $Progress1, $inpVal, $CheckKeepAlpha, $v1, $sNewFileName, $sDestFile, $sParams, $sRunWait, $LabelStatus, $bMover, $cMover, $qMover, $ExtractAlpha, $FlipY, $ExtractBlue Local $sDrive, $sFolder, $sFileName, $sExt ;path to image magick tools Local $sIMConv = 'magick.exe', $sIMPathFull = 'C:\Program Files\ImageMagick\', $sIMPath = FileGetShortName($sIMPathFull & $sIMConv) ;supported input file extensions Local $Exts = "tga|jpg|bmp|dds|png|tif|jpeg", $sPattern = "\.(?i:" & $Exts & ")", $ExtsPreview = " tga | jpg | bmp | dds | png | tif | jpeg " Local $ExtOutput = "jpg", $ExtOutput2 = "png" Local $LogDefaultSize = '70' If Not $CmdLine[0] Then MsgBox($MB_SYSTEMMODAL, "Usage", "Drop " & $ExtsPreview & " file(s)" & @LF & "on " & @ScriptName) ConsoleWrite("Usage: " & @ScriptName & " <file>" & @CRLF) Exit EndIf If $CmdLine[0] <> 0 Then If FileExists($sIMPath) Then ProcessFiles() Else MsgBox(0, $sIMConv & " not found", "File [" & $sIMPathFull & $sIMConv & "] not found" & @CRLF) ConsoleWrite("Download Image Magick: " & $sIMConv & " to use this tool." & @CRLF) EndIf Else MsgBox(0, "Usage", "Drop file(s) on " & @ScriptName) ConsoleWrite("Usage: " & @ScriptName & " <file>" & @CRLF) EndIf Func ProcessFiles() #Region ### START Koda GUI section ### Form= $hGUI = GUICreate("Converting to PNG", 300, 285, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX)) GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate") ;PNG Option group $cMover = 0 Local $Group2 = GUICtrlCreateGroup("Options (PNG):", 8, 5+$cMover, 284, 56) $CheckKeepAlpha = GUICtrlCreateCheckbox("Keep alpha channel", 24, 30+$cMover, 130, 17) $FlipY = GUICtrlCreateCheckbox("Flip Vertical", 160, 30+$cMover, 130, 17) GUICtrlSetState($CheckKeepAlpha, $GUI_CHECKED) ;JPG Quality Input $qMover = 68 Local $Group1 = GUICtrlCreateGroup("Extraction options (JPG):", 8, 5+$qMover, 284, 86) $ExtractAlpha = GUICtrlCreateCheckbox("Extract alpha channel", 24, 28+$qMover, 130, 17) $ExtractBlue = GUICtrlCreateCheckbox("Extract blue channel", 160, 28+$qMover, 130, 17) $inpVal = GUICtrlCreateInput("90", 20, 56+$qMover, 260, 22) GUICtrlSetState($inpVal, $GUI_DISABLE) ;Buttons and bar $bMover = 92 $Label = GUICtrlCreateLabel("Press Convert to proceed", 20, 94+$bMover, 220, 20, $SS_LEFT) $LabelStatus = GUICtrlCreateLabel("Ready", 20, 153+$bMover, 220, 20, $SS_LEFT) $Progress1 = CreateProgress(20, 115+$bMover, 260, 20) Local $Button1 = GUICtrlCreateButton("Convert", 206, 150+$bMover, 75, 25) GUICtrlSetState ($Button1, $GUI_DEFBUTTON) ;Initializer GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Exit Case $ExtractAlpha or $ExtractBlue If _IsChecked($ExtractAlpha) or _IsChecked($ExtractBlue) Then GUICtrlSetState($inpVal, $GUI_ENABLE) Else GUICtrlSetState($inpVal, $GUI_DISABLE) EndIf Case $Button1 GUICtrlSetState($inpVal, $GUI_DISABLE) GUICtrlSetState($CheckKeepAlpha, $GUI_DISABLE) GUICtrlSetState($Button1, $GUI_DISABLE) MainLoop() ExitLoop Case Else ContinueLoop EndSwitch WEnd EndFunc ;==>ProcessFiles Func Settings() If _IsChecked($CheckKeepAlpha) Then $v1 = ' ' Else $v1 = ' ' & '-alpha off' & ' ' EndIf If _IsChecked($ExtractAlpha) Then ;Extracting JPG $sSourceFile = '"' & $sSourceFile & '"' $sNewFileNameA = ($sFileName & '_a.' & $ExtOutput) $sDestFileA = '"' & $sDrive & StringTrimRight($sFolder, 1) & '\' & $sNewFileNameA & '"' $sParamsA = '-channel A -separate -quality' & ' ' & GUICtrlRead($inpVal) & ' ' & '-colorspace sRGB' $sRunWaitA = $sIMPath & " " & $sSourceFile & " " & $sParamsA & " " & $sDestFileA EndIf ;Converting PNG $sNewFileName = ($sFileName & '.' & $ExtOutput2) $sDestFile = '"' & $sDrive & StringTrimRight($sFolder, 1) & '\' & $sNewFileName & '"' $sDestFile3 = $sDrive & StringTrimRight($sFolder, 1) & '\' & $sNewFileName $sParams = $v1 & '-colorspace sRGB' $sRunWait = $sIMPath & " " & $sSourceFile & " " & $sParams & " " & $sDestFile EndFunc ;==>Settings Func MainLoop() WriteLogFile() ConsoleWrite("File Log Path: " & $sFileLogPath & @LF) For $i = 1 To $CmdLine[0] $sSourceFile = $CmdLine[$i] _PathSplit($sSourceFile, $sDrive, $sFolder, $sFileName, $sExt) GUICtrlSetData($ProgressBar1, ($i / $CmdLine[0]) * 100) UpdateProgress($Progress1, ($i / $CmdLine[0]) * 100) GUICtrlSetData($Label, $sFileName & $sExt) GUICtrlSetState($LabelStatus, $GUI_ENABLE) GUICtrlSetColor($LabelStatus, $COLOR_BLACK) GUICtrlSetData($LabelStatus, 'Converting') Sleep(20) If StringRegExp($sExt, "\A" & $sPattern & "\z", 0) = 1 Then If FileExists($sSourceFile) Then Settings() ; function of settings ConsoleWrite("Full converting path: " & $sRunWaitA & @LF) If _IsChecked($ExtractAlpha) Then RunWait(@ComSpec & ' /c ' & $sRunWaitA, '', @SW_HIDE) EndIf RunWait(@ComSpec & ' /c ' & $sRunWait, '', @SW_HIDE) Else ConsoleWriteError("File [" & $sSourceFile & "] not found" & @CRLF) EndIf If FileExists($sDestFile3) Then LabelAnim(' .') LabelAnim(' . .') LabelAnim(' . . .') LabelAnim(' . . . OK') Sleep(20) Else LabelAnim(' .') LabelAnim(' . .') LabelAnim(' . . .') GUICtrlSetColor($LabelStatus, $COLOR_RED) LabelAnim(' . . . ERROR') UpdateLogFile() EndIf Else ; MsgBox(0, "Wrong extension", "Extension of file [" & $sFileName & "] is [" & $sExt & "] and not in" & @LF & "[" & $ExtsPreview & "]" & @CRLF) ConsoleWriteError("Extension of file [" & $sSourceFile & "] is [" & $sExt & "] and not in [" & $sPattern & "]" & @CRLF) ; Terminate() LabelAnim(' .') LabelAnim(' . .') LabelAnim(' . . .') GUICtrlSetColor($LabelStatus, $COLOR_RED) LabelAnim(' . . . Wrong Extension') UpdateLogFile() EndIf Next ; Retrieve the file size (in bytes) $iFileSize = FileGetSize($sFileLogPath) ConsoleWrite("FileLog size: " & $iFileSize & @LF) If $iFileSize < $LogDefaultSize Then FileDelete($sFileLogPath) ElseIf $iFileSize > $LogDefaultSize Then FileMove($sFileLogPath, @WorkingDir, $FC_OVERWRITE) EndIf GUICtrlSetData($Label, "Converting complete") Sleep(10) EndFunc ;==>MainLoop Func LabelAnim($Result) GUICtrlSetData($LabelStatus, 'Converting' & $Result) Sleep(12) EndFunc Func RemoveExt($Input) Local $ExtArray = StringSplit($Input, ".") Return StringReplace($Input, "." & $ExtArray[$ExtArray[0]], "", -1) EndFunc Func GetFileName($Input) Local $PathArray = StringSplit($Input, "\/") Return $PathArray[$PathArray[0]] EndFunc ;--------------------------------------------------------------- ;- Creating file in @tempdir ;--------------------------------------------------------------- Func WriteLogFile() ; Create a constant variable in Local scope of the filepath that will be read/written to. $ScriptNameWoExt = RemoveExt(GetFileName(@ScriptName)) $sFileLogPath = (@TempDir & '\' & '_' & $ScriptNameWoExt & '_errorlog_' & @YEAR & '_' & @MON & '_' & @MDAY & '_' & @HOUR & '_' & @MIN & '_' & @SEC & '_.txt') If FileExists($sFileLogPath) Then FileDelete($sFileLogPath) EndIf ; Create a temporary file to write data to. If Not FileWrite($sFileLogPath, "ImageMagick converter (" & $sIMConv & ") can't convert these files:" & @CRLF) Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.") Return False EndIf EndFunc ;--------------------------------------------------------------- ;- Update log file in @tempdir ;--------------------------------------------------------------- Func UpdateLogFile() ; Open the file for writing (append to the end of a file) and store the handle to a variable. Local $hFileOpen = FileOpen($sFileLogPath, $FO_APPEND) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.") Return False EndIf ; Write data to the file using the handle returned by FileOpen. FileWriteLine($hFileOpen, ($sFileName & $sExt)) Sleep(20) ; Close the handle returned by FileOpen. FileClose($hFileOpen) EndFunc ;--------------------------------------------------------------- ;- Enhanced Progress widget ;--------------------------------------------------------------- Func CreateProgress($x, $y, $w, $h, $Label="") Dim $Progress[2] $Progress[0] = GuiCtrlCreateProgress($x, $y, $w, $h) ; this is progress bar $Progress[1] = GuiCtrlCreateLabel("---", $x+0, $y-21, '', '', $SS_RIGHT) ; this is percentage label GUICtrlSetFont($Progress[1], 11, 500, 0, "") GUICtrlSetBkColor($Progress[1], $GUI_BKCOLOR_TRANSPARENT) Return $Progress EndFunc Func UpdateProgress($ProgressID, $Percent, $Label="") GUICtrlSetData($ProgressID[0], $Percent) GUICtrlSetData($ProgressID[1], $Label & Round($Percent, 1) & "%") EndFunc Func _IsChecked($idControlID) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked Func Terminate() If WinGetHandle('') <> $hGUI Then HotKeySet('{ESC}') Send('{ESC}') HotKeySet('{ESC}', '_Close') Return EndIf GUIDelete() Exit EndFunc ;==>Terminate Exit(0) the problem caused by this area:
      Case $ExtractAlpha or $ExtractBlue If _IsChecked($ExtractAlpha) or _IsChecked($ExtractBlue) Then GUICtrlSetState($inpVal, $GUI_ENABLE) Else GUICtrlSetState($inpVal, $GUI_DISABLE) EndIf if I remove "or $ExtractBlue" and "or _IsChecked($ExtractBlue)" the input field is not flashing.
      p.s.: also my button don't work if I use OR for the "Case" condition.
    • By nooneclose
      Why can I not click on either of my input fields?
      #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Form1", 730, 437, 192, 124) ;GUISetFont(14, 800, 0, "MS Sans Serif") GUISetBkColor(0xC0DCC0) Global $Label1 = GUICtrlCreateLabel("Enter your Password. UserName is auto filled", 62, 40, 604, 41, $SS_CENTER) GUICtrlSetFont(-1, 26, 800, 0, "MS Sans Serif") Global $Label2 = GUICtrlCreateLabel("User Name:", 120, 130, 604, 31, $SS_LEFT) GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif") Global $Label3 = GUICtrlCreateLabel("Password:", 135, 210, 604, 31, $SS_LEFT) GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif") Global $Input1 = GUICtrlCreateInput(@UserName, 274, 130, 185, 32) GUICtrlSetFont(-1, 14, 800, 1, "MS Sans Serif") Global $Input2 = GUICtrlCreateInput("Password", 274, 210, 185, 32, $ES_PASSWORD) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") Global $OK = GUICtrlCreateButton("OK", 274, 270, 185, 57) GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $OK Global $UserName = GUICtrlRead($Input1) Global $PassWord = GUICtrlRead($Input2) ExitLoop EndSwitch WEnd ; Delete the GUI window GUIDelete()  
    • By sudeepjd
      I was looking for a way to embed Windows Media Player into Autoit. I found 2 Windows Media Player UDF's but both of them seem to have used the OCX directly. The problem with using the OCX directly is that the video display size cannot be changed, and it takes the size of the video inherently.
      @seangriffin created the VLC GUI based on embedding the IE object into the GUI and that seems to work perfectly with Windows Media Player as well and it does not give the resize problem.
      I built the WMP.au3 around this concept and would like to share it with everybody.
      Attached is the WMP.au3 and the WMP_Example.au3 where it is used.

      Feedback is appreciated. This is my first UDF, so please be kind. 
      SudeepJD
      WMP_Example.au3
      WMP.au3
×
×
  • Create New...