kcvinu

How to loop through all textboxes in a form

23 posts in this topic

Hi all,

I have a form with 15 textboxes. I need to set all of them disabled when i press a button. So i decided to use a loop. But how can i do it. Any idea ?


My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites



Thank you @Jos. So simple answer. 


My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites

Use an array for the control handles so you can use a For..Next loop,

Jos

how can we use array ....

can u give one small example?

i am new to autoit

i want to select checkbox using IE function 

how can i use array there ??

 

Share this post


Link to post
Share on other sites

There is a big difference between the question raised here, using your own gui with controls and using the IE functions.
Why did you think they are related so I understand what you mean?

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

hey,

Already i have one webpage i want select checkbox ,

i just want to know how can i do it ??

which functions can be used 

Share this post


Link to post
Share on other sites

Again, this thread is related to an AutoIt3 GUI, not a webpage.
Create your own thread with the question in the appropriate forum.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

You can do something like this.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 595, 375, 192, 124)
$Input1 = GUICtrlCreateInput("Input1", 144, 24, 289, 21)
$Label1 = GUICtrlCreateLabel("Label1", 160, 64, 36, 17)
$Input2 = GUICtrlCreateInput("Input2", 152, 88, 281, 21)
$Button1 = GUICtrlCreateButton("Button1", 208, 136, 129, 17)
$Input3 = GUICtrlCreateInput("Input3", 32, 24, 89, 21)
$Input4 = GUICtrlCreateInput("Input4", 400, 168, 129, 21)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 72, 136, 97, 33)
$Button2 = GUICtrlCreateButton("Button2", 488, 72, 65, 33)
$Input5 = GUICtrlCreateInput("Input5", 176, 184, 193, 21)
$Input6 = GUICtrlCreateInput("Input6", 416, 240, 129, 21)
$Input7 = GUICtrlCreateInput("Input7", 40, 208, 217, 21)
$Input8 = GUICtrlCreateInput("Input8", 96, 256, 193, 21)
$Button3 = GUICtrlCreateButton("Disable Just Inputs", 200, 304, 209, 49)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button3
        For $i=$Input1 to  $Button3
            if _WinAPI_GetClassName(GUICtrlGetHandle($i))="Edit" Then
                GUICtrlSetState($i,$GUI_DISABLE)
            EndIf
        Next

    EndSwitch
WEnd

Saludos

Share this post


Link to post
Share on other sites

@Danyfirex , I am confuced. You are looping through what ? just through control IDs ?. Please clarify the for loop.


My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites

Yes I'm looping through all controls ID and check if is a Edit box. starting from first control ID (the first before the GUI)  till last one. this case $button3.

 

Saludos

 

 

1 person likes this

Share this post


Link to post
Share on other sites

Thanks. That is new knowledge for me to loop through declared control IDs. Then AutoIt considering control IDs as a list or range. Isn't it ?


My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites

Look inside SciTEConfig for the code that set's up the the "Edit Colors" window. I use a For..Next loop to create the 3 columns of CheckBoxes and also a For..Next loop to see which are checked/

Jos

1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

kcvinu,

AutoIt ControlIDs are actually the index numbers of the internal array that AutoIt uses to track the native created controls. They are usually in numerical order, but to save space, the first empty index is used - this means that deleting controls will allow the same ControlID to be reused, as you can see here:

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

For $i = 0 To 9
    $cCID = GUICtrlCreateLabel("", 10, 10 + (20 * $i), 200, 20)
    GUICtrlSetData($cCID, $cCID)
Next

$cReuse = GUICtrlCreateButton("Delete/Recreate", 10, 450, 100, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cReuse

            GUICtrlDelete(5)
            $cCID = GUICtrlCreateLabel("", 10, 10 + (20 * $i), 200, 20)
            GUICtrlSetData($cCID, $cCID)
    EndSwitch

WEnd

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

@Melba23 Interesting !. So if you delete a control, it's ID will be allotted to a new control. But why did this example only shows labels with number 3 ?. I expect it should start from zero.


My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

@Jos , Did you meant these lines ?

For $x = 1 To 17
    $H_Syn_Label[$x] = GUICtrlCreateLabel($Syn_Label[$x], $BaseX + 5, $BaseY + 20 * $x, 150, 20)
    $H_Syn_Bold[$x] = GUICtrlCreateCheckbox("", $BaseX + 170, $BaseY + 20 * $x, 20, 20)
    $H_Syn_Italic[$x] = GUICtrlCreateCheckbox("", $BaseX + 195, $BaseY + 20 * $x, 20, 20)
    $H_Syn_Underline[$x] = GUICtrlCreateCheckbox("", $BaseX + 220, $BaseY + 20 * $x, 20, 20)
    $H_Syn_fColor[$x] = GUICtrlCreateButton("Fore", $BaseX + 245, $BaseY + 20 * $x, 40, 20)
    $H_Syn_bColor_Standard[$x] = GUICtrlCreateCheckbox("", $BaseX + 295, $BaseY + 20 * $x, 20, 20)
    $H_Syn_bColor[$x] = GUICtrlCreateButton("Back", $BaseX + 320, $BaseY + 20 * $x, 40, 20)
Next

And these are the lines in which you checked for the control state

; Check if one of the checkboxes is clicked
    For $x = 1 To 17
        If $Msg = $H_Syn_bColor_Standard[$x] Then
            $Syn_bColor_Default[$x] = GUICtrlRead($H_Syn_bColor_Standard[$x])
            If GUICtrlRead($H_Syn_bColor_Standard[$x]) = $GUI_CHECKED Then
                GUICtrlSetState($H_Syn_bColor[$x], $GUI_DISABLE)
                $Syn_bColor[$x] = $Background_Color
                GUICtrlSetBkColor($H_Syn_Label[$x], $Syn_bColor[$x])
            Else
                GUICtrlSetState($H_Syn_bColor[$x], $GUI_ENABLE)
            EndIf
            $NeedsSave = 1
        EndIf
        If $Msg = $H_Syn_Bold[$x] Then
            $Syn_Bold[$x] = Not $Syn_Bold[$x]
            $NeedsSave = 1
        EndIf
        If $Msg = $H_Syn_Italic[$x] Then
            $Syn_Italic[$x] = Not $Syn_Italic[$x]
            $NeedsSave = 1
        EndIf
        If $Msg = $H_Syn_Underline[$x] Then
            $Syn_Underline[$x] = Not $Syn_Underline[$x]
            $NeedsSave = 1
        EndIf
        If $Msg = $H_Syn_fColor[$x] Then
            $tempcolor = SelectColor($Syn_fColor[$x])
            $Syn_fColor[$x] = $tempcolor
            GUICtrlSetColor($H_Syn_Label[$x], $Syn_fColor[$x])
            $NeedsSave = 1
        EndIf
        If $Msg = $H_Syn_bColor[$x] Then
            $tempcolor = SelectColor($Syn_bColor[$x])
            $Syn_bColor[$x] = $tempcolor
            GUICtrlSetBkColor($H_Syn_Label[$x], $Syn_bColor[$x])
            $NeedsSave = 1
        EndIf
        If $Msg = $H_Syn_Bold[$x] Or $Msg = $H_Syn_Italic[$x] Or $Msg = $H_Syn_Underline[$x] _
                Or $Msg = $H_Syn_fColor[$x] Or $Msg = $H_Syn_bColor[$x] Then
            GUICtrlSetFont($H_Syn_Label[$x], $SYN_Font_Size, 400 + $Syn_Bold[$x] * 200, $Syn_Italic[$x] * 2 + $Syn_Underline[$x] * 4, $SYN_Font_Type)
            $NeedsSave = 1
        EndIf
    Next

 

Edited by kcvinu

My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites

kcvinu,

why did this example only shows labels with number 3 ?.

The first ControlID returned has always been 3 since I started using AutoIt - you will have to ask Jon why, but I imagine that the earlier elements are used for other things that AutoIt needs to track.

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

@Melba23 Oh. I deleted label number 2 for a test. But nothing happened and label number 14 created. 


My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites

kcvinu,

As I explained above, the control ControlIDs start from 3, so using a lower value in a ControlID parameter will not affect any existing control. Thus in this case nothing is deleted and the next created control will follow on from the earlier sequence.

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

Melba23,

But the earlier sequence was ended at 12. So, new control should be created as 13. But it indicates 14. 


My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites

kcvinu,

The first ControlID returned has always been 3 since I started using AutoIt - you will have to ask Jon why, but I imagine that the earlier elements are used for other things that AutoIt needs to track.

M23

always is 3 because autoit create two hidden controls internally. maybe internally use a counter for HMENU parameter of CreateWindowEx.

 

Saludos

 


 

1 person likes this

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

    • tcurran
      By tcurran
      Here are two functions to provide pixel-accurate height and width dimensions for a given string.
      The more commonly-used _GDIPlus_GraphicsMeasureString built-in UDF is problematic because it returns the width padded by roughly one en-space (for reasons related to the various ways Windows produces anti-aliased fonts).
      These are AutoIt translations of Pierre Arnaud's C# functions, described in his CodeProject article "Bypass Graphics.MeasureString limitations"
      The first is an all-purpose version that takes a window handle, string, font family, font size (in points), style, and (optionally) width of the layout column (in pixels) as parameters.
      The second, more efficient version is intended for applications where GDI+ fonts are already in use, and takes handles to the existing graphics context, string, font, layout and format as parameters.
      Both functions return a two-row array with the exact width [0] and height [1] of the string (in pixels).
      #include <GDIPlus.au3> #include <GUIConstantsEx.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _StringInPixels ; Description ...: Returns a pixel-accurate height and width for a given string using a given font, style and size. ; Syntax ........: _StringInPixels($hGUI, $sString, $sFontFamily, $fSize, $iStyle[, $iColWidth = 0]) ; Parameters ....: $hGUI - Handle to the window. ; $sString - The string to be measured. ; $sFontFamily - Full name of the font to use. ; $fSize - Font size in points (half-point increments). ; $iStyle - Combination of 0-normal, 1-bold, 2-italic, 4-underline, 8-strikethrough ; $iColWidth - [optional] If word-wrap is desired, column width in pixels ; Return values .: 2-row array. [0] is width in pixels; [1] is height in pixels. ; Author ........: Tim Curran; adapted from Pierre Arnaud's C# function ; Modified ......: ; Remarks .......: This version is longer and less efficient but works for all purposes. ; Related .......: <https://www.codeproject.com/Articles/2118/Bypass-Graphics-MeasureString-limitations> ; Link ..........: ; Example .......: Example-StringInPixels.au3 ; =============================================================================================================================== #include <GDIPlus.au3> #include <GUIConstantsEx.au3> Func _StringInPixels($hGUI, $sString, $sFontFamily, $fSize, $iStyle, $iColWidth = 0) _GDIPlus_Startup() Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle Local $aRanges[2][2] = [[1]] $aRanges[1][0] = 0 ;Measure first char (0-based) $aRanges[1][1] = StringLen($sString) ;Region = String length Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate($sFontFamily) Local $hFont = _GDIPlus_FontCreate($hFamily, $fSize, $iStyle) _GDIPlus_GraphicsSetTextRenderingHint($hGraphic, $GDIP_TEXTRENDERINGHINT_ANTIALIASGRIDFIT) _GDIPlus_StringFormatSetMeasurableCharacterRanges($hFormat, $aRanges) ;Set ranges Local $aWinClient = WinGetClientSize($hGUI) If $iColWidth = 0 Then $iColWidth = $aWinClient[0] Local $tLayout = _GDIPlus_RectFCreate(10, 10, $iColWidth, $aWinClient[1]) Local $aRegions = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphic, $sString, $hFont, $tLayout, $hFormat) ;get array of regions Local $aBounds = _GDIPlus_RegionGetBounds($aRegions[1], $hGraphic) Local $aWidthHeight[2] = [$aBounds[2], $aBounds[3]] ; Clean up resources _GDIPlus_FontDispose($hFont) _GDIPlus_RegionDispose($aRegions[1]) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() Return $aWidthHeight EndFunc ;==>_StringInPixels ; #FUNCTION# ==================================================================================================================== ; Name ..........: _StringInPixels_gdip ; Description ...: Returns a pixel-accurate height and width for a given string using a GDI+ font, layout and format ; Syntax ........: _StringInPixels_gdip($hGraphic, $sString, $hFont, $tLayout, $hFormat) ; Parameters ....: $hGraphic - Handle to a GDI+ graphics object. ; $sString - The string to be measured. ; $hFont - Handle to a GDI+ font. ; $tLayout - A $tagGDIPRECTF structure that bounds the string. ; $hFormat - Handle to a GDI+ string format. ; Return values .: 2-row array. [0] is width in pixels; [1] is height in pixels. ; Author ........: Tim Curran; adapted from Pierre Arnaud's C# function ; Modified ......: ; Remarks .......: This much more efficient version is for use with GDI+ fonts ; Related .......: ; Link ..........: <https://www.codeproject.com/Articles/2118/Bypass-Graphics-MeasureString-limitations> ; Example .......: Example-StringInPixels.au3 ; =============================================================================================================================== #include <GDIPlus.au3> #include <GUIConstantsEx.au3> Func _StringInPixels_gdip($hGraphic, $sString, $hFont, $tLayout, $hFormat) Local $aRanges[2][2] = [[1]] $aRanges[1][0] = 0 ;Measure first char (0-based) $aRanges[1][1] = StringLen($sString) ;Region = String length _GDIPlus_GraphicsSetTextRenderingHint($hGraphic, $GDIP_TEXTRENDERINGHINT_CLEARTYPEGRIDFIT) _GDIPlus_StringFormatSetMeasurableCharacterRanges($hFormat, $aRanges) ;Set ranges Local $aRegions = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphic, $sString, $hFont, $tLayout, $hFormat) ;get array of regions Local $aBounds = _GDIPlus_RegionGetBounds($aRegions[1], $hGraphic) Local $aWidthHeight[2] = [$aBounds[2], $aBounds[3]] _GDIPlus_RegionDispose($aRegions[1]) Return $aWidthHeight EndFunc ;==>_StringInPixels_gdip  
      _StringInPixels.au3
      Example-StringInPixels.au3
    • anusha
      By anusha
      Hi I have jus started using auto-it . Please correct me if I'm wrong.
      I need to read data from an input in text box and search in excel file and return value in next column of matched cell on GUI.
      I have written below code but i cannot use variable which has data stored. it works only when search string is hard coded.
      Please help out.
       
      Example()
      Func Example()
      Local $GuiMain = GUICreate("EXCEL TEST", 399, 180) ;creates main GUI
      ;~ Local $idOK = GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
      Local $iWidthCell = 70
      Local $idLabel = GUICtrlCreateLabel("PART NUMBER", 10, 30, $iWidthCell,50)
      Local $RUN_1 = GUICtrlCreateButton("OK", 70, 70, 85, 25)
      Local $Input_1 = GUICtrlCreateInput("PART NUMBER", 100, 20, 120, 20)
      Local $sMenutext = GUICtrlRead($Input_1, 1)
      GUISetState(@SW_SHOW, $GuiMain)

          While 1
          $MSG = GUIGetMsg()
          Select
              Case $MSG = $GUI_EVENT_CLOSE
                  Exit
              Case $MSG = $RUN_1
                  Local $oAppl = _Excel_Open()

      Local $sFilePath1 = "D:\Anu_WorkFolder\Components.xlsx"
      Local $oWorkbook = _Excel_BookOpen($oAppl, $sFilePath1, Default, Default, True)
      Local $aResult = _Excel_RangeFind($oWorkbook, $sMenutext , Default, Default, $xlWhole)
    • Miliardsto
      By Miliardsto
      Hello.
      Drag option works only on parent window but as we can see on the parent gui is showed up child gui (on the right side with the color).
      Desired action is when we want to drag whole program we can also drag child gui and child gui will drag with parent gui.
      How to do this?
       
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> GUIRegisterMsg($WM_NCHITTEST, "_NCHITTEST") $hGUI = GUICreate("Test", 500, 500, -1, -1) $cButton_0 = GUICtrlCreateButton("Child 0", 10, 10, 80, 30) $cButton_1 = GUICtrlCreateButton("Child 1", 10, 50, 80, 30) $cButton_2 = GUICtrlCreateButton("Child 2", 10, 90, 80, 30) GUISetState(@SW_SHOW, $hGUI) ; guis Global $hChild_[3] Global $countGUI = UBound($hChild_) - 1 ;MsgBox("","",$countGUI) ; licznik dla GUI Global $gui = 0 $hChild_[0] = GUICreate("Child 0", 350, 300, 150, 0, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) GUISetBkColor(0xFF0000) GUISetState(@SW_SHOW, $hChild_[0]) $hChild_[1] = GUICreate("Child 1", 350, 300, 150, 0, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) GUISetBkColor(0x00FF00) GUISetState(@SW_HIDE, $hChild_[1]) $hChild_[2] = GUICreate("Child 2", 350, 300, 150, 0, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) GUISetBkColor(0x0000FF) GUISetState(@SW_HIDE, $hChild_[2]) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton_0 _All_Hide() GUISetState(@SW_SHOW, $hChild_[0]) $gui = 0 Case $cButton_1 _All_Hide() GUISetState(@SW_SHOW, $hChild_[1]) $gui = 1 Case $cButton_2 _All_Hide() GUISetState(@SW_SHOW, $hChild_[2]) $gui = 2 EndSwitch WEnd Func _All_Hide() GUISetState(@SW_HIDE, $hChild_[0]) GUISetState(@SW_HIDE, $hChild_[1]) GUISetState(@SW_HIDE, $hChild_[2]) EndFunc Func _NCHITTEST($hWnd, $uMsg, $wParam, $lParam) If $hWnd = $hGUI Then Local $aPos = WinGetPos($hWnd) If Abs(BitAND(BitShift($lParam, 16),0xFFFF)- $aPos[1]) < 500 Then Return $HTCAPTION EndIf Return $GUI_RUNDEFMSG EndFunc  
    • IAMK
      By IAMK
      Hello,
       
      I have a script which uses a GUI with two buttons. It gets shown and hidden., and pressing the buttons (including their hotkeys) highlights the button, making you able to press enter the next time.
      However, I don't want that.
       
      I've tried using WinActivate() to make enter do things on another program, but the enter is still tied to the AutoIT GUI (which still has the button highlighted).
       
      Here's the important part of my code:
      $MY_GUI = GUICreate("Check.exe", 400, 300, ((@DesktopWidth / 2) - 200), -500) WinSetOnTop($MY_GUI, "", 1) ;Keeps the window on the top. $Button1 = GUICtrlCreateButton("Pass (Ctrl+P)", 40, 250, 120, 40, $WS_GROUP) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Button2 = GUICtrlCreateButton("Fail (Ctrl+F)", 240, 250, 120, 40, $WS_GROUP) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $GUIText = GUICtrlCreateLabel("", 20, 10, 360, 230) GUICtrlSetFont(-1, 13, 400, 0, "MS Sans Serif") GUICtrlSetData($GUIText, Execute($stepMessage[$step])) $showGUI = "True" GUISetState(@SW_SHOW) While($showGUI = "True") $buttonPressed = GUIGetMsg() Switch $buttonPressed Case $Button1 ;Pass $pass = "True" $buttonPressed = 0 $showGUI = "False" GUISetState(@SW_HIDE) Case $Button2 ;Fail $buttonPressed = 0 $showGUI = "False" GUISetState(@SW_HIDE) While($message = "") $message = InputBox("Check.exe", "Please enter the reason the step failed." & @CRLF, "", "", 300, 200, ((@DesktopWidth / 2) - 150), -400) WEnd Return $message EndSwitch WEnd Local $pass = "False" ;Whether "Pass" or "Fail" was pressed. Local $failLog = xxxfunc($pass) ;Returns a message to log if the step failed. ##THIS CALLS THE CODE SNIPPET ABOVE## FileWrite($file, _Now() & ": Step " & $step & getStatus($pass) & "and took " & Ceiling(TimerDiff($timer) / 1000) & " seconds." & @CRLF) If($failLog <> "") Then FileWrite($file, "Logged comment: " & $failLog & @CRLF) EndIf WinActivate("[TITLE:ProgramName]") ;Hotkeys: HotKeySet("^{p}", "pressPass") HotKeySet("^{f}", "pressFail") Func pressPass() $buttonPressed = $Button1 EndFunc Func pressFail() $buttonPressed = $Button2 EndFunc  
      The GUI's button/hotkey pressing works correctly.
      The same WinActivate code works in another script of mine.
      Together, WinActivate is not take "Active" away from the GUI's last-pressed button. How do I fix this?
       
      Thank you in advance.
    • fatpig
      By fatpig
      Dear AutoIT Community.
      I am currently working on a program that will display lots of images in a scroll down GUI.
      I create the GUI based on the number of images, which works fine.
      But all images I place using GuiCtrlCreatePic above a threshold of around 32000 pixels (cant say exactly) are placed at negative locations and finally will reach 0 again
      and will then populate on top of the images placed there before.
      For $i = 1 To $Images[0] ; Get picture dimensions $hImage = _GDIPlus_ImageLoadFromFile($ImgRep & $Images[$i]) $iX = _GDIPlus_ImageGetWidth($hImage) $iY = _GDIPlus_ImageGetHeight($hImage) _GDIPlus_ImageDispose($hImage) ; Resize & place images in GUI $Pic[$i] = GUICtrlCreatePic($ImgRep & $Images[$i], $Spacer, Round($yPos, 0), $MaxImgWidth, $MaxImgWidth * ($iY / $iX)) $yPos = $yPos + $MaxImgWidth * ($iY / $iX) + $Spacer $log = $log & "|" & $yPos $currentlut = $Images[1] Next I have found a limit at 32767 pixels for some GUI elements when googling around.
      Can someone tell me how to circumvent that?
      thanks!
      cheers
      Felix