Jump to content

How would i make a round GUI that is also a button


Guest
 Share

Recommended Posts

Hello everybody,

 

I am working on a project that will allow me to run a macro on another non focused window (say notepad-the ultimate example)

So far I have found the control functions that would let me do this. However I am a bit stumped on how to make the GUI.

What i would like to do is to make a round button( like thisimage.png.ef69c148cfdfc0e9dbd4bdd6d241aa37.png) that on a click would open a drop down menu with many functions in it.

I'm confident I could figure out the drop down menu but I can not figure out how to make the round button.

 

I have scavenged the forum looking for answers but to no avail. I have downloaded ezskin and xskin but have not been able to figure those out.

 

Any help that you can give would be greatly appreciated,

Lewiaa

Link to comment
Share on other sites

2 hours ago, lewiaa said:

I have scavenged the forum looking for answers but to no avail. I have downloaded ezskin and xskin but have not been able to figure those out. Any help that you can give would be greatly appreciated,

Maybe this old code snippet I found will help you somehow 🤔 :

; https://www.autoitscript.com/forum/topic/27260-round-gui-picture-gui/?do=findComment&comment=193006
; https://www.autoitscript.com/forum/topic/27260-round-gui-picture-gui/

#include <GUIConstants.au3>
$Form1 = GUICreate("AForm1", 100, 100, -1, -1, BitOR($WS_SYSMENU,$WS_POPUPWINDOW,$WS_BORDER), 0)
_GuiRoundCorners($Form1, 0, 0, 100, 100)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
    ;;;;;;;
    EndSelect
WEnd
Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3)
   Dim $pos, $ret, $ret2
   $pos = WinGetPos($h_win)
    $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long",  $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3,  "long", $i_y3)
   If $ret[0] Then
      $ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1)
      If $ret2[0] Then
         Return 1
      Else
         Return 0
      EndIf
   Else
      Return 0
   EndIf
EndFunc;==>_GuiRoundCorners

Check out the following link as well :

https://www.autoitscript.com/forum/topic/194880-smoothing-rounded-corners-gui/

Probably not the solution you're looking for, but at least a start :lol:.

Edited by Musashi

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

Hi all,

Funkey's script based on a child gui gives great results too. I just reworked it a bit to get 2 round clickable controls :

#include <ColorConstants.au3>
#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$hGui = GUICreate("Main Form", 300, 150)
$idGraphic1 = _GuiCtrlCreateRoundedLabel($hGui, "OK", 60, 40 , 60, 60, _
    $COLOR_WHITE, $COLOR_GREEN)
$idGraphic2 = _GuiCtrlCreateRoundedLabel($hGui, "Cancel", 180, 40 , 60, 60, _
    $COLOR_WHITE, $COLOR_RED)
GUISetState(@SW_SHOW, $hGui)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $idGraphic1
            MsgBox($MB_TOPMOST,"", "OK clicked")
        Case $idGraphic2
            MsgBox($MB_TOPMOST,"", "Cancel clicked")
    EndSwitch
WEnd

Func _GuiCtrlCreateRoundedLabel($hParent, $sText, $iX, $iY, $iW, $iH, $iClr, $iBkClr)
    Local $hChild = GUICreate($sText, $iW, $iH, $iX, $iY, $WS_CHILD, 0, $hParent)
    GUISetBkColor($iBkClr)
    _Gui_RoundCorners($hChild, 0, 0, $iW - 1, $iH - 1)
    GUICtrlCreateGraphic(0, 0, $iW, $iH, 0)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $iBkClr)
    GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, 0, $iW - 1, $iH - 1) ; $iW = $iH => circle
    Local $nLabel = GUICtrlCreateLabel($sText, 0, 0, $iW, $iH, _
        BitOr($SS_CENTERIMAGE, $SS_CENTER))
    GUICtrlSetColor(-1, $iClr)
    GUICtrlSetFont(-1, Default, $FW_BOLD)
    GUISetState(@SW_SHOW, $hChild)
    Return $nLabel
EndFunc   ;==>_GuiCtrlCreateRoundedLabel

Func _Gui_RoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3)
    Local $XS_pos, $XS_ret, $XS_ret2
    $XS_pos = WinGetPos($h_win)
    $XS_ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", _
        $i_y1, "long", $XS_pos[2], "long", $XS_pos[3], "long", $i_x3, "long", $i_y3)
    If $XS_ret[0] Then
        $XS_ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", _
        $XS_ret[0], "int", 1)
    EndIf
EndFunc   ;==>_Gui_RoundCorners

907.png.d9ddadbebfbbe68b8741e5e419f00340.png

Great job Funkey :)

Link to comment
Share on other sites

Or you may want to have it with transparency  ?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGui = GUICreate("", 400, 400,-1,-1,$WS_POPUP, $WS_EX_LAYERED)
    Local $hPic = GUICreate("", 150, 100, 10, 10, $WS_POPUP, $WS_EX_LAYERED+$WS_EX_MDICHILD, $hGui)
    GUICtrlCreatePic("Arrow.jpg", 0, 0, 150, 100,-1,$GUI_WS_EX_PARENTDRAG)

    GUISetState(@SW_SHOW, $hPic)
    GUISetState(@SW_SHOW, $hGui)

    HotKeySet("{ESC}", "_Exit")

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
      Case $GUI_EVENT_SECONDARYDOWN
        ConsoleWrite ("right click" & @CRLF)
        EndSwitch
    WEnd

EndFunc   ;==>Example

Func _Exit ()
    Exit
EndFunc

Use this picture to get better result.

It is intended to be dragable and with right click you could have a contextual popup menu...

Arrow.jpg

Edited by Nine
Link to comment
Share on other sites

This is great everyone thanks for all the help.

I guess I didn't scavenge the forums enough.

Everything seemed to work so this is all going to be a great help.

Also @Nine

the "Arrow.jpg", when i try to open it, gives a 404 not found.

 

Thanks for all the help everyone.

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...