rajeshwaran Posted August 30, 2010 Share Posted August 30, 2010 In linux command prompt, if you press UP/DOWN keys it will display the previous commands which are executed.Like that, I am also trying to do the same with Input Box.But I do not know, how to handle UP/DOWN keys for InputBox. From AutoIt help for the function "GUIRegisterMsg" I came to know the below"Some controls consume internally specific Windows Message ID, so registrating them will have no effect, e.g; WM_CHAR, WM_KEYDOWN, WM_KEYUP are consumed by an edit control."Any other way to resolve this problem ? Link to comment Share on other sites More sharing options...
Tvern Posted August 30, 2010 Share Posted August 30, 2010 I don't think you can do this with an actual inputbox as that's a blocking function, but you caould make your own inputbox function with the functionality. Here's an example that should be editable to how you want it: expandcollapse popup#include<array.au3> Global $aCommands[5] = ["command1","command2","command3","command4","command5"] ;this is just some fake history for testing Global $iHistory = UBound($aCommands) ;keeps track of the currently displayed history item Global $hWnd = GUICreate("test",420) Global $CtrlInput = GUICtrlCreateInput("",10,10,400,20) GUICtrlCreateEdit("This edit does nothing.",10,40,400,200) Global $hInput = ControlGetHandle($hWnd,"",$CtrlInput) GUISetState() HotKeySet("{Up}","_PrevCMD") HotKeySet("{Down}","_NextCMD") While 1 Switch GUIGetMsg() Case -3 Exit Case $CtrlInput _RunCommand() GUICtrlSetData($CtrlInput,"") _ArrayDisplay($aCommands) EndSwitch WEnd Func _RunCommand() $sCMD = GUICtrlRead($CtrlInput) _ArrayPush($aCommands,$sCMD) ;using this as a limited history, _Arrayadd can be used as unlimited history until max arraysize is reached. $iHistory = UBound($aCommands) ;reset the history position ;execute command EndFunc Func _PrevCMD() ;go to command executed before the curerntly displaying one If ControlGetHandle($hWnd,"",ControlGetFocus($hWnd)) <> $hInput Then Return ;only make it work when the input is focussed If $iHistory = 0 Then $iHistory = UBound($aCommands) - 1 ;once the end is reached it goes back to the start Else $iHistory -= 1 EndIf GUICtrlSetData($CtrlInput,$aCommands[$iHistory]) EndFunc Func _NextCMD() ;go to the command executed after the currently displaying one If ControlGetHandle($hWnd,"",ControlGetFocus($hWnd)) <> $hInput Then Return If $iHistory >= UBound($aCommands) - 1 Then $iHistory = 0 ;once the start is reached it goes back to the end Else $iHistory += 1 EndIf GUICtrlSetData($CtrlInput,$aCommands[$iHistory]) EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 30, 2010 Moderators Share Posted August 30, 2010 rajeshwaran, No doubt there is a sexy way to do it with GUIRegisterMsg, but you can also do it like this: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <Misc.au3> Global $aInputs[9], $iIndex = 0 $dll = DllOpen("user32.dll") $hGUI = GUICreate("Test", 500, 500) $hInput = GUICtrlCreateInput("", 10, 10, 200, 20) $hButton = GUICtrlCreateButton("Input", 10, 50, 80, 30) $hLabel = GUICtrlCreateLabel("", 10, 100, 400, 40) GUICtrlSetFont(-1, 18) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE DllClose($dll) Exit Case $hButton If GUICtrlRead($hInput) <> "" Then GUICtrlSetData($hLabel, GUICtrlRead($hInput)) _ArrayPush($aInputs, GUICtrlRead($hInput), 1) EndIf EndSwitch If _IsPressed("28", $dll) = 1 Then ; DOWN Arrow If $iIndex > 0 Then $iIndex -= 1 GUICtrlSetData($hInput, $aInputs[$iIndex]) EndIf While _IsPressed("28", $dll) = 1 Sleep(10) WEnd EndIf If _IsPressed("26", $dll) = 1 Then ; UP Arrow If $iIndex < 9 Then If $aInputs[$iIndex + 1] <> "" Then $iIndex += 1 GUICtrlSetData($hInput, $aInputs[$iIndex]) EndIf EndIf While _IsPressed("26", $dll) = 1 Sleep(10) WEnd EndIf WEnd All clear? M23 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...
rajeshwaran Posted August 31, 2010 Author Share Posted August 31, 2010 Hi Melba, Thank you very much. Your way of thinking is different. Thank you, once again. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 31, 2010 Moderators Share Posted August 31, 2010 rajeshwaran,Your way of thinking is differentYou are by no means the first to say that! M23 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...
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