Jump to content
Sign in to follow this  
LetsAuto

if button is clicked..? {SOLVED}

Recommended Posts

LetsAuto

Hi everyone... i need a little help getting a button click statement to work.. this is what i have..

#include
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("CALs", 494, 408, 425, 188)
$serverButton = GUICtrlCreateButton("Server", 112, 72, 105, 41)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$deskButton = GUICtrlCreateButton("Desktop", 256, 72, 105, 41)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$calListBox = GUICtrlCreateList("", 136, 136, 201, 206)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
$sValue = IniRead("C:\IanLogTest\radioButton.ini", "Breed", "Radio Checked", "Error!")
Switch $sValue
Case "0"
if $serverButton Then
_GUICtrlListBox_InsertString($calListBox,"test")
EndIf
Case "1"
Run("C:\Program Files\AutoIt3\AutoIt3.exe F:\AutoIt3\testings\auto\dogs.au3")
Case "3"
Run("C:\Program Files\AutoIt3\AutoIt3.exe F:\AutoIt3\testings\auto\dogs.au3")
Case "5"
Run("C:\Program Files\AutoIt3\AutoIt3.exe F:\AutoIt3\testings\auto\dogs.au3")
EndSwitch
EndSwitch
WEnd

what i want it to do is.. if $serverButton is pressed when $sValue = "0" then display "test" in the $calListBox.... i just dont know how to say IF the button is pressed THEN do THIS - in autoit....

Edited by LetsAuto

Share this post


Link to post
Share on other sites
LetsAuto

yes, but i need the nested IF within Case "0" to work... i can make buttons click with switch...case.. thats easy, but i cant get a switch case to work within a case.. so i tried the if... i need help getting the

If $serverButton is clicked Then

show data in list box

else if $deskButton is clicked Then

show other data in list box

end if

Share this post


Link to post
Share on other sites
LetsAuto

but the thing is, depending on what is in quotes ("0, "3"...) different information will populate the list box, so wouldnt i need a specific Switch for that?..

$sValue = IniRead("C:IanLogTestradioButton.ini", "Brand", "Radio Checked", "Error!")
Switch $sValue
Case "0"
$serverClick = _GUICtrlButton_Click($serverButton)
Switch $serverClick
Case True
_GUICtrlListBox_InsertString($calListBox, "test")
EndSwitch

;~ If _GUICtrlButton_Click($serverButton) Then
;~ _GUICtrlListBox_InsertString($calListBox, "test")
;~ EndIf
Case "1"
Run("C:Program FilesAutoIt3AutoIt3.exe F:AutoIt3testingsautoWizardCALs.au3")
Case "3"
Run("C:Program FilesAutoIt3AutoIt3.exe F:AutoIt3testingsautoWizardCALs.au3")
Case "5"
Run("C:Program FilesAutoIt3AutoIt3.exe F:AutoIt3testingsautoWizardCALs.au3")
EndSwitch

something like that i would think, however that exact wording does not work

Share this post


Link to post
Share on other sites
BrewManNH

Maybe something like this???

#include
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("CALs", 494, 408, 425, 188)
$serverButton = GUICtrlCreateButton("Server", 112, 72, 105, 41)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$deskButton = GUICtrlCreateButton("Desktop", 256, 72, 105, 41)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$calListBox = GUICtrlCreateList("", 136, 136, 201, 206)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $serverButton
            $sValue = IniRead("C:IanLogTestradioButton.ini", "Breed", "Radio Checked", "Error!")
            Switch $sValue
                Case "0"
                    _GUICtrlListBox_InsertString($calListBox, "test")
                Case "1"
                    Run("C:Program FilesAutoIt3AutoIt3.exe F:AutoIt3testingsautodogs.au3")
                Case "3"
                    Run("C:Program FilesAutoIt3AutoIt3.exe F:AutoIt3testingsautodogs.au3")
                Case "5"
                    Run("C:Program FilesAutoIt3AutoIt3.exe F:AutoIt3testingsautodogs.au3")
            EndSwitch
    EndSwitch
WEnd

BTW, the description of your question is extremely vague, you should explain in detail what it is you're trying to do if this script doesn't do it for you.


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

    • 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.
    • dadalt
      By dadalt
      Hi!
      I have a button where I need to close it!
      I was doing through  clicking same position in screen but there are some id's that have different sizes.
      What are the possible ways to click this closable button?
      Is there a way to close it through id? Is there a way to get it's position through it's ID?  
      Thanks in advance!


    • 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  
    • dadalt95
      By dadalt95
      Perform a simple google search!
      The script below works fine until fill the google form!
      What I can't find is how to submit the form, tried a couple of ways and none of them worked.

       
      #include <IE.au3> $oIE = _IECreate ("www.google.com") $o_form = _IEFormGetObjByName ($oIE, "f") $o_login = _IEFormElementGetObjByName ($o_form, "q") $username = "80251369" _IEFormElementSetValue ($o_login, $username) $o_numer = _IEGetObjByName($o_form, "btnK") _IEAction ($o_numer, "click")  
      The code runs without any problem.
      I don't know how to proceed!
      Thanks in advance!
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.