bazinga Posted September 3, 2013 Share Posted September 3, 2013 (edited) Hello guys, as the title says, i have a problem with array, combobox and the IsPressed function. i try to pass the selected item to the _IsPressed function but its not working the way i do it. a little hint what to search for or a code snippet to learn from would be really nice. thanks in advance. Global $Array[3][2] = [ ["X", 58], ["C", 43], ["V", 56] ] $Combo = GUICtrlCreateCombo($Array[0][0], 130, 100, 50, 20, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) For $i = 0 To Ubound($Array) - 1 GUICtrlSetData($Combo, $Array[$i][0], True) Next $Key = GUICtrlRead($Combo) While 1 If _IsPressed($Key) Then Do Send ("{0}") Until Not _IsPressed($Key) EndIf WEnd Edited September 3, 2013 by bazinga Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted September 3, 2013 Moderators Solution Share Posted September 3, 2013 bazinga,I would do something like this:expandcollapse popup#include <GUIConstantsEx.au3> #include <ComboConstants.au3> #include <Array.au3> #include <Misc.au3> Global $aKeys[3][2] = [ ["X", 58], ["C", 43], ["V", 56] ] $hDLL = DllOpen("user32.dll") ; You are calling _IsPressed in a loop - so use the DLL handle $iKeyCode = 0 ; You need to declare this $hGUI = GUICreate("Test", 500, 500) ; Do not set a default value in the combo - then you react to the first selection $cCombo = GUICtrlCreateCombo("", 130, 100, 50, 20, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) For $i = 0 To Ubound($aKeys) - 1 GUICtrlSetData($cCombo, $aKeys[$i][0]) Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE DllClose($hDLL) Exit Case $cCombo ; Combo selection changed - get index of new selection $iIndex = _ArraySearch($aKeys, GUICtrlRead($cCombo)) ; Set keycode to the correct vlaue $iKeyCode = $aKeys[$iIndex][1] EndSwitch If _IsPressed($iKeyCode, $hDLL) Then Do Send ("0") ; No need for {} Until Not _IsPressed($iKeyCode, $hDLL) EndIf WEndAll clear? M23 bazinga 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
FireFox Posted September 3, 2013 Share Posted September 3, 2013 The _IsPressed function takes hexadecimal numbers, 58 <> 0x58. Either turn your integers into strings or put directly the hexadecimal numbers in your array. Br, FireFox. Link to comment Share on other sites More sharing options...
bazinga Posted September 3, 2013 Author Share Posted September 3, 2013 oh yea, its working thanks alot Melba23! well, one more question: why do i have to use "user32.dll" when using _IsPressed in a loop? any disadvantages if i dont do? i ask, because i cant see a difference :S Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 3, 2013 Moderators Share Posted September 3, 2013 (edited) bazinga,If you do not open the DLL and use the handle in the function call you are opening and closing the DLL each time. In this case there is not a huge penalty as the user32 DLL is almost certainly open anyway - but the principle still holds that it is better to get a handle and use it if you call the function in a loop. M23 Edited September 3, 2013 by Melba23 Typo Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
bazinga Posted September 3, 2013 Author Share Posted September 3, 2013 aah ok. thank you very much Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now