Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

How to create a click button within a Gui window


  • Please log in to reply
6 replies to this topic

#1 djbinh

djbinh

    Seeker

  • Normal Members
  • 3 posts

Posted 31 January 2013 - 03:25 AM

Hi All,


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


#include <WinAPI.au3>
; http://www.autoitscript.com/forum/index.php?showtopic=62641&view=findpost&p=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)







#2 lorenkinzel

lorenkinzel

    Adventurer

  • Active Members
  • PipPip
  • 145 posts

Posted 31 January 2013 - 04:12 AM

#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("<a href='http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateButton.htm' class='bbc_url' title=''>http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateButton.htm"</a>) EndSwitch WEnd


#3 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 10,448 posts

Posted 31 January 2013 - 04:12 AM

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

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to an XP machine, and I'm not going to.

 

Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude

 

How to ask questions the smart way!

 

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.
Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.
_FileGetProperty - Retrieve the properties of a file SciTE Toolbar - A toolbar demo for use with the SciTE editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.
GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips. Latin Square password generator

 

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.


#4 djbinh

djbinh

    Seeker

  • Normal Members
  • 3 posts

Posted 01 February 2013 - 01:29 AM

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>
; http://www.autoitscript.com/forum/index.php?showtopic=62641&view=findpost&p=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)

#5 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 10,448 posts

Posted 01 February 2013 - 01:33 AM

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.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to an XP machine, and I'm not going to.

 

Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude

 

How to ask questions the smart way!

 

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.
Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.
_FileGetProperty - Retrieve the properties of a file SciTE Toolbar - A toolbar demo for use with the SciTE editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.
GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips. Latin Square password generator

 

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.


#6 djbinh

djbinh

    Seeker

  • Normal Members
  • 3 posts

Posted 01 February 2013 - 01:37 AM

Thanks for your help

#7 lorenkinzel

lorenkinzel

    Adventurer

  • Active Members
  • PipPip
  • 145 posts

Posted 01 February 2013 - 03:47 AM

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.
AutoIt         
#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)





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users