Jump to content

Recommended Posts

zxtnt09

Hi guys,

i have problem with this : 

2e0utk3.png

whheux.png

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


GUI()
Func GUI()
Global $MyForm = GUICreate("My GUI edit",500,300,100,100)
GUISetState(@SW_SHOW)
GUISetFont(12, 400, 0, "Tahoma")

$Label1 = GUICtrlCreateLabel("Label 01 ",0, 0, 50 , 25 )
$Label1 = GUICtrlCreateLabel("Label 01 ",0, 50, 50 , 25 )

Global $BTN1 = GUICtrlCreateButton("BTN 1 ", 150, 0, 50, 25)
Global $BTN2 = GUICtrlCreateButton("BTN 2", 150, 50, 50, 25)
EndFunc

;Function
Func Test1()
   If $BTN1 = True Then
   Local $Edit1 = GUICtrlCreateEdit("Edit 1", 0, 80, 200, 200)
   EndIf
EndFunc

Func Test2()
   If $BTN2 = True Then
   Local $Edit2 = GUICtrlCreateEdit("Edit 2", 200, 80, 200, 200)
   EndIf
EndFunc


While 1
Switch GUIGetMsg()

Case $BTN1
If $BTN1 = True Then
Test1 ()
EndIf

Case $BTN2
If $BTN2 = True Then
Test2 ()
EndIf

Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd

* i want to : after click on "$BTN 1" , "$Edit2" was hidden or 

after click on "$BTN 2" , "$Edit1" was hidden.

Edited by zxtnt09
Image

Share this post


Link to post
Share on other sites
Melba23

zxtnt09,

Simple - just hide/show the edits as required:

#include <GUIConstantsEx.au3>

Global $MyForm, $BTN1, $BTN2, $Edit1, $Edit2

GUI()

While 1
    Switch GUIGetMsg()
        Case $BTN1
            GUICtrlSetState($Edit2, $GUI_HIDE)
            GUICtrlSetState($Edit1, $GUI_SHOW)
        Case $BTN2
            GUICtrlSetState($Edit1, $GUI_HIDE)
            GUICtrlSetState($Edit2, $GUI_SHOW)
        Case $GUI_EVENT_CLOSE
            ExitLoop

    EndSwitch

WEnd



Func GUI()
    $MyForm = GUICreate("My GUI edit", 500, 300, 100, 100)

    GUISetFont(12, 400, 0, "Tahoma")

    $Label1 = GUICtrlCreateLabel("Label 01 ", 0, 0, 50, 25)
    $Label1 = GUICtrlCreateLabel("Label 01 ", 0, 50, 50, 25)

    $BTN1 = GUICtrlCreateButton("BTN 1 ", 150, 0, 50, 25)
    $BTN2 = GUICtrlCreateButton("BTN 2", 150, 50, 50, 25)

    $Edit1 = GUICtrlCreateEdit("Edit 1", 0, 80, 200, 200)
    $Edit2 = GUICtrlCreateEdit("Edit 2", 200, 80, 200, 200)
    GUICtrlSetState($Edit2, $GUI_HIDE)

    GUISetState(@SW_SHOW)
EndFunc   ;==>GUI

And it is not good coding practice to declare Global variables inside functions - so I changed that too.

M23

  • Like 1

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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
zxtnt09

Like everytime great, 

Thanks Melba23 :wub:

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. 

    • 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
    • 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!
×