Jump to content
Sign in to follow this  
JuanFelipe

GUICtrlCreateButton

Recommended Posts

JuanFelipe

Hi friends, I need help with the process, I have a button to initiate a code but do not know how to configure it to be the button to start the process, thank you very much for your help.

Here I leave the code to see if I have to change some part.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\users\juan.caballeron\desktop\ \programacion\autoit\capturas\koda_1.7.3.0\forms\grabar capturas.kxf
$Form1_1 = GUICreate("WhiteSnake", 655, 487, 192, 124)
GUISetIcon("C:\Users\juan.caballeron\Desktop\ \Programacion\Autoit\Capturas\koda_1.7.3.0\iconos\Avatar on ice-256.ico", -1)
GUISetBkColor(0xC8C8C8)
$hechos = GUICtrlCreateGroup("Hechos", 16, 32, 385, 169)
GUICtrlSetColor(-1, 0x000000)
$box_fechah = GUICtrlCreateInput("", 112, 72, 81, 21)
GUICtrlSetLimit(-1, 10)
$box_hora = GUICtrlCreateInput("", 112, 104, 81, 21)
GUICtrlSetLimit(-1, 5)
$box_fechaf = GUICtrlCreateInput("", 112, 136, 81, 21)
GUICtrlSetLimit(-1, 10)
$box_fte = GUICtrlCreateInput("", 112, 168, 81, 21)
GUICtrlSetLimit(-1, 5)
$Label3 = GUICtrlCreateLabel("Fecha Hecho:", 24, 72, 72, 17)
$Label4 = GUICtrlCreateLabel("Hora:", 24, 104, 30, 17)
$Label5 = GUICtrlCreateLabel("Fecha Fuente:", 24, 136, 73, 17)
$Label6 = GUICtrlCreateLabel("Nro. Fuente:", 24, 168, 63, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$personas = GUICtrlCreateGroup("Datos de la Persona", 16, 224, 585, 185)
$Label1 = GUICtrlCreateLabel("Tipo Identificación:", 32, 256, 94, 17)
$Label2 = GUICtrlCreateLabel("No. Documento:", 32, 280, 82, 17)
$Label7 = GUICtrlCreateLabel("Apellidos", 32, 304, 46, 17)
$Label8 = GUICtrlCreateLabel("Nombres", 32, 328, 46, 17)
$Label9 = GUICtrlCreateLabel("Sexo", 32, 352, 28, 17)
$Label10 = GUICtrlCreateLabel("Fecha Nacimiento", 32, 376, 90, 17)
$Combo1 = GUICtrlCreateCombo("Selección", 128, 256, 193, 21)
$Combo1 = GUICtrlSetData(-1, "Tarjeta de Identidad|Cédula")
GUICtrlSetLimit(-1, 1)
$documento = GUICtrlCreateInput("", 128, 280, 193, 21)
$apellidos = GUICtrlCreateInput("", 128, 304, 377, 21)
$nombres = GUICtrlCreateInput("", 128, 328, 377, 21)
$Combo2 = GUICtrlCreateCombo("Selección", 128, 352, 121, 21)
$Combo2 = GUICtrlSetData(-1, "Masculino|Femenino")
GUICtrlSetLimit(-1, 1)
$fecha_naci = GUICtrlCreateInput("", 128, 376, 121, 21)
GUICtrlSetLimit(-1, 10)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$datoscap = GUICtrlCreateGroup("Datos Capturas", 456, 32, 145, 169)
$Label11 = GUICtrlCreateLabel("Label11", 472, 56, 42, 17)
$Label12 = GUICtrlCreateLabel("Label12", 472, 80, 42, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Titulo = GUICtrlCreateLabel("PROCESO PARA GRABAR CAPTURAS EN EL SIEDCO.", 175, 8, 277, 17, $SS_CENTER)
GUICtrlSetCursor (-1, 3)
$Progress1 = GUICtrlCreateProgress(448, 432, 169, 9)
GUICtrlSetCursor (-1, 15)
$creador = GUICtrlCreateLabel("By WhiteSnake", 8, 440, 78, 17)
GUICtrlSetColor(-1, 0xFF0000)
$Icon1 = GUICtrlCreateIcon("C:\Users\juan.caballeron\Desktop\ \Programacion\Autoit\Capturas\koda_1.7.3.0\iconos\1249549841170809086.ico", -1, 88, 432, 32, 32)
$iniciar = GUICtrlCreateButton("INICIAR PROCESO", 296, 424, 145, 25)
GUICtrlSetCursor (-1, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
 WEnd

 

I just need to know how to do that when you click the $iniciar start any process.

Edited by Jos
Put script in Codebox. Please use that the next time you post code.

Share this post


Link to post
Share on other sites
BrewManNH
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case  $iniciar
            ;  Put what ever you want to do after pushing the button here
    EndSwitch
 WEnd

 

  • Like 1

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 XP, 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!

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.

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 editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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  

  • Similar Content

    • Pike
      By Pike
      Hello Everyone,
      New Guy here. This is a two-part question, hopefully easy enough though. I know it's ugly coding, this is because I have only a couple hours worth of coding experience and could really use some help.
      1) When I single click the button I want one action (like playing a sound clip) and when I double click the button I want a different action (such as opening dialogue box to ask for soundclip directory address). At the bottom of the script I made a comment which one I would like single click versus double click.
      2) I can not get the FileOpenDialogue to save the file address to the config.ini file at the 'One' position on the .ini.
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <FileConstants.au3> #include <AutoItConstants.au3> #include <Sound.au3> Opt('MustDeclareVars', 1) Opt("GUIOnEventMode", 1) Global $OneID _Main() Func _Main() GUICreate("Form1", 156, 86, 281, 276) $OneID = GUICtrlCreateButton("Button", 15, 17, 122, 37) GUICtrlSetOnEvent($OneID, "OnOne") GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit") GUISetState() While 1 While 1 Sleep(1000) WEnd WEnd EndFunc ;---------------Functions------------- While 1 Sleep(100) WEnd Func OnOne() ; ******************Single Click for this action**************** $OneID = IniRead("config.ini", "Config", "One", $OneID) If $OneID = True Then SoundPlay($OneID, @HotKeyPressed) Else ; *******Double Click for this action*****And Help Saving File Address to config.ini 'One'*********** $OneID = FileOpenDialog("Select file", @WorkingDir, "All (*.*)") IniWrite("config.ini", "Config", "One", $OneID) $OneID = InputBox("Enter Information", "Short Name for File?", "") IniWrite("config.ini", "Config", "NameOne", $OneID) EndIf EndFunc Any help would be greatly appreciated, and if you need anymore clarity as to what exactly I'm trying to do, please do not hesitate to ask. Thanks so much!
      Pike
    • kcvinu
      By kcvinu
      Hi all,
      I have a button created with _GUICtrlButton_Create function. I know that this function returns a handle of button instead of an ID. So i have obtain control ID by calling _WinAPI_GetDlgCtrlID function. After that i have tried the GUICtrlSetBkColor function. But it didnt worked. Any suggestions will be appreciated. Thanks in advance. 
      Note : - The window which carries this button is not created with native gui create function. Instead, it is created with CreateWindowEx api function.
    • Yirrlaar
      By Yirrlaar
      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("MyCommands", 406, 236, 610, 129) $Main = GUICtrlCreateTab(8, 8, 385, 217) $TabSheet1 = GUICtrlCreateTabItem("Main") $StopFunc = GUICtrlCreateButton("STOP", 17, 43, 150, 50) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $StartFunc = GUICtrlCreateButton("Start", 17, 98, 150, 50) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Input0 = GUICtrlCreateInput("Input0", 267, 43, 75, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $Input1 = GUICtrlCreateInput("Input1"", 267, 73, 75, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $Input2 = GUICtrlCreateInput("Input2", 267, 103, 75, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $Input3 = GUICtrlCreateInput("Input3", 267, 133, 75, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $Input4 = GUICtrlCreateInput("Input4", 267, 163, 75, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $Input5 = GUICtrlCreateInput("Input5", 267, 195, 75, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $Label1 = GUICtrlCreateLabel("Label1", 215, 43, 50, 20, $SS_RIGHT) GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif") $Label2 = GUICtrlCreateLabel("Label2", 215, 73, 50, 20, $SS_RIGHT) GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif") $Label3 = GUICtrlCreateLabel("Label3", 215, 103, 50, 20, $SS_RIGHT) GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif") $Label4 = GUICtrlCreateLabel("Label4", 215, 133, 50, 20, $SS_RIGHT) GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif") $Label5 = GUICtrlCreateLabel("Label5", 215, 163, 50, 20, $SS_RIGHT) GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif") $Label6 = GUICtrlCreateLabel("Label6", 191, 195, 74, 20, $SS_RIGHT) GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif") $TabSheet2 = GUICtrlCreateTabItem("Individuals") $Button1 = GUICtrlCreateButton("Button1", 17, 43, 75, 25) GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $StartBOT letsdothis() Case $StopBOT END_This() EndSwitch WEnd func letsdothis() While 1 ;doing stuff ;doing more stuff if $StopFunc Then END_This() ;how do i detect if the button has been pressed if $Button1 Then Sleepy_Time() ;doing things ;doing more things WEnd EndFunc Func Sleepy_Time() while 1 sleep(10) if $Button1 Then ExitLoop ; detect button press and return to previous state Wend EndFunc Func END_This() Exit EndFunc For the LIFE of me I can't figure out, HOW ON EARTH to detect that a button has been pressed while a function is running?
      Can someone PLEASE point me in the right direction???
      Thanks
    • Robdog1955
      By Robdog1955
      I'm trying to click a button on a web page. I have added a couple of MsgBox lines to allow me to watch what happens on the page. As you can see the first half of my script enters data into text boxes on the page. I have no problem there. I just cannot click on the region buttons. The "set focus" line causes an outline to appear around the EU button and the "click button" line causes the "Pick a Region" text to disappear. Here is the code I have so far.
      #include <IE.au3> Local $oIE = _IECreate("http://questchecker.com/") Local $iQuestID = "123456" Local $sCharacterName = "CharacterName" Local $colForms = _IEFormGetCollection($oIE) $iCount = 0 For $oForm In $colForms $oFormElements = _IEFormElementGetCollection($oForm) For $oFormElement In $oFormElements $iCount = $iCount + 1 Local $sTagName = StringLower($oFormElement.tagName) Local $sElementType = $oFormElement.type Local $sElementName = $oFormElement.name Switch $iCount Case 6 _IEFormElementSetValue($oFormElement, "MyRealm", 0) ; realm Case 7 _IEFormElementSetValue($oFormElement, $sCharacterName, 0) Case 8 _IEFormElementSetValue($oFormElement, $iQuestID, 0) EndSwitch Next Next Local $oButtons = _IEGetObjByName($oIE, "questForm") For $oButton In $oButtons If _IEFormElementGetValue($oButton) = "US" Then MsgBox(0, "", "Click Okay to set focus") _IEAction($oButton, "focus") MsgBox(0, "", "Click Okay to click button") _IEAction($oButton, "click") ExitLoop EndIf Next MsgBox(0, "", "Click Okay to quit") _IEQuit($oIE) Exit  
    • John C.
      By John C.
      ;Adding $BS_DEFPUSHBUTTON doesn't work
              $idCopy_Data = GUICtrlCreateButton("Copy Data Only", $iButtonWidth_2, $aiGUISize[1] - $iButtonMargin, $iButtonWidth_2, 20, $BS_DEFPUSHBUTTON)
      ;Adding these two lines doesn't work either
               Local $aAccelKeys[2][2] = [["{enter}", $idCopy_Data], ["^{enter}", $idCopy_ID]]
              GUISetAccelerators($aAccelKeys)
       
×