Jump to content

Skampp

Members
  • Posts

    4
  • Joined

  • Last visited

About Skampp

  • Birthday 04/28/1971

Skampp's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Dear Community, I am attempting to search for particular lines that begin with a square bracket, such as: [19:05:23] Frankie Say Relax But of course this is not working... If $c > 1 And StringRegExp($fArray[$x], '[') = 1 Then ...do stuff Any ideas what is the proper way? Thanks in advance!
  2. That's brilliant, thanks! I'll try that today and see where it lands me. I appreciate your reply.
  3. Hi All, I have a listbox that has a context menu associated with it. When I right-click on the listbox the context menu pops up as expected. But I would like for the list item under the cursor to be selected, so that my context menu can take action on that item (such as "remove item"). I have culled my script down to the pertinent parts I think. Can someone give me a pointer in the right direction on how to select / activate a list item under the cursor? Please overlook my #region definitions. It drives most people mad but it does help me. #region Includes and Constants #include <GUIListBox.au3> #include <WindowsConstants.au3> #endregion Includes and Constants #region GUI Scaling Local $hWidth = 615 Local $hHeight = 438 Local $hTop = (@DesktopHeight - 40 - $hHeight) / 2 Local $hLeft = (@DesktopWidth - $hWidth) / 2 #endregion #region GUI section Local $iTitle = "User Configuration Applet" Local $hGUI = GUICreate($iTitle, $hWidth, $hHeight, $hLeft, $hTop,BitOR($GUI_SS_Default_GUI, $WS_SIZEBOX, $WS_MAXIMIZEBOX)) Local $tQuestion = GUICtrlCreateLabel("When I right-click in the listbox I would like the user below it to be selected but I'm not sure how.",5,5) Local $hUsers = GUICtrlCreateList("", 16, 245, 227, 175) _GUICtrlListBox_AddString($hUsers,"Joe Mama") _GUICtrlListBox_AddString($hUsers,"John Public") _GUICtrlListBox_AddString($hUsers,"Jane Doe") _GUICtrlListBox_EndUpdate($hUsers) Local $ContextMenuUsers = GUICtrlCreateContextMenu($hUsers) Local $ContextRemove = GUICtrlCreateMenuItem("Remove User",$ContextMenuUsers) GUISetState(@SW_SHOW) #endregion #region Monitor the GUI While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ContextRemove MsgBox(0,"User to remove","Need to have the user selected...") EndSwitch WEnd #endregion
  4. I know this post is a little bit old but I ran into the same issue and thought I'd share. Rather than having to recycle my code, I wrote this. --Skampp ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ListBoxToArray ; Description ...: Creates a 1-dimensional 0-based array from a listbox ; Syntax ........: _ListBoxToArray($iListBox, $iListBoxNumber) ; Parameters ....: $iListBox - Control ID of the ListBox Control ; $iListBoxNumber - Instance Number of the ListBox Control ; Return values .: $iReturnName - Array containing the items in the ListBox ; Author ........: Skampp ; Modified ......: ; Remarks .......: This may exist elsewhere but I could not find it. Requires <GUIListBox.au3> ; Related .......: _GUICtrlListBox_GetCount, _GUICtrlListBox_GetText, ControlGetHandle ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _ListBoxToArray($iListBox, $iListBoxNumber) Local $iReturnName[100] ;maximum realistic number of items for a listbox $cC = 1 ;counter $iMax = _GUICtrlListBox_GetCount($iListBox) ;number of items in the listbox ReDim $iReturnName[$iMax + 1] ;resize the array Local $hListBoxHandle = ControlGetHandle($iTitle, "", "[CLASS:ListBox;INSTANCE:" & $iListBoxNumber & "]") ;get the control handle $iReturnName[0] = $iMax ;store the array size in [0] For $cC = 0 To $iMax - 1 ;start counter $iReturnName[$cC + 1] = _GUICtrlListBox_GetText($hListBoxHandle, $cC) ;populate array from listbox Next Return $iReturnName ;return the array EndFunc ;==>_ListBoxToArray
×
×
  • Create New...