Valnurat

2 small issues.

7 posts in this topic

#1 ·  Posted

I have combobox, ListControl and a button.

#include <ComboConstants.au3>
#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#Include <AD.au3>
#include <Array.au3>

;Opt('MustDeclareVars', 1)

Global $aResult[0][2]
Local $aNames[4] = ["DKSO","DKKO","SELU","SEES"]
Local $hGUI = GUICreate("Find Computer Owner", 300, 200)
; Create a combobox control.
Local $idComboBox = GUICtrlCreateCombo("", 2, 2, 296, 20, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL,  $CBS_SORT)) ;$WS_VSCROLL
Local $idMylist = GUICtrlCreateList("", 2, 24, 296, 140)
GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling
Local $idClos = GUICtrlCreateButton("Close", 210, 170, 85, 25)
_AD_Open()
_GUICtrlComboBox_BeginUpdate($idComboBox)
Local $sFill = ""
For $i = 0 to UBound($aNames) -1
    Local $aUserInfo = _AD_GetObjectsInOU("OU=company,DC=ad,DC=company,DC=org","(&(objectCategory=Person)(objectclass=user)(sAMAccountName=" & $aNames[$i] & "*))","","distinguishedName,cn")
    if @error Then
        MsgBox(0,@error,@extended)
        Exit
    EndIf
    For $x = $aUserInfo[0][0] To 1 Step -1
        If $aUserInfo[$x][0] = "" Or StringInStr($aUserInfo[$x][0], "Resources") > 0 Or StringInStr($aUserInfo[$x][0], "Leavers") > 0 Or StringInStr($aUserInfo[$x][0], "Administration") > 0 Then
            _ArrayDelete($aUserInfo, $x)
        EndIf
    Next
    _ArrayConcatenate($aResult, $aUserInfo, 1)
Next
_ArrayDisplay($aResult, 'AD ' & UBound($aResult))
for $i = 0 To UBound($aResult) -1
    If $aResult[$i][0] <> "" Then
        $sFill &= $aResult[$i][1] & "|"
    EndIf
Next
$sFill = StringTrimRight($sFill, 1)
GUICtrlSetData($idComboBox, $sFill, "")
_GUICtrlComboBox_EndUpdate($idComboBox)
   ; Display the GUI.
GUISetState(@SW_SHOW, $hGUI)
Local $sComboRead = ""
; Loop until the user exits.
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)
            GUICtrlSetData($idMylist, "|")
            Local $aComputerOwner = _AD_GetObjectsInOU("OU=company,DC=AD,DC=company,DC=ORG","(&(objectclass=computer)(managedby=" & $aResult[$iIdx][0] & "))",Default,"cn")
            If $aComputerOwner <> "" Then
                For $i = 1 to $aComputerOwner[0]
                    GUICtrlSetData($idMylist, $aComputerOwner[$i] & "|")
                Next
            Else
                GUICtrlSetData($idMylist, "No computer|")
            EndIf
    EndSwitch
WEnd
_AD_Close()

; Delete the previous GUI and all controls.
GUIDelete($hGUI)

How can I, when keypressed, change the name in the combobox runtime instead of using the mouse to scroll down to the name I want?

How can I dobbelt click with mouse on the computername in my ListControl to start another application?


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites



#2 ·  Posted

Is there a nice soul who could help me?


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites

#3 ·  Posted

@Valnurat you have been around long enough to know you need to wait 24 hours before bumping your thread.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#4 ·  Posted

Can you provide a different working example that illustrates the issue without the AD dependency?  You might get a quicker response.

Share this post


Link to post
Share on other sites

#5 ·  Posted

As requested.

#include <WindowsConstants.au3>
#include <ComboConstants.au3>
#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#Include <AD.au3>
#include <Array.au3>

Opt('MustDeclareVars', 1)

Global $aResult[0][2]
Local $hGUI = GUICreate("Find Computer Owner", 300, 200)
; Create a combobox control.
Local $idComboBox = GUICtrlCreateCombo("", 2, 2, 296, 20, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL, $WS_VSCROLL, $CBS_SORT)) ;$WS_VSCROLL
Local $idMylist = GUICtrlCreateList("", 2, 24, 296, 140)
GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling
Local $idClos = GUICtrlCreateButton("Close", 210, 170, 85, 25)
_GUICtrlComboBox_BeginUpdate($idComboBox)
Local $sFill = ""
$sFill = "Aardwolf|Adouri|African black crake|African buffalo|African bush squirrel|African clawless otter|African darter|African elephant|African fish eagle"
GUICtrlSetData($idComboBox, $sFill, "")
_GUICtrlComboBox_EndUpdate($idComboBox)
   ; Display the GUI.
GUISetState(@SW_SHOW, $hGUI)
Local $sComboRead = ""
; Loop until the user exits.
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $idClos
            ExitLoop
        Case $idComboBox
            $sComboRead = GUICtrlRead($idComboBox)
            MsgBox(0,"",$sComboRead)
    EndSwitch
WEnd

; Delete the previous GUI and all controls.
GUIDelete($hGUI)

 


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites

#6 ·  Posted

Does any kind soul have solution?


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites

#7 ·  Posted

If the combobox control is focused/selected, the arrow keys already seem to work.  Do you want the keys to always change the selection whether the control has focus or not?  

If so, I think you can either do so with a custom message handler, by employing GuiSetAccelerators and dummy controls, or using HotKeys.  For the double-click on the listview, I think you're only option is to create a custom message handler.  

The _GUICtrlListView_Create help file example has a working example of how to handle the double click of a listview control.  There is a lot of extra (commented out) code in the WM_NOTIFY function (which is the custom message handler), but may be worth having a look to further understand message events. The piece that is relevant to the double click action/message is where it says Case $NM_DBLCLK.  I pasted in the example below, but removed the other messages/cases and commented out lines.  Double-clicking an item in the listview prints debug info into the console of the SciTE editor.

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

Global $g_hListView

Example()

Func Example()
    Local $hGUI, $hImage
    $hGUI = GUICreate("(UDF Created) ListView Create", 400, 300)

    $g_hListView = _GUICtrlListView_Create($hGUI, "", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($g_hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_hListView, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_hListView, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_hListView, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($g_hListView, $hImage, 1)

    ; Add columns
    _GUICtrlListView_InsertColumn($g_hListView, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($g_hListView, 1, "Column 2", 100)
    _GUICtrlListView_InsertColumn($g_hListView, 2, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($g_hListView, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($g_hListView, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($g_hListView, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($g_hListView, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($g_hListView, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($g_hListView, "Row 3: Col 1", 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
    ; Local $tBuffer
    $hWndListView = $g_hListView
    If Not IsHWnd($g_hListView) Then $hWndListView = GUICtrlGetHandle($g_hListView)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint

Take not that the custom message handler only deals with handles and not AutoIt control IDs.  In the example, the WM_COMMAND function ensures the control handle is used, so no need or worry to have to change your ListView from the Native control creation func to the UDF version.

$hWndListView = $g_hListView
If Not IsHWnd($g_hListView) Then $hWndListView = GUICtrlGetHandle($g_hListView)


Try some things out and let us know if/when you get stuck.

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

    • X_xkijux_x
      By X_xkijux_x
      Ok so im using this program. clarify for school. I would like to have a program that takes every word i type in microsoft word and searches on it in claryfi. is this possible. I would like to have the program not stopping me from typing more after that word. Like when i type a word it auto search it on clarify without making me stop typing and if i want to change i can do that and if im fine that word i can just keep typing and it will search after the next word. 
    • Miliardsto
      By Miliardsto
      Is this possible to make program works like in diagram? There is so much encryption methods and UDFs are they give security? If the $Address will be crypted with some encryption algorithm could be possible to get the value of $Address in easy way? Of course We know its easy too look into autoit code and get value of variable and so We dont want to anyone see $Address value - there are functions Could func1.au3, func2.au3.. be for example func1.php or other type of file? As we know .php files are unnable to see. For example func1 would be read by FileRead() and then Execute() Is this generally possible to do?
      Will it give secure?
      What do you think about? Maybe there is something wrong in this concept or missed.

    • JaredStroeb
      By JaredStroeb
      I need to open an application and send it keys in Session 0.  I have exe's working locally, I can see the application open in session 0 through interactive services, but my send commands do not go to the application.  The following article running-autoit-session-0, directs me to use ControlSend() however my application has no controls that can be identified by AutoIt v3 Window Info.  Get All Windows Controls also returned nothing for the application's handle.  
      What are my options?  
      Can this be done with AutoIt?
      Is there a different "relatively simple" library/tool to use? (I am familiar with C# if there is a viable library there )

       
    • nassausky
      By nassausky
      Hey all,
      Has anyone created any queries for youtube? I was thinking it might be something like this but can't quite figure it out:
      $oIE = _IECreateEmbedded() _IENavigate($oIE,"https://www.youtube.com") Local $oForms = _IETagNameGetCollection($oIE, "form") Local $sTxt = "" For $oForm In $oForms If $oForm.id = "masthead-search" Then $oInputs = _IETagNameGetCollection($oIE, "input") For $oInput In $oInputs If $oInput.id = "masthead-search-term" Then _IEFormElementSetValue($oInput, "cards") _IEFormSubmit($oForm) EndIf Next EndIf Next  
    • Skysnake
      By Skysnake
      Scite comes up occasional, almost incidentally, in some support topics.  I have not found a "Scite" topic in the forums, so this is where I will start.  I have recently been using Scite intensively, specifically with a large project and I have certain issues.  I know that Scite is not an AutoIt product, but it is so closely integrated to the core release that it makes sense to raise issues and request support here.  If this is not the right please refer me to the right forum.
      Thx
       
      Skysnake