Jump to content
Sign in to follow this  

A shortlist of short List questions

Recommended Posts


Been using GUICtrlCreateList for the first time in the last few days and am wondering for how many currently perceived shortcomings I am still to blame... ;)

Been scanning some of the special settings here and there, but currently still wondering about these...

Even "yes" or "no" can be helpful. More is welcome if it saves me some hours  :)

1) When wanting to hilite a List item with the help of GUICtrlSetData ( $myList, data, $hiliteThisItem ), my impression is that this is not case sensitive? If not, can this be set to be so? [solved, if *not* using $LBS_EXTENDEDSEL only?]

2) Is it possible to have right-clicking an item also immediately making it the active item (highlight it)...?

3) Is manually dragging items for custom sorting possible?

4) While using my scroll wheel inside a List, I've been hearing some beeps, as if it wanted to tell me when I got to the edge of either end. However, it does not seem to work consistently and I don't want these sounds anyway. Are they from AutoIt and can I disable them?

5) Is it possible to multi-select items?  (à la Ctrl-click) [solved with $LBS_EXTENDEDSEL]

6) [non-List question] Is it possible that using the Return key inside a GUICtrlCreateInput field activates a Function?

Thanks for any tips!

Edited by Guy_

Share this post

Link to post
Share on other sites

5) Is it possible to multi-select items?  (à la Ctrl-click)



EDIT: normal link was broken, so link only in TXT way ... (new cripled forum is really hell :-( )

Edited by Zedna
  • Like 1

Share this post

Link to post
Share on other sites

Thanks & sorry..., there *was* a huge oversight on my part... :>

(5) is kinda solved now by including $LBS_EXTENDEDSEL


I had solved (1) by using ...

$_idx = _GUICtrlListBox_FindString ($idList, $newItem, 1) ; find item (case sens.)
_GUICtrlListBox_SetCurSel(($idList, $_idx)

But after adding $LBS_EXTENDEDSEL the above scrollTo & hilite code does not work anymore... (and neither does the 'Default' parameter in GUICtrlSetData)

I figured by prepending a "Select none" to the prev. 2 lines it might work again, but it doesn't...

_GUICtrlListBox_SelectString ( $idList, "")

Is that a known limitation, or do I need to unset something else first...?

Edited by Guy_

Share this post

Link to post
Share on other sites

2) Yes. in the same manner as point 3) if not in other ways.

3) See Drag-and-drop reordering listbox. Note that subclassing is much easier implemented with the four functions SetWindowSubclass, GetWindowSubclass, RemoveWindowSubclass and DefSubclassProc (all implemented in WinAPIShellEx.au3) than with _WinAPI_SetWindowLong.

4) I have never heard beeps when I have used the scrool wheel in a listbox. I think it has something to do with your specific code.

Have you looked at GUICtrlCreateListView and the GuiListView UDF? A listview is an advanced version of a listbox. Because a listview natively supports more functionality than a listbox most of your questions are easier to implement for a listview than for a listbox. Also the forums contains many more questions/answers and code examples for listviews than for listboxes. GUIListViewEx is a very popular example.

6) This can be implemented with GUISetAccelerators.

Edited by LarsJ
  • Like 1

Share this post

Link to post
Share on other sites

Thank you Larsj! Very helpful  :)

Have you looked at GUICtrlCreateListView and the GuiListView UDF?

Just discovered it. When I looked at a Listview example yesterday it reminded me of Excel or _ArrayDisplay() and I was like "No, that's not what I need at the moment." But I will look at the UDF to see if it can be a simple box too.


6) This can be implemented with GUISetAccelerators.

I was figuring as much when running across that after my opening post. Good to have confirmation.

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

    • XinYoung
      By XinYoung
      For fun, I'm building an app that opens a webpage and refreshes it every 30 seconds.
      But once the script performs _IEAction($oIE, "refresh"), the GUI closes.
      Any help is appreciated.

      #include <ButtonConstants.au3>
      #include <EditConstants.au3>
      #include <GUIConstantsEx.au3>
      #include <StaticConstants.au3>
      #include <WindowsConstants.au3>
      #include <WinAPIFiles.au3>
      #include <Array.au3>
      #include <File.au3>
      #include <Excel.au3>
      #include <DateTimeConstants.au3>
      #include <MsgBoxConstants.au3>
      #include <WinAPIShellEx.au3>
      #include <MsgBoxConstants.au3>
      #include <Date.au3>
      #include <ComboConstants.au3>
      #include <guimenu.au3>
      #include <IE.au3>
      HotKeySet("{F4}", "_Exit")
      ;Open the file(s) in the selected folder
      $extension = ".txt"
      $app2openWith = @SystemDir & "\notepad.exe"
      Func Begin()
          Global $loopTrick = 0
          #Region ### START Koda GUI section ### Form=c:\users\mchu\downloads\autoit\my code\form1.kxf
          Global $UI = GUICreate("Hit Em Up!", 256, 113, -1, -1)
          $menu = _GUICtrlMenu_GetSystemMenu($UI)
          _GUICtrlMenu_EnableMenuItem($menu, $SC_CLOSE, 1, False)
          Global $url = GUICtrlCreateInput("https://www.youtube.com/watch?v=dQw4w9WgXcQ", 81, 8, 160, 21)
          $Label1 = GUICtrlCreateLabel("Target:", 16, 8, 55, 17)
          GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
          GUICtrlSetColor(-1, 0x00FF00)
          Global $StartBut = GUICtrlCreateButton("Start", 16, 40, 67, 25)
          GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif")
          GUICtrlSetBkColor(-1, 0x008000)
          $Label2 = GUICtrlCreateLabel("(Press F4 to Exit)", 96, 40, 8000, 17)
          GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
          GUICtrlSetColor(-1, 0x00FF00)
          #EndRegion ### END Koda GUI section ###
          While 1
              $UIfunc = GUIGetMsg()
                  Case $UIfunc = $GUI_EVENT_CLOSE
                  Case $UIfunc = $StartBut
                      If GUICtrlRead($url) = "" Then
                          MsgBox(48, "Um...", "Give me a target you idiot.")
                          GUICtrlSetState($url, $GUI_DISABLE)
                          GUICtrlSetState($StartBut, $GUI_DISABLE)
      EndFunc   ;==>Begin
      Func Start()
          If $loopTrick = 0 Then
              Global $oIE = _IECreate(GUICtrlRead($url))
          ElseIf $loopTrick = 1 Then
              _IEAction($oIE, "refresh")
      EndFunc   ;==>Start
      Func Again()
          $loopTrick = 1
      EndFunc   ;==>Again
      Func _Exit()
      EndFunc   ;==>_Exit
    • 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.
    • kcvinu
      By kcvinu
      Hi all,
      I am playing with _GUICtrlButton_Create function. How can i change this button's (or the entire form's) font ?. The in-built GUICtrlSetFont function is not working even when i convert the control handle to control ID with _WinAPI_GetDlgCtrlID ( ) function.  Do i need to use CreateFont api finction and send WM_SETFONT message ? Or is there any other easy and safe ways to do this ?. Thanks in advance.
      Note : This window is created by CreateWindowEx function, not by GUICreate function. 
    • Jake_s
      By Jake_s
      Hi All, 
      I am a begginer in auto it. I am trying to build simple gui that will show me if for example notepad.exe process is currently running on the system. I have built something like this, but when I execute it shows me message boxes, but I want the results to show in gui. If you can help me start with this.
        #include <MsgBoxConstants.au3>
      #include <GUIConstantsEx.au3>


      Func ActiveProcess()

             If ProcessExists("wuauclt.exe") Then
       MsgBox($MB_SYSTEMMODAL, "", "Windows Upates are running")
       MsgBox($MB_SYSTEMMODAL, "", "Windows Updates are not running")


               If ProcessExists("notepad.exe") Then
      MsgBox($MB_SYSTEMMODAL, "", "Notepad is running")
      MsgBox($MB_SYSTEMMODAL, "", "Notepad is not running")

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.