timmy2 Posted November 4, 2013 Share Posted November 4, 2013 (edited) A graphic is already on screen showing the meanings of the following keys: j, k, l. At the point when that graphic appears I want my script to then wait for the user to press any of those keys. My script will respond appropriately. I found an old post by zackrspv that led me to the following script. My question is: how can I limit keyboard input to this GUI? I don't want the user's keystrokes to be seen by any other program that might be running. I cannot figure out how to incorporate the BlockInputEX UDF into my script, plus I'm not sure my approach is even the best solution. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $form = GUICreate("test", 500, 500,BitOR($WS_SYSMENU,$WS_POPUP)) $SBack = GUICtrlCreateDummy() $SPause = GUICtrlCreateDummy() $SForward = GUICtrlCreateDummy() Dim $AccelKeys[3][2] = [["j", $SBack],["k", $SPause],["l", $SForward]] GUISetAccelerators($AccelKeys) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $SBack ConsoleWrite("back" & @CRLF) Case $SPause ConsoleWrite("pause" & @CRLF) Case $SForward ConsoleWrite("forward" & @CRLF) EndSwitch WEnd Edited November 5, 2013 by timmy2 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 4, 2013 Moderators Share Posted November 4, 2013 timmy2,Accelerator keys are automatically limited to your GUI when it is active - if your GUI is not active than they are useable by any active GUI. So if your graphic is being displayed in the active GUI - which you imply is the case - those keys will be trapped by that GUI. By the way, you are not creating your GUI correctly - there are a couple of parameters missing: $form = GUICreate("test", 500, 500, -1, -1 ,BitOR($WS_SYSMENU,$WS_POPUP))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...
timmy2 Posted November 5, 2013 Author Share Posted November 5, 2013 (edited) timmy2, Accelerator keys are automatically limited to your GUI when it is active - if your GUI is not active than they are useable by any active GUI. So if your graphic is being displayed in the active GUI - which you imply is the case - those keys will be trapped by that GUI. By the way, you are not creating your GUI correctly - there are a couple of parameters missing: $form = GUICreate("test", 500, 500, -1, -1 ,BitOR($WS_SYSMENU,$WS_POPUP)) M23 Thank you, Melba23 for replying. (I'm chuckling as I write this, being an idiot keyboard monkey who discovered he accidently typed a line from Hamlet.) I realize the correct syntax for GUICreate requires the left and top values (-1, -1) but if I add those values my formerly invisible GUI becomes a white box, which I don't want. I'm tempted to enjoy my newly discovered hidden feature in GUICreate but for the sake of proper usage do you see anything wrong with changing the GUICreate statement to: $form = GUICreate("test", 0, 0,-1, -1, BitOR($WS_SYSMENU,$WS_POPUP)) All I want is an invisible multiple-choice single-keystroke-to-continue routine that at least when active doesn't pass through keystrokes. If there's a better way please -- somebody -- show me. While I've got your attention (if I do), can you tell me if it's possible to use the BlockInputEX UDF with my script, allows excepting a specific window? I tried blocking all keyboard input with the exception of the handle $form but still NO input was allowed. Edited November 5, 2013 by timmy2 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