Sign in to follow this  
Followers 0

How to create a click button within a Gui window

7 posts in this topic

Posted

Hi All,

im really new with Autoit, I want to know how to create a click button within a gui windows

#include <WinAPI.au3>

; #469512

Global Const $COLOR_ACTIVECAPTION = 2

Global Const $COLOR_GRADIENTACTIVECAPTION = 27

Local $aElements[2] = [$COLOR_ACTIVECAPTION, $COLOR_GRADIENTACTIVECAPTION]

; Red and Yellow

Local $aColors[3] = [255, 65535], $aSaveColors[2]

GUICreate("Supagas ", 1000, 800)

$aSaveColors[0] = _WinAPI_GetSysColor($COLOR_ACTIVECAPTION)

$aSaveColors[1] = _WinAPI_GetSysColor($COLOR_GRADIENTACTIVECAPTION)

_WinAPI_SetSysColors($aElements, $aColors)

GUISetState()

While 1

$Msg = GUIGetMsg()

Switch $Msg

Case -3 ; $GUI_EVENT_CLOSE

ExitLoop

EndSwitch

WEnd

_WinAPI_SetSysColors($aElements, $aSaveColors)

Share this post


Link to post
Share on other sites



Posted

#include <ButtonConstants.au3>
#include <GUIConstantSex.au3>
#include <WindowsConstants.au3>

$theGUI = GUICreate("formWithButton", 293, 220, 192, 124)
$button1 = GUICtrlCreateButton("A button", 40, 32, 209, 121)
GUISetState(@SW_SHOW)


While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $button1
ShellExecute("http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateButton.htm")

EndSwitch
WEnd

Share this post


Link to post
Share on other sites

Posted

Look up GUICtrlCreateButton in the help file and study the example shown in there.

Share this post


Link to post
Share on other sites

Posted

Hi Guys

what im trying to do is to make a gui window with Button to action a .exe Error message

( Case $msg = $GUI_EVENT_CLOSE)

(Case $msg = ^ ERROR)

#include <WinAPI.au3>

; #469512

Global Const $COLOR_ACTIVECAPTION = 2

Global Const $COLOR_GRADIENTACTIVECAPTION = 27

Local $aElements[2] = [$COLOR_ACTIVECAPTION, $COLOR_GRADIENTACTIVECAPTION]

; Red and Yellow

Local $aColors[3] = [255, 65535], $aSaveColors[2]

GUICreate("Supagas ", 1000, 800)

$aSaveColors[0] = _WinAPI_GetSysColor($COLOR_ACTIVECAPTION)

$aSaveColors[1] = _WinAPI_GetSysColor($COLOR_GRADIENTACTIVECAPTION)

$button1 = GUICtrlCreateButton("Adobe", 40, 32, 209, 121)

$button2 = GUICtrlCreateButton("Signature Reset", 400, 32, 209, 121)

$button3 = GUICtrlCreateButton("Install Printers", 700, 32, 209, 121)

$button4 = GUICtrlCreateButton("CO2", 40, 241, 209, 121)

_WinAPI_SetSysColors($aElements, $aColors)

GUISetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $Button_1

Run('notepad.exe') ; Will Run/Open Notepad

EndSelect

WEnd

_WinAPI_SetSysColors($aElements, $aSaveColors)

Share this post


Link to post
Share on other sites

Posted

Maybe you should reference the post you keep linking to, there's a GUI and a Button in there. Then, open the help file, read what each of the commands do, and learn something. Because copying code and hoping to get it to work for you isn't working for your knowledge level in the language.

Share this post


Link to post
Share on other sites

Posted

Thanks for your help

Share this post


Link to post
Share on other sites

Posted

A little bit of spoonfeeding to get you over that first hump...........

The 1 button works & should show you how to get the others going.

It's a bitch at first. I know being self-taught that the teacher is as stupid as me.

BrewManNHs' advice is the best you can get.... study the help file.

#include <WindowsConstants.au3>;'fixIncludes.au3' decided We needed this one.
#include <GUIConstantsEx.au3>; ditto
#include <WinAPI.au3>


;Global Const $COLOR_ACTIVECAPTION = 2>>>>>>>>>Shown as pre-declared at syntax check (tools from Scite toolbar), so I commented it out. This happens alot if you copy older scripts
;Global Const $COLOR_GRADIENTACTIVECAPTION = 27>>>>>>>>>>>ditto
Local $aElements[2] = [$COLOR_ACTIVECAPTION, $COLOR_GRADIENTACTIVECAPTION]
; Red and Yellow
Local $aColors[3] = [255, 65535], $aSaveColors[2]

GUICreate("Supagas ", 1000, 800)
$aSaveColors[0] = _WinAPI_GetSysColor($COLOR_ACTIVECAPTION)
$aSaveColors[1] = _WinAPI_GetSysColor($COLOR_GRADIENTACTIVECAPTION)


$button1 = GUICtrlCreateButton("Adobe", 40, 32, 209, 121); highlite 'GUICtrlCreateButton' while in Scite & press F1.
;An example is given that gives the necessary '#includes' without needing 'fixIncludes.au3'....but get it anyway. It is very handy for those like us (beginners)
$button2 = GUICtrlCreateButton("Signature Reset", 400, 32, 209, 121)
$button3 = GUICtrlCreateButton("Install Printers", 700, 32, 209, 121)
$button4 = GUICtrlCreateButton("CO2", 40, 241, 209, 121)


_WinAPI_SetSysColors($aElements, $aColors);I can't do anything for you here. Lack of knowledge.

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button1; notice it is no longer $Button_1 (from your scrip). Now it matches the declared variable---$button1
Run('notepad.exe') ; Will Run/Open Notepad

EndSelect

WEnd

_WinAPI_SetSysColors($aElements, $aSaveColors)

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  
Followers 0