zxtnt09

Hide CTRL Edit

3 posts in this topic

#1 ·  Posted (edited)

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



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

1 person likes this

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

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

    • Aphotic
      By Aphotic
      Just wanted to share my functions for managing a GUI with lots of controls and many screens.
      I personally feel that it is very efficient and keeps line count to a minimum.
      And if it's not, I'll learn a better solution!
      Note: There are some conditional veriables such as $changes and $cont that are modified by the main loop in this particular script; they are meant as an example, please don't try too hard to understand why they're used.
      *Usage*
      This allows you to re-state a handful of buttons in one line when doing slight GUI changes:
      ToggleCTRL($GUI_DISABLE, $dALO, $dAAF, $dRLA) (A few buttons on a certain screen)
      ToggleCTRL($GUI_DISABLE, $dSAV, $dCAN) (Save/Cancel buttons)
      AND
      A single line solution to switching a GUI "screen":
      GuiMod("MAIN", $GUI_HIDE)
      GuiMod("DETAILS", $GUI_SHOW)
      GuiMod("PLANS", $GUI_HIDE)
      Another way I've used this to my advantage is as follows:
      Say a GUI has 3 or 4 main screens, and 3 or 4 "form" screens.
      When switching to a form screen, save the main screen that it was on to a variable; then once the user is done with the form, either submitting or cancelling, you can call the variable to revert back to the main screen it was on.
      Func _GuiMod($i, $tog, $act = True) Switch $i Case "MAIN" If $tog = $GUI_SHOW And $changes Then $changes = False ControlClick($GUI, "", $LOGfg) Else EndIf If $tog = $GUI_SHOW Then WinMove($GUI, "", Default, Default, 535, 445) _ToggleCTRL($tog, $TAB, $LOGfl, $LOGfc, $LOGfi, $LOGfg, $LOGta, $LOGvd) _ToggleCTRL($tog, $LOGtp, $LOGse) Case "DETAILS" If $tog = $GUI_SHOW Then WinMove($GUI, "", Default, Default, 535, 475) Local $cont = True If $tog = $GUI_SHOW And $act Then If Not UpdateDetails() Then $cont = False _GuiMod("MAIN", $GUI_SHOW) EndIf EndIf If $cont Then _ToggleCTRL($tog, $dUID, $dICU, $dACC, $dCOF, $dNAM, $dCO2, $dIPW, $dEMA, $dEDI, $dLOG, $dMOD) _ToggleCTRL($tog, $dUPD, $dINP, $dAPL, $dALO, $dAAF, $dPLL, $dLOL, $dAFL, $dSAV, $dCAN, $dRPL) _ToggleCTRL($tog, $dRLA, $dACT, $dAC2, $dRET, $dDEL, $dADD, $dMQC) EndIf Case "ADD-INPUT" _ToggleCTRL($tog, $nCOMi, $nCO2i, $nNAMi, $nNAMb, $nEMAi, $nPREc, $nACCc, $nICUi, $nADDi, $nNOTi) _ToggleCTRL($tog, $nAPLb, $nALOb, $nAAFb, $nPLAl, $nLOCl, $nAFFl, $nRPLb, $nRLAb, $nADDb, $nCLEb) Case "PLANS" If $tog <> $GUI_SHOW Or Not $changing Then If $act Then _ToggleCTRL($tog, $dMOD, $dLOG, $dUPD, $dDEL) _ToggleCTRL($tog, $dINP, $dAPL, $dALO, $dAAF, $dPLL, $dLOL, $dAFL, $dSAV, $dCAN, $dRPL, $dRLA) EndIf Case "CHANGE" _ToggleCTRL($tog, $dITL, $dITC, $dAML, $dAMC, $dSCB, $dCCB, $dEAB) If $tog = $GUI_SHOW Then GUICtrlSetState($dRET, $GUI_DISABLE) Else GUICtrlSetState($dRET, $GUI_ENABLE) EndIf Case "NEW" If $tog = $GUI_SHOW Then WinMove($GUI, "", Default, Default, 465, 475) _ToggleCTRL($tog, $TAB, $nCOMl, $nCOMi, $nCO2l, $nCO2i, $nNAMl, $nNAMi, $nEMAl, $nEMAi, $nPREl, $nPREc) _ToggleCTRL($tog, $nACCl, $nACCc, $nPAEb, $nICUl, $nICUi, $nADDi, $nAPLb, $nALOb, $nAAFb, $nPLAl, $nLOCl) _ToggleCTRL($tog, $nAFFl, $nRPLb, $nNOTl, $nNOTi, $nADDb, $nCLEb, $nLAST) Case "ACCESS" If $tog = $GUI_SHOW Then WinMove($GUI, "", Default, Default, 465, 330) _ToggleCTRL($tog, $ACCd1, $ACCd2, $TYPla, $TYPli, $TYPad, $TYPde, $TYPmu, $TYPmd, $ACCla, $ACCli) _ToggleCTRL($tog, $ACCde, $ACCmu, $ACCmd, $ACCdl, $ACCdi, $ACCal, $ACCai, $ACCaa, $taRET) Case "TPi" _ToggleCTRL($tog, $tpOPEb, $tpCREr, $tpLINr, $tpCO2i, $tpEMAi, $tpEMAl, $tpCREb, $tpCOPb, $tpCOPi, $tpCTOi, $tpCGOb) _ToggleCTRL($tog, $tpUFLi, $tpUFLb, $tpICUi, $tpPLAi, $tpLINb, $tpDLIb, $tpUFMi, $tpSCAl, $tpCFAr, $tpCBAr) Case "TPC" If $tog = $GUI_SHOW Then _GuiMod("TPL", $GUI_HIDE) _GuiMod("TPH", $GUI_HIDE) _GuiMod("TPD", $GUI_HIDE) EndIf _ToggleCTRL($tog, $tpCO2l, $tpCO2i, $tpCOPl, $tpCOPi, $tpCREb, $tpCOPb, $tpSEPl, $tpCTOl, $tpCTOi, $tpCGOb, $tpLAST) _ToggleCTRL($tog, $tpIDNl, $tpIDNi, $tpIDNn, $tpSCAl, $tpEMAi, $tpEMAl, $tpCFAr, $tpCBAr) Case "TPL" If $tog = $GUI_SHOW Then _GuiMod("TPC", $GUI_HIDE) _GuiMod("TPH", $GUI_HIDE) _GuiMod("TPD", $GUI_HIDE) EndIf _ToggleCTRL($tog, $tpUFLl, $tpUFLi, $tpUFLb, $tpICUl, $tpICUi, $tpPLAl, $tpPLAi, $tpLINb, $tpDLIb, $tpUFMl, $tpUFMi, $tpIMAb, $tpIMRb) Case "TPH" If $tog = $GUI_SHOW Then _GuiMod("TPC", $GUI_HIDE) _GuiMod("TPL", $GUI_HIDE) _GuiMod("TPD", $GUI_HIDE) EndIf _ToggleCTRL($tog, $tpUFLl, $tpUFLi, $tpUFLb, $tpUFMl, $tpUFMi, $tpCOCl, $tpCOCi, $tpCOGb) Case "TPD" If $tog = $GUI_SHOW Then _GuiMod("TPC", $GUI_HIDE) _GuiMod("TPL", $GUI_HIDE) _GuiMod("TPH", $GUI_HIDE) EndIf _ToggleCTRL($tog, $tpDIDl, $tpDIDi, $tpDIDb) EndSwitch EndFunc Func _ToggleCTRL($tog, $c0 = 0, $c1 = 0, $c2 = 0, $c3 = 0, $c4 = 0, $c5 = 0, $c6 = 0, $c7 = 0, $c8 = 0, $c9 = 0, $c10 = 0, $c11 = 0, $c12 = 0) For $i = 0 To @NumParams GUICtrlSetState(Eval("c" & $i), $tog) Next EndFunc  
    • dejhost
      By dejhost
      Hi everybody,
      I have troubles using the function "GUISetCursor" properly.
      My script generates a small GUI and opens an image in IrfanView. If the user hits the button "$p_coord" on the GUI, the GUI shall be hidden, IrfanView shall become active and the mousepointer shall turn into a cross (as long hovering over IrfanView). Once clicked into IrfanView, the cursor shall turn into a nordinary mousepointer again.
      Unfortunately, the cross doesn't appear until the user clicks into IrfanView manually. Then the mousepointer changes for the duration of the click into the cross. Can anybody tell why this is happening?
      Here is the relevant code:
      GUISetState(@SW_SHOW, $hGUI) ;the autoit gui is hidden ; Loop until the user exits: While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $p_coord WinSetState("Bicon Coordinator","",@SW_HIDE) ;the autoit gui is hidden $Handle = WinActivate ( "IrfanView") ; IrfanView is activated GUISetCursor (15,1,$Handle) ;Cursor should be turned into a cross - this is what fails :-( While 1 If _IsPressed ("01", $hDLL) Then ;Once a mousclick by the user is performed... GUISetCursor (2) EndIf EndSwitch WEnd  
      dejhost
       
       
       
       
       
    • WoodGrain
      By WoodGrain
      Hi guys,
      Trying to map my mouse button 4 (I'm pretty sure it's 4 rather than 5, but I can experiment) to click the back button in a program (screenshot attached). In terms of positioning it sits in the middle of 3 screens if that makes a difference.
      I assume I can use something like (though I prob don't need the 1st two lines if using ControlClick?):
      WinActivate("ConnectWise v2016.4 (41139)", "Chrome Legacy Window") WinWaitActive("ConnectWise v2016.4 (41139)", "Chrome Legacy Window") ControlClick("ConnectWise v2016.4 (41139)", "Chrome Legacy Window", "[CLASS:Chrome_RenderWidgetHostHWND; INSTANCE:1]", "Left", 1, 0, 30) When I hover my mouse over the button I get the following information in Window Info
      >>>> Window <<<< Title: ConnectWise v2016.4 (41139) Class: TabBrowser_MainFrame Position: -8, -8 Size: 1696, 1026 Style: 0x17CF0000 ExStyle: 0x00040100 Handle: 0x0000000000010C56 >>>> Control <<<< Class: Chrome_RenderWidgetHostHWND Instance: 1 ClassnameNN: Chrome_RenderWidgetHostHWND1 Name: Advanced (Class): [CLASS:Chrome_RenderWidgetHostHWND; INSTANCE:1] ID: 315622768 Text: Chrome Legacy Window Position: 0, 30 Size: 1680, 957 ControlClick Coords: 81, 138 Style: 0x56300000 ExStyle: 0x00000020 Handle: 0x0000000000040AC6 >>>> Mouse <<<< Position: 81, 191 Cursor ID: 0 Color: 0x004E7F >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< ConnectWise: My Calendar Chrome Legacy Window >>>> Hidden Text <<<< Chrome Legacy Window  

    • Queener
      By Queener
      This is the info of the interface:
      Window
      Title:    Password Safe
      Class:    #32770
      Control
      Class:    ToolbarWindow32
      Instance:    2
      ClassnameNN:    ToolbarWindow322
      Name:    
      Advanced (Class):    [CLASS:ToolbarWindow32; INSTANCE:2]
       ToolsBar
      1:    32003    Make New Database
      2:    32002    Open Another Database
      3:    32004    Close Database
      4:    32005    Save Database
      5:    0    
      6:    32066    Copy Password to Clipboard
      7:    32068    Copy Username to Clipboard
      8:    32069    Copy Notes to Clipboard
      9:    32065    Clear the clipboard contents
      10:    0    
       
      I wanted to click on 1:    32003    Make New Database. But unfortunately, I'm unable to click on that. Any help is much appreciated. Below are the code I tried:

      $Title = "Password Safe" $Class = "[CLASS:ToolbarWindow32; INSTANCE:2]" WinWaitActive($Title) Sleep(500) Dim $hWnd = WinGetHandle($Title,"") Dim $hToolBar = ControlGetHandle($hWnd, '', $Class) ConsoleWrite($hWnd & @TAB & $hToolBar & @LF) _GUICtrlToolbar_ClickIndex($hToolBar, 32003)
    • Comboku
      By Comboku
      Hi Guys,
      I have written a little loop program that counts to whatever you choose in "Rounds". 

      (this is just a short version of my program, but it should cover what I try to achieve)

      I now want to be able to stop the counting by pressing the start/stop button. Unfortunately, autoit only registers my click on my button AFTER the func has ended.

      Do you guys have an idea how to stop the function? Maybe check if button was pressed in the loop? 


      Thanks,

      Comboku

       
       
       
      #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <IE.au3> #include <Array.au3> #include <File.au3> $Form1 = GUICreate("Looper", 355, 229, 435, 293) $StartStop = GUICtrlCreateButton("Start", 136, 184, 75, 25) $Rounds = GUICtrlCreateInput("1", 210, 40, 80, 21) $lRounds = GUICtrlCreateLabel("Rounds", 298, 42, 52, 18) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $StartStop If GUICtrlRead($StartStop) = "Start" Then GUICtrlSetData($StartStop, "Stop") GUICtrlSetState($Rounds, $GUI_DISABLE) Call("Loop") ElseIf GUICtrlRead($StartStop) = "Stop" Then ExitLoop MsgBox(0, "Info", "Stopped") Else MsgBox(0, "Info", "Error") EndIf Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Loop() $LoopTimes = GUICtrlRead($Rounds) For $i = 1 To $LoopTimes MsgBox(0, "Info", "LET US COUNT: " & $i) Sleep("2000") Next GUICtrlSetData($StartStop, "Start") GUICtrlSetState($StartStop, $GUI_ENABLE) GUICtrlSetState($Rounds, $GUI_ENABLE) EndFunc