Jump to content
SerLanceloth

Casing Buttons

Recommended Posts

SerLanceloth

hello everyone I need some urgent help I need to create a function that is based on buttons, that is setting data to Edits depending on the levels selected on the combobox, now I am able to use the buttons from the main guy where the function is only 1, but I need the same button to do different things depending of whats selected on the combobox thanks in advance for your help

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


$Form1 = GUICreate("Form1", 229, 295, 192, 124)
$Combo1 = GUICtrlCreateCombo("Combo1", 8, 8, 169, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
   GUICtrlSetData($Combo1, "|Item 1|Item 2|Item 3")
$Button1 = GUICtrlCreateButton("Button1", 8, 40, 75, 25)
$Button2 = GUICtrlCreateButton("Button2", 88, 40, 75, 25)
$Edit1 = GUICtrlCreateEdit("", 0, 80, 193, 177)
GUICtrlSetData(-1, "Edit1")
GUISetState(@SW_SHOW)


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

 EndSwitch
WEnd

here is like an idea of flow of what im looking for
if GUICtrlRead($combo1) = "Item 1" Then $Button1 sets edit1 data to yes and $button2 sets edit1 data to no
   if GUICtrlRead($combo1) = "Item 2" Then $Button1 sets edit1 data to yes2 and $button2 sets edit1 data to no2
   if GUICtrlRead($combo1) = "Item 3" Then $Button1 sets edit1 data to yes3 and $button2 sets edit1 data to no3

Edited by Melba23
Added code tags

Share this post


Link to post
Share on other sites
Melba23

SerLanceloth,

Something like this should be what you want:

#include <GUIConstantsEx.au3>

Local $sButton1_Data = "", $sButton2_Data = ""

$Form1 = GUICreate("Form1", 229, 295, 192, 124)

$Combo1 = GUICtrlCreateCombo("", 8, 8, 169, 25) ; The required styles are the defaults
GUICtrlSetData($Combo1, "|Item 1|Item 2|Item 3")
$Button1 = GUICtrlCreateButton("Button1", 8, 40, 75, 25)
$Button2 = GUICtrlCreateButton("Button2", 88, 40, 75, 25)
$Edit1 = GUICtrlCreateEdit("", 0, 80, 193, 177)

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo1
            Switch GUICtrlRead($Combo1)
                Case "Item 1"
                    $sButton1_Data = "yes1"
                    $sButton2_Data = "no1"
                Case "Item 2"
                    $sButton1_Data = "yes2"
                    $sButton2_Data = "no2"
                Case "Item 3"
                    $sButton1_Data = "yes3"
                    $sButton2_Data = "no3"
            EndSwitch

        Case $Button1
            GUICtrlSetData($Edit1, $sButton1_Data)
        Case $Button2
            GUICtrlSetData($Edit1, $sButton2_Data)
    EndSwitch

WEnd

And when you post code please use Code tags - see here how to do it.  Then you get a scrolling box and syntax colouring as you can see above now I have added the tags.

M23

 


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
SerLanceloth

thanks melba you awesome, im trying to save and hit on next line, i manage for it to save it by adding the 1 after the coma at the end, but how can i make it write on next line?

#include <GUIConstantsEx.au3>

Local $sButton1_Data = "", $sButton2_Data = ""

$Form1 = GUICreate("Form1", 229, 295, 192, 124)

$Combo1 = GUICtrlCreateCombo("", 8, 8, 169, 25) ; The required styles are the defaults
GUICtrlSetData($Combo1, "|Item 1|Item 2|Item 3")
$Button1 = GUICtrlCreateButton("Button1", 8, 40, 75, 25)
$Button2 = GUICtrlCreateButton("Button2", 88, 40, 75, 25)
$Edit1 = GUICtrlCreateEdit("", 0, 80, 193, 177)

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo1
            Switch GUICtrlRead($Combo1)
                Case "Item 1"
                    $sButton1_Data = "yes1"
                    $sButton2_Data = "no1"
                Case "Item 2"
                    $sButton1_Data = "yes2"
                    $sButton2_Data = "no2"
                Case "Item 3"
                    $sButton1_Data = "yes3"
                    $sButton2_Data = "no3"
            EndSwitch



        Case $Button1
            GUICtrlSetData($Edit1, $sButton1_Data,1)
        Case $Button2
            GUICtrlSetData($Edit1, $sButton2_Data,1)
    EndSwitch

WEnd

 

Share this post


Link to post
Share on other sites
Melba23

SerLanceloth,

What do you think might make the edit control move down a line? What would you press if you were using a keyboard?

GUICtrlSetData($Edit1, $sButton1_Data & @CRLF, 1) ; Add an EOL

M23 


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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

  • Similar Content

    • nooneclose
      By nooneclose
      Hello again, I am in phase two of my help bot. I cannot figure out how to properly code Autoit to click on a webpage button using the I.E UDF. I want to click on the button that I have attached as an image. This button does not have a name but it has an ID. Here is the HTML code for this button that I found using chromes developer inspector.
      HTML Code: 
      <img role="button" tabindex="-1" id="toolactions_INSERT-tbb_image" src="nav_icon_insertkey.gif" alt="New Work Order CTRL+ALT+I" draggable="false"> Here is the code that I have so far:
      ;******************************************************************************* ; Opens IE and fill out a New Workorder ;******************************************************************************* ; Start IE at the ** Tracking Application in ****** $oIE = _IECreate("https:I_am_Bound_by_my_company_to_not_reveal_this_webpage") ; Wait for a browser page load to complete _IELoadWait($oIE) Sleep(6000) ; Store the field names where the important data will be sent Local $nWorkOrderB = _IEGetObjById($oIE, "toolactions_INSERT-tbb_image") _IEAction($nWorkOrderB, "click")  I want my program to click on the button that looks like a piece of paper with a blue # 
      (For those wondering, I am allowed to send images just not the URL.) 
      As always any help would be appreciated. 

    • MJ36
      By MJ36

      How to click this button ? 
      I Try 
       
      func test () $oCorrectObj = "" $tags = $oIE.document.GetElementsByTagName("button") For $tag in $tags $class_value = $tag.GetAttribute("type") If string($class_value) = "buttont" Then $oCorrectObj = $tag MsgBox(0, "Level: ", "Level found :)") Else MsgBox(16, "Failed", "Not found.") ExitLoop EndIf Next If IsObj ( $oCorrectObj ) Then _IEAction ($oCorrectObj, "click") EndIF  
      and
       
      func klik () Local $oFound = "" Local $oBtns = _IETagNameGetCollection($oIE, "span") For $oBtn In $oBtns If String($oBtn.classname) = "yt-uix-button-content" Then $oFound = $oBtn EndIf Next _IEAction ($oFound, "click") EndFunc  
      Please Help 
      Can you click it by name?
    • faustf
      By faustf
      i guys , like title anyone  have idea if is possible , and if yes if  have example to post ?  i find in forum and in google but  i dont know   how can start  to create  button with icon over toolbar near  clock or is  goog before language layout .
      sorry i not post any script but i dont know  where to start
      thankz
      at  all
    • caramen
      By caramen
      Hmmm i am sorry  i had simular problem but i cant find back post. 
       
      How to hide a gui button ? 
       
      I Want to dodge the variable non déclaréd when i make button in
      if statment 
       
      thx before 
    • odaylton
      By odaylton
      Hello everyone ,
      Text translated from Portuguese by google - please apologize for any errors

      Once again I need a light from the gurus of this wonderful website
      I am fanatic by combobox for its usability but I am not able to uncertain images within lists ...
      I know uncertain icons, and cursors but I am not able to insert gif or jpg images.
      1) How to solve this ...
      2) will the path is to convert gif into bmp and then uncertain ... how to do that?
      #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> ;dados de mouse #include <WinAPIRes.au3> ;COMBO #include <GuiComboBoxEx.au3> ;Fonts #include <FontConstants.au3> ;obter imagem de arquivo #include <GDIPlus.au3> #include <WinAPIGdi.au3> Example() Func Example() Local $hGUI, $hImage, $hCombo, $hFont Local $idListview, $hImage Local $sWow64 = "" Local $Pasta = "C:\WINDOWS\Cursors\3dgarro.cur" Local $PastaROMs = @MyDocumentsDir & "\Stella\ROMs\" ;com barra no final $hGUI = GUICreate("ImageList", 500, 310) GUISetFont(14, 400, 0, "Arial") ;<<<<<<<<<<this does not work for _GUICtrlComboBoxEx_Create $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 494, 200) ;GUICtrlSetFont($hCombo, 14, 400, 0, "Arial");<<<<<<<<<<It does not work ; ;Create a handle to a font object $hFont = _WinAPI_CreateFont(30, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial') ;Pass the handle to _WinAPI_SetFont _WinAPI_SetFont($hCombo, $hFont) $idListview = GUICtrlCreateListView("", 2, 50, 494, 250, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) GUISetState(@SW_SHOW) ; Initialize GDI+ library _GDIPlus_Startup() ; Load images $hImage = _GUIImageList_Create(120, 70, 6, 2) ;32,32,5,5) ; $DadosCombo = "Escolha|" & _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 120, 70)) ;Local $aCursors[] = [32650, 32512, 32515, 32649, 32651, 32513, 32648, 32646, 32643, 32645, 32642, 32644, 32516, 32514] For $i = 1 To 10 $sFile = FileOpenDialog("Please select an image", $PastaROMs, "Image (*.jpg;*.png;*.bmp;*.gif;*.tif)", BitOR($FD_PATHMUSTEXIST, $FD_FILEMUSTEXIST)) If @error Then Exit MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "Error", "No image file has been selected", 30) $a = _GDIPlus_BitmapCreateFromFile ($sFile);<<<<< ok If @error Or Not $hImage Then MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "Error", "This file isn't supported by GDIPlus!") Else $b=_GUIImageList_Add($hImage, $a);<<<<<< Return -1 $DadosCombo &= "|" & $i & "_img_princ.gif""|" & $b EndIf Next _GUICtrlListView_SetImageList($idListview, $hImage, 1) _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage) ; Add columns _GUICtrlListView_AddColumn($idListview, "Icons - Mouses", 350) ; Add items $a = StringSplit($DadosCombo, "|") For $i = 1 To $a[0] Step 2 _GUICtrlListView_AddItem($idListview, $a[$i], $a[$i + 1]) _GUICtrlComboBoxEx_AddString($hCombo, $a[$i], $a[$i + 1], $a[$i + 1]) Next ;AutoIt_Debugger_Command:Disable_Debug ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() ;AutoIt_Debugger_Command:Enable_Debug EndFunc ;==>Example tks
×