Jump to content

Ugly Gui - Needs some Expert Help!


 Share

Recommended Posts

I'm sorry about the topic of this but I have to say one of the big issues with "AutoIT" and I hope I'm totally wrong. Is that the buttons look like .......

On my gui it drives me crazy that the buttons are square. I would like to select a area and use that area as a button and it doesn't have that ugly grey box around it.

PLEASE PLEASE HELP !

Ugly Gui of Dell Remote

Link to comment
Share on other sites

Sounds like a WAY out not a solution.. AutoIT people are proud of..or look at and go damn that looks good...

What are you talking about? You said you didn't want the "button" to be visible, and that is done by using a LABEL.
Link to comment
Share on other sites

What are you talking about? You said you didn't want the "button" to be visible, and that is done by using a LABEL.

What I have done now is cropped a image of the button and overlayed that overtop of the orignal image the problem is that I just want the round Button not the SQUARE. or even beable to take that background image and select one of the areas and say thats the area for the button.

Link to comment
Share on other sites

If you don't like labels. Try pics.

#include <GDIPlus.au3>
#include <Array.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <ButtonConstants.au3>
#include <Winapi.au3>
#include<Misc.au3>
#include <Process.au3>
#include <StaticConstants.au3>
#include <GuiConstants.au3>
#include <Constants.au3>
#include <GuiMenu.au3>
Global $aFactors[4] = [0.0, 0.6, 0.8, 1.0], $aPositions[4] = [0.0, 0.6, 0.8, 1.0]
Global $bGammaCorrection = False

    Opt("GUIOnEventMode", 1); Change to OnEvent mode 
    Global $gw=400,$gh=400
    $taskbar=GUICreate("example", $gw, $gh,-1,-1,$WS_POPUP, $WS_EX_TOOLWINDOW);,$WS_EX_LAYERED)
         $a=GUICtrlCreatePic("",0,0)
        SetIcon($a,"", 0, 400, 400, $aFactors, $aPositions, "0x33CC66", "0x663399", 3,2,"Spruce up your Backgrounds",20,0)
$iPid = Run("notepad.exe")
Sleep(100); allow notepad to create window

                Global $a = _ProcessGetIcon("notepad.exe")
                GUISetIcon($a)
                $down =10

                Global $b=GUICtrlCreatePic("",10,10)
                SetIcon($b,$a, 0, 80, 40, $aFactors, $aPositions, "0x444444", "0x999999", 2,2)
                Global $c=GUICtrlCreatePic("",10,60)
                SetIcon($c,$a, 0, 80, 40, $aFactors, $aPositions, "0xFFFF33", "0x3333FF", 1,2,"Under",12,0)
                Global $d=GUICtrlCreatePic("",10,110)
                SetIcon($d,$a, 0, 80, 40, $aFactors, $aPositions, "0x33FF99", "0xFF0033", 0,2,"Over",14,1)


                    GUISetState()
While 1


$hover=GUIGetCursorInfo(WinGetHandle("example",""))

if _IsPressed("01","user32.dll") and $hover[4]=$b then
SetIcon($b,$a, 0, 80, 40, $aFactors, $aPositions, "0x444444", "0x999999", 1,0)
_WinAPI_RedrawWindow(GUICtrlGetHandle($b))
sleep(400)
SetIcon($b,$a, 0, 80, 40, $aFactors, $aPositions, "0x444444", "0x999999", 2,2)
_WinAPI_RedrawWindow(GUICtrlGetHandle($b))
Elseif _IsPressed("01","user32.dll") and $hover[4]=$c then
SetIcon($c,$a, 0, 80, 40, $aFactors, $aPositions, "0x3333FF", "0xFFFF33", 1,0,"Under",12,0)
_WinAPI_RedrawWindow(GUICtrlGetHandle($c))
sleep(400)
SetIcon($c,$a, 0, 80, 40, $aFactors, $aPositions, "0xFFFF33", "0x3333FF", 1,2,"Under",12,0)
_WinAPI_RedrawWindow(GUICtrlGetHandle($c))
Elseif _IsPressed("01","user32.dll") and $hover[4]=$d then
SetIcon($d,$a, 0, 80, 40, $aFactors, $aPositions, "0xFF0033", "0x33FF99", 0,0,"Over",14,1)
_WinAPI_RedrawWindow(GUICtrlGetHandle($d))
sleep(400)
SetIcon($d,$a, 0, 80, 40, $aFactors, $aPositions, "0x33FF99", "0xFF0033", 0,2,"Over",14,1)
_WinAPI_RedrawWindow(GUICtrlGetHandle($d))
EndIf
sleep(100)
WEnd
        
Func FillArray($sData)
    Local $aDataSplit
    $aDataSplit = StringSplit(StringStripWS($sData, 8), ",")
    If $aDataSplit[0] < 2 Then
        MsgBox(0, "Error", "Must have at lease two (2) entries in input box", 2)
        Return 1
    Else
        Local $aRetArray[$aDataSplit[0]]
        For $x = 0 To UBound($aRetArray) - 1
            $aRetArray[$x] = $aDataSplit[$x + 1]
        Next
        Return $aRetArray
    EndIf
EndFunc ;==>FillArray

Func SetColor($iD)
    Local $Clr
    $Clr = _ChooseColor(2, 0, 2, $hGui)
    If $Clr <> -1 Then
        $iColor[$iD] = $Clr
        If $iD Then
            GUICtrlSetColor($Label[$iD], $iColor[0])
            GUICtrlSetColor($Label[0], $iColor[1])
        Else
            GUICtrlSetColor($Label[$iD], $iColor[1])
            GUICtrlSetColor($Label[1], $iColor[0])
        EndIf
        GUICtrlSetData($Label[$iD], $iColor[$iD])
        GUICtrlSetBkColor($Label[$iD], $iColor[$iD])
        Return 1
    EndIf
    Return 0
EndFunc ;==>SetColor

Func PicSetGradient($cID, $iW, $iH, $aFactors, $aPositions, $iClr1, $iClr2, $iDirection)
    Local Const $STM_SETIMAGE = 0x0172
    Local Const $IMAGE_BITMAP = 0
    Local $hWnd, $iC1, $iC2, $hBitmap, $hImage, $hGraphic, $hBrushLin, $hbmp, $aBmp
    $hWnd = GUICtrlGetHandle($cID)
    $iC1 = StringReplace($iClr1, "0x", "0xFF")
    $iC2 = StringReplace($iClr2, "0x", "0xFF")
    $hBitmap = _WinAPI_CreateBitmap($iW, $iH, 1, 32)
    _GDIPlus_Startup()
    $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage)
    $hBrushLin = _GDIPlus_CreateLineBrushFromRect(0, 0, $iW, $iH, $aFactors, $aPositions, $iC1, $iC2, $iDirection)
    GDIPlus_SetLineGammaCorrection($hBrushLin, $bGammaCorrection)
    _GDIPlus_GraphicsFillRect($hGraphic, 0, 0, $iW, $iH, $hBrushLin)
    $hbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $aBmp = DllCall("user32.dll", "hwnd", "SendMessage", "hwnd", $hWnd, "int", $STM_SETIMAGE, "int", $IMAGE_BITMAP, "int", $hbmp)
    If $aBmp[0] <> 0 Then _WinAPI_DeleteObject($aBmp[0])
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_BrushDispose($hBrushLin)
    _GDIPlus_GraphicsDispose($hGraphic)
    _WinAPI_DeleteObject($hbmp)
    _WinAPI_DeleteObject($hBitmap)
    _GDIPlus_Shutdown()

EndFunc ;==>PicSetGradient
func SetIcon($controlID, $sIcon, $iIndex, $iWidth, $iHeight, $aFactors, $aPositions, $iClr1="0x111111", $iClr2="0x999999", $iDirection=2, $pressed=2,$string="", $fontsize="12", $over="1")
    const $STM_SETIMAGE = 0x0172
    local $tIcon, $tID, $hDC, $hBackDC, $hBackSv, $hBitmap, $hImage, $hIcon, $hBkIcon
   Local $w=$iWidth-32, $h=$iHeight-32
    $tIcon = DllStructCreate('hwnd')
    $tID = DllStructCreate('hwnd')

     _GDIPlus_Startup()
    Local Const $IMAGE_BITMAP = 0
    Local $hWnd, $iC1, $iC2, $hBitmap, $hImage, $hGraphic, $hBrushLin, $hbmp, $aBmp
    $hWnd = GUICtrlGetHandle($controlID)
    $iC1 = StringReplace($iClr1, "0x", "0xFF")
    $iC2 = StringReplace($iClr2, "0x", "0xFF")
    $hBitmap = _WinAPI_CreateBitmap($iWidth+$pressed, $iHeight+$pressed, 1, 32)
    $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage)
    $hBrushLin = _GDIPlus_CreateLineBrushFromRect(0, 0, $iWidth, $iHeight, $aFactors, $aPositions, $iC1, $iC2, $iDirection)
    GDIPlus_SetLineGammaCorrection($hBrushLin, $bGammaCorrection)
    _GDIPlus_GraphicsFillRect($hGraphic, 0, 0, $iWidth, $iHeight, $hBrushLin)
    if $over=0 and not $string="" then
        _GDIPlus_GraphicsDrawString($hGraphic,$string,2, $h/2,"arial",$fontsize)
    EndIf
    $hbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
 
if not $sIcon="" Then
       $hIcon = DllCall('user32.dll', 'int', 'PrivateExtractIcons', 'str', $sIcon, 'int', $iIndex, 'int', 32, 'int', 32, 'ptr', DllStructGetPtr($tIcon), 'ptr', DllStructGetPtr($tID), 'int', 1, 'int', 0)
    if (@error) or ($hIcon[0] = 0) then
        return SetError(1, 0, 0)
    endif
    $hIcon = DllStructGetData($tIcon, 1)
    $tIcon = 0
    $tID = 0

    $hDC = _WinAPI_GetDC(0)
    $hBackDC = _WinAPI_CreateCompatibleDC($hDC)
  ;$hBitmap = _WinAPI_CreateSolidBitmap(0, $iBackground, $iWidth, $iHeight)
    $hBackSv = _WinAPI_SelectObject($hBackDC, $hbmp)
   If $hIcon <> 0 Then _WinAPI_DrawIconEx($hBackDC, $w/2, $h/2, $hIcon, 0, 0, 0, 0, $DI_NORMAL)
EndIf
   if $over=1 and not $string="" then
        $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hbmp)
        Local $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage)
        _GDIPlus_GraphicsDrawString($hGraphic,$string,2, $h/2,"arial",$fontsize)
        $hbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
        _GDIPlus_GraphicsDispose    ($hGraphic)
    EndIf
     $aBmp = DllCall("user32.dll", "hwnd", "SendMessage", "hwnd", $hWnd, "int", $STM_SETIMAGE, "int", $IMAGE_BITMAP, "int", $hbmp)
    If $aBmp[0] <> 0 Then _WinAPI_DeleteObject($aBmp[0])
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_BrushDispose($hBrushLin)
    _GDIPlus_GraphicsDispose($hGraphic)
;   _WinAPI_DeleteObject($hbmp)

    _GDIPlus_Shutdown()
_WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteObject($hIcon)

if $sIcon="" Then Return SetError(0, 0, 1)
 _WinAPI_SelectObject($hBackDC, $hBackSv)
    _WinAPI_DeleteDC($hBackDC)
    _WinAPI_ReleaseDC(0, $hDC)

    return SetError(0, 0, 1)
endfunc; SetIcon
Func _Quit()
    Exit
EndFunc ;==>_Quit

;==== GDIPlus_CreateLineBrushFromRect === Malkey's function
;Description - Creates a LinearGradientBrush object from a set of boundary points and boundary colors.
; $aFactors - If non-array, default array will be used.
;          Pointer to an array of real numbers that specify blend factors. Each number in the array
;          specifies a percentage of the ending color and should be in the range from 0.0 through 1.0.
;$aPositions - If non-array, default array will be used.
;           Pointer to an array of real numbers that specify blend factors' positions. Each number in the array
;           indicates a percentage of the distance between the starting boundary and the ending boundary
;           and is in the range from 0.0 through 1.0, where 0.0 indicates the starting boundary of the
;           gradient and 1.0 indicates the ending boundary. There must be at least two positions
;           specified: the first position, which is always 0.0, and the last position, which is always
;           1.0. Otherwise, the behavior is undefined. A blend position between 0.0 and 1.0 indicates a
;           line, parallel to the boundary lines, that is a certain fraction of the distance from the
;           starting boundary to the ending boundary. For example, a blend position of 0.7 indicates
;           the line that is 70 percent of the distance from the starting boundary to the ending boundary.
;           The color is constant on lines that are parallel to the boundary lines.
; $iArgb1   - First Top color in 0xAARRGGBB format
; $iArgb2   - Second color in 0xAARRGGBB format
; $LinearGradientMode -  LinearGradientModeHorizontal      = 0x00000000,
;                       LinearGradientModeVertical       = 0x00000001,
;                       LinearGradientModeForwardDiagonal  = 0x00000002,
;                       LinearGradientModeBackwardDiagonal = 0x00000003
; $WrapMode  - WrapModeTile    = 0,
;             WrapModeTileFlipX  = 1,
;             WrapModeTileFlipY  = 2,
;             WrapModeTileFlipXY = 3,
;             WrapModeClamp   = 4
; GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect, ARGB color1, ARGB color2,
;            LinearGradientMode mode, GpWrapMode wrapMode, GpLineGradient **lineGradient)
; Reference:  http://msdn.microsoft.com/en-us/library/ms534043(VS.85).aspx
;
Func _GDIPlus_CreateLineBrushFromRect($iX, $iY, $iWidth, $iHeight, $aFactors, $aPositions, _
        $iArgb1 = 0xFF0000FF, $iArgb2 = 0xFFFF0000, $LinearGradientMode = 0x00000001, $WrapMode = 0)

    Local $tRect, $pRect, $aRet, $tFactors, $pFactors, $tPositions, $pPositions, $iCount

    If $iArgb1 = Default Then $iArgb1 = 0xFF0000FF
    If $iArgb2 = Default Then $iArgb2 = 0xFFFF0000
    If $LinearGradientMode = -1 Or $LinearGradientMode = Default Then $LinearGradientMode = 0x00000001
    If $WrapMode = -1 Or $LinearGradientMode = Default Then $WrapMode = 1

    $tRect = DllStructCreate("float X;float Y;float Width;float Height")
    $pRect = DllStructGetPtr($tRect)
    DllStructSetData($tRect, "X", $iX)
    DllStructSetData($tRect, "Y", $iY)
    DllStructSetData($tRect, "Width", $iWidth)
    DllStructSetData($tRect, "Height", $iHeight)

  ;Note: Withn _GDIPlus_Startup(), $ghGDIPDll is defined
    $aRet = DllCall($ghGDIPDll, "int", "GdipCreateLineBrushFromRect", "ptr", $pRect, "int", $iArgb1, _
            "int", $iArgb2, "int", $LinearGradientMode, "int", $WrapMode, "int*", 0)

    If IsArray($aFactors) = 0 Then Dim $aFactors[4] = [0.0, 0.4, 0.6, 1.0]
    If IsArray($aPositions) = 0 Then Dim $aPositions[4] = [0.0, 0.3, 0.7, 1.0]

    $iCount = UBound($aPositions)
    $tFactors = DllStructCreate("float[" & $iCount & "]")
    $pFactors = DllStructGetPtr($tFactors)
    For $iI = 0 To $iCount - 1
        DllStructSetData($tFactors, 1, $aFactors[$iI], $iI + 1)
    Next
    $tPositions = DllStructCreate("float[" & $iCount & "]")
    $pPositions = DllStructGetPtr($tPositions)
    For $iI = 0 To $iCount - 1
        DllStructSetData($tPositions, 1, $aPositions[$iI], $iI + 1)
    Next

    $hStatus = DllCall($ghGDIPDll, "int", "GdipSetLineBlend", "hwnd", $aRet[6], _
            "ptr", $pFactors, "ptr", $pPositions, "int", $iCount)
    Return $aRet[6]; Handle of Line Brush
EndFunc ;==>_GDIPlus_CreateLineBrushFromRect

;===========================================================
; Description:  Specifies whether gamma correction is enabled for this linear gradient brush.
; Parameters
; $hBrush            - [in] Pointer to the LinearGradientBrush object.
; $useGammaCorrection - [in] Boolean value that specifies whether gamma correction occurs
;                    during rendering. TRUE specifies that gamma correction is enabled,
;                    and FALSE specifies that gamma correction is not enabled. By default,
;                    gamma correction is disabled during construction of a
;                    LinearGradientBrush object.
;GdipSetLineGammaCorrection(GpLineGradient *brush, BOOL useGammaCorrection)
;
Func GDIPlus_SetLineGammaCorrection($hBrush, $useGammaCorrection = True)
    Local $aResult  
    $aResult = DllCall($ghGDIPDll, "int", "GdipSetLineGammaCorrection", "hwnd", $hBrush, "int", $useGammaCorrection)
    Return $aResult[0]
EndFunc ;==>GDIPlus_SetLineGammaCorrection

Func _ProcessGetIcon($vProcess)
    Local $iPID = ProcessExists($vProcess)
    If Not $iPID Then Return SetError(1, 0, -1)
    Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID)
    If Not IsArray($aProc) Or Not $aProc[0] Then Return SetError(2, 0, -1)
    Local $vStruct = DllStructCreate('int[1024]')
    Local $hPsapi_Dll = DllOpen('Psapi.dll')
    If $hPsapi_Dll = -1 Then $hPsapi_Dll = DllOpen(@SystemDir & '\Psapi.dll')
    If $hPsapi_Dll = -1 Then $hPsapi_Dll = DllOpen(@WindowsDir & '\Psapi.dll')
    If $hPsapi_Dll = -1 Then Return SetError(3, 0, '')
    DllCall($hPsapi_Dll, 'int', 'EnumProcessModules', _
    'hwnd', $aProc[0], _
    'ptr', DllStructGetPtr($vStruct), _
    'int', DllStructGetSize($vStruct), _
    'int_ptr', 0)
    Local $aRet = DllCall($hPsapi_Dll, 'int', 'GetModuleFileNameEx', _
    'hwnd', $aProc[0], _
    'int', DllStructGetData($vStruct, 1), _
    'str', '', _
    'int', 2048)
    DllClose($hPsapi_Dll)
    If Not IsArray($aRet) Or StringLen($aRet[3]) = 0 Then Return SetError(4, 0, '')
    Return $aRet[3]
EndFunc

Func processgetstate($process)
        For $i = 1 To $winlistall[0][0]
                If $process = $winlistall[$i][0] and WinActive($winlistall[$i][2]) Then return 1
        Next
    Return 0
EndFunc
Link to comment
Share on other sites

This is ARTeam tutorial for making a nice bitmap-based GUI window. Maybe it'll be cooler than the boring traditional GUI windows you used to see:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt('GUICloseOnESC', 0)
Global Const $WM_LBUTTONDOWN = 0x0201

GUIRegisterMsg($WM_LBUTTONDOWN, '_WM_LBUTTONDOWN')

$hGUI = GUICreate("", 398, 177, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
$Pic = GUICtrlCreatePic(@ScriptDir & "\Bitmap.bmp", 0, 0, 398, 177, $WS_CLIPSIBLINGS)
$Btn_About = GUICtrlCreateButton("", 48, 136, 73, 17, BitOR($WS_CLIPSIBLINGS, $BS_FLAT))
$Btn_Copy = GUICtrlCreateButton("", 184, 136, 57, 17, BitOR($WS_CLIPSIBLINGS, $BS_FLAT))
$Btn_Exit = GUICtrlCreateButton("", 304, 136, 57, 17, BitOR($WS_CLIPSIBLINGS, $BS_FLAT))

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $Btn_About
            MsgBox(0x42040, 'About', 'About')
        Case $Btn_Copy
            MsgBox(0x42030, 'Copy', 'Copy')
        Case $Btn_Exit
            ExitLoop
    EndSwitch
WEnd

GUIDelete()
Exit

Func _WM_LBUTTONDOWN($hWnd, $iMsg, $iwParam, $ilParam)
    _SendMessage($hWnd, $WM_NCLBUTTONDOWN, $HTCAPTION, $ilParam)
EndFunc
Link to comment
Share on other sites

I'm sorry about the topic of this but I have to say one of the big issues with "AutoIT" and I hope I'm totally wrong. Is that the buttons look like .......

On my gui it drives me crazy that the buttons are square. I would like to select a area and use that area as a button and it doesn't have that ugly grey box around it.

PLEASE PLEASE HELP !

Ugly Gui of Dell Remote

If you just want to select an area, then look at the examples @

http://www.autoitscript.com/forum/index.ph...st&p=639786

Here is an example of the method used at that link.

;
 #include <guiconstantsex.au3>
; Example of dividing up a GUI into clickable areas
; requires Opt("MouseCoordMode", 2)
; Modified from  http://www.autoitscript.com/forum/index.php?s=&showtopic=89034&view=findpost&p=640845
 Opt("MouseCoordMode", 2);1=absolute, 0=relative, 2=client
 
 Example()
 
 Func Example()
    Local $msg, $aPos
 
    GUICreate("My GUI", 100, 300)
    GUISetState()
 
    While 1
        $msg = GUIGetMsg()
        Switch $msg
            Case - 3; $GUI_EVENT_CLOSE from #include <guiconstantsex.au3>
                ExitLoop
            Case $GUI_EVENT_PRIMARYUP
                $aPos = MouseGetPos()
                Select
                    Case _WinAPI_PtInRectEx($aPos[0], $aPos[1], 0, 0, 100, 100)
                        MsgBox(0, "", "Top")
                    Case _WinAPI_PtInRectEx($aPos[0], $aPos[1], 0, 100, 100, 100)
                        MsgBox(0, "", "Middle")
                    Case _WinAPI_PtInRectEx($aPos[0], $aPos[1], 0, 200, 100, 100)
                        MsgBox(0, "", "Bottom")
                EndSelect
        EndSwitch
    WEnd
 EndFunc  ;==>Example
 
 
; Note this_WinAPI_PtInRectEx() Not the same as 1st post.
; Here Width & height used, NOT Botton right corner position.
; Also, declared $tagREC.
; $tagRECT required WinAPI.au3 to be included.
 Func _WinAPI_PtInRectEx($iX, $iY, $iLeft, $iTop, $iWidth, $iHeight)
    Local $aResult, $tagREC = "int Left;int Top;int Right;int Bottom"
    Local $tRect = DllStructCreate($tagREC)
    DllStructSetData($tRect, "Left", $iLeft)
    DllStructSetData($tRect, "Top", $iTop)
    DllStructSetData($tRect, "Right", $iLeft + $iWidth)
    DllStructSetData($tRect, "Bottom", $iTop + $iHeight)
    $aResult = DllCall("User32.dll", "int", "PtInRect", "ptr", DllStructGetPtr($tRect), "int", $iX, "int", $iY)
    If @error Then Return SetError(@error, 0, False)
    Return $aResult[0] <> 0
 EndFunc  ;==>_WinAPI_PtInRectEx
;
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...