Jump to content
Valnurat

ComboBox keypressed

Recommended Posts

Valnurat

I have a ComboBox and I want, when I start writting in it, that it will show me what is the first in the list.

Like, is I start writting:

"pe" it  should show me "peter" if that is the first in the list.

How can I do that?

 

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $idClos
            ExitLoop
        Case $idComboBox
            $sComboRead = GUICtrlRead($idComboBox)
            Local $iIdx = _ArraySearch($aResult,$sComboRead,0,0,0,0,1,1)
            Local $aComputerOwner = _AD_GetObjectsInOU("OU=al,DC=AD,DC=AL,DC=ORG","(&(objectclass=computer)(managedby=" & $aResult[$iIdx][0] & "))",Default,"cn")
            _ArrayDelete($aComputerOwner,0)
            _GUICtrlListView_SetItemCount($idMylist,UBound($aComputerOwner))
            If IsArray($aComputerOwner) Then
                For $i = 0 To UBound($aComputerOwner) - 1
                    GUICtrlCreateListViewItem($aComputerOwner[$i], $idMylist)
                Next
            Else
                GUICtrlSetData($idMylist, "No computer|")
            EndIf
    EndSwitch
WEnd

 


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites
Zedna

Just BIG speed optimization of your script --> not needed _ArrayDelete():

;~  Local $aComputerOwner = _AD_GetObjectsInOU("OU=al,DC=AD,DC=AL,DC=ORG","(&(objectclass=computer)(managedby=" & $aResult[$iIdx][0] & "))",Default,"cn")
;~             _ArrayDelete($aComputerOwner,0)
;~             _GUICtrlListView_SetItemCount($idMylist,UBound($aComputerOwner))
;~             If IsArray($aComputerOwner) Then
;~                 For $i = 0 To UBound($aComputerOwner) - 1
;~                     GUICtrlCreateListViewItem($aComputerOwner[$i], $idMylist)
;~                 Next
;~             Else
;~                 GUICtrlSetData($idMylist, "No computer|")
;~             EndIf
            
 Local $aComputerOwner = _AD_GetObjectsInOU("OU=al,DC=AD,DC=AL,DC=ORG","(&(objectclass=computer)(managedby=" & $aResult[$iIdx][0] & "))",Default,"cn")
            _GUICtrlListView_SetItemCount($idMylist,UBound($aComputerOwner)-1)
            If IsArray($aComputerOwner) Then
                For $i = 1 To UBound($aComputerOwner) - 1 ; skip first item with index 0 (number of rows in array)
                    GUICtrlCreateListViewItem($aComputerOwner[$i], $idMylist)
                Next
            Else
                GUICtrlSetData($idMylist, "No computer|")
            EndIf

 

Share this post


Link to post
Share on other sites
Valnurat

Great. Thank you. How can I use "Enter" on my ComboBox as I do with my mouse?


Yours sincerely

Kenneth.

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

    • SharpDressedMan
      By SharpDressedMan
      Hello,
      Is there any way to check for validity of a pointer to a DllStruct ?
      In the above code, a DllStruct is created from an invalid pointer. How to prevent from doing this ?
      local $tStruct = DllStructCreate("int i") DllStructSetData($tStruct, "i", 123) local $pStruct = DllStructGetPtr($tStruct) $tStruct = 0 ; destroy DllStruct ==> $pStruct becomes invalid ; how to check here for validity of $pStruct and prevent from doing the following ? $tStruct = DllStructCreate("int i", $pStruct) ; create DllStruct from invalid pointer... MsgBox(0, @ScriptName, @error) ; displays '0' : invalid pointer is not detected by DllStructCreate() MsgBox(0, @ScriptName, IsDllStruct($tStruct)) ; displays '1' : tStruct is assumed as a valid DllStruct object, which is not Thanks for help
    • nooneclose
      By nooneclose
      I need to send a string of text to this popup and click on the ok button to save it.
      Here is the code I have so far:
      ;Start IE Sleep(7000) $oIE = _IECreate("http://www.google.com") Sleep(500) _IELoadWait($oIE) $hIE = _IEPropertyGet($oIE, "hwnd") ; Get Handle of the IE window Sleep(500) WinSetState($hIE, "", @SW_MAXIMIZE) ;Wait for a browser page load to complete Sleep(3000) _IENavigate($oIE, "https://properURL.com") Sleep(8000) _IELoadWait($oIE) ;Attach to a browser control embedded in another window $oIE = _IEAttach("https://"properURL.com", url") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $oIE = ' & $oIE & @CRLF & '>Error code: ' & @error & ' Extended code: 0x' & Hex(@extended) & @CRLF) ;### Debug Console Sleep(2000) ;Get the title of the webpage ;Local $wTitle = _IEPropertyGet($oIE, "title") ;MsgBox($MB_SYSTEMMODAL, "Webpage title:", $wTitle) ;Clicks the new button Sleep(3000) _IEAction($nWorkOrderB, "focus") _IEAction($nWorkOrderB, "click") Sleep(5000) ;Store the Element names where the important data will be sent ;Store the long description button Local $wLongDButton = _IEGetObjById($oIE, "m65d795a4-img") ;Store the long Description field id Local $wComments = _IEGetObjById($oIE, "ma6499a9c-rte_iframe") ;Store the ok button id that is in the long description Local $wCommOk = _IEGetObjById($oIE, "m74031266-pb") ;******************************************************************************* ; Send the stored data to the proper field ;******************************************************************************* ;Click the long description button Sleep(300) _IEAction($wLongDButton, "focus") _IEAction($wLongDButton, "click") Sleep(300) ;Sends the Comments Sleep(500) _IEAction($wComments, "focus") _IEAction($wComments, "click") Sleep(500) _IEFormElementSetValue($wComments, "hello darkness my old friend") ;Click the ok button Sleep(500) _IEAction($wCommOk, "focus") _IEAction($wCommOk, "click") Sleep(500)  
      Here is the popup:

    • yasha
      By yasha
      i want am trying to select a nimber to run a program and then select where to save the excel result at before hand
      the problem is that it does not save in the folder i want but the folder before any solutions
      #.................
      $sFolder = ""
          ; Create a constant variable in Local scope of the message to display in FileSelectFolder.
          Local Const $sMessage = "Select a folder"
          ; Display an open dialog to select a file.
          $sFileSelectFolder = FileSelectFolder($sMessage, $sFolder)
          If @error Then
              ; Display the error message.
              MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.")
          Else
              ; Display the selected folder.
              MsgBox($MB_SYSTEMMODAL, "", "You chose the following folder:" & @CRLF & $sFileSelectFolder)
          EndIf
      .......
      ........
      $oExcel = ObjCreate("Excel.Application")                   ; Create an Excel Object
      $oExcel.Visible = 1                                        ; Let Excel show itself
      $oExcel.Workbooks.Open("J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\"& $YY & $MM & $DD & " ORDER.xls",0)
      $oExcel.ActiveWorkbook.Saveas ( $sFileSelectFolder,""& $YY & $MM & $DD & " ORDER.xlsx", 1)
      $oExcel.ActiveWorkBook.Close
      $oExcel.Quit
      i only want to save it as ddmmyy order inside documents but it saves in libraries as documents ddmmyy order.
    • vynce1982
      By vynce1982
      I am trying to make a simple installer script for my understanding.  I would just like to understand how to deal with multiple possible windows. In the case of installing VLC, I might get a window saying VLC is already installed. I have also tried a switch with no luck.  I would just like to understand some methods for dealing with the possible existence of unexpected windows. 
       
      ;INSTALL VLC VIEWER
      Run(@ScriptDir & '\bin\VLCViewer_2.2.4_3.EXE')
      AutoItSetOption('MouseCoordMode', 0)
      sleep(4000)
      WinWait("VLC Viewer 2.2.4")

           ; this window will pop up if vlc is already installed
          If WinExists( "VLC Viewer 2.2.4", "VLC 2.2.4 Already Installed") Then
                ConsoleWrite ("already installed")
                WinActivate ('VLC Viewer 2.2.4','Already Installed')
                MouseClick ('primary', 93, 83, 1, 0)
                
          EndIf
       
            ; this window will pop up if installer finishes sucessfully
           If WinExists( "VLC Viewer 2.2.4", "VLC Viewer 2.2.4 Installed") Then 
                ConsoleWrite ("already installed")
                WinActivate ('VLC Viewer 2.2.4','VlC Installed')
                MouseClick ('primary', 93, 83, 1, 0)
         EndIf

       
       
       
    • TrashBoat
      By TrashBoat
      After i create my GUI i cant set the color anymore.  help?
      $hBarGUI1 = GUICreate("", 50, 1, 91, 188, 0x80000000, 0x08000080) $g = GUICtrlCreateLabel("", 1, 1, 1, 1) GUICtrlSetBkColor(-1, $color) GUISetBkColor($color, $hBarGUI1) WinSetTrans($hBarGUI1, '', 0) WinSetState($hBarGUI1, '', @SW_SHOWNOACTIVATE) WinMove($hBarGUI1, '', -1, -1) WinSetTrans($hBarGUI1, '', 254) WinSetOnTop($hBarGUI1, "", 1) I see that my problem has to do something with WinSetState but have no clue how to fix it already tried to set it to @SW_UNLOCK and @SW_SHOWNORMAL.
      @swa
×