ENTER keypress wihtout touching keyboard in matlab - matlab
how its possible to Matlab input work in command window and then press ENTER without touching keyboard..
or any pushbutton function which can do that
thanks
I have this generic solution, based on undocumented matlab. It enables to press any button based on a string input (e.g. '0') by searching through a string of possible buttons to press. Watch out, this will also be pressed outside of the Matlab environment.
function presskey(mykey)
keys={'KEY_FIRST ','KEY_LAST ','KEY_PRESSED ','KEY_RELEASED ','KEY_TYPED ','VK_0 ','VK_1 ','VK_2 ','VK_3 ','VK_4 ','VK_5 ','VK_6 ','VK_7 ','VK_8 ','VK_9 ','VK_A ','VK_ACCEPT ','VK_ADD ','VK_AGAIN ','VK_ALL_CANDIDATES ','VK_ALPHANUMERIC ','VK_ALT ','VK_ALT_GRAPH ','VK_AMPERSAND ','VK_ASTERISK ','VK_AT ','VK_B ','VK_BACK_QUOTE ','VK_BACK_SLASH ','VK_BACK_SPACE ','VK_BRACELEFT ','VK_BRACERIGHT ','VK_C ','VK_CANCEL ','VK_CAPS_LOCK ','VK_CIRCUMFLEX ','VK_CLEAR ','VK_CLOSE_BRACKET ','VK_CODE_INPUT ','VK_COLON ','VK_COMMA ','VK_COMPOSE ','VK_CONTROL ','VK_CONVERT ','VK_COPY ','VK_CUT ','VK_D ','VK_DEAD_ABOVEDOT ','VK_DEAD_ABOVERING ','VK_DEAD_ACUTE ','VK_DEAD_BREVE ','VK_DEAD_CARON ','VK_DEAD_CEDILLA ','VK_DEAD_CIRCUMFLEX ','VK_DEAD_DIAERESIS ','VK_DEAD_DOUBLEACUTE ','VK_DEAD_GRAVE ','VK_DEAD_IOTA ','VK_DEAD_MACRON ','VK_DEAD_OGONEK ','VK_DEAD_SEMIVOICED_SOUND ','VK_DEAD_TILDE ','VK_DEAD_VOICED_SOUND ','VK_DECIMAL ','VK_DELETE ','VK_DIVIDE ','VK_DOLLAR ','VK_DOWN ','VK_E ','VK_END ','VK_ENTER ','VK_EQUALS ','VK_ESCAPE ','VK_EURO_SIGN ','VK_EXCLAMATION_MARK ','VK_F ','VK_F1 ','VK_F10 ','VK_F11 ','VK_F12 ','VK_F13 ','VK_F14 ','VK_F15 ','VK_F16 ','VK_F17 ','VK_F18 ','VK_F19 ','VK_F2 ','VK_F20 ','VK_F21 ','VK_F22 ','VK_F23 ','VK_F24 ','VK_F3 ','VK_F4 ','VK_F5 ','VK_F6 ','VK_F7 ','VK_F8 ','VK_F9 ','VK_FINAL ','VK_FIND ','VK_FULL_WIDTH ','VK_G ','VK_GREATER ','VK_H ','VK_HALF_WIDTH ','VK_HELP ','VK_HIRAGANA ','VK_HOME ','VK_I ','VK_INSERT ','VK_INVERTED_EXCLAMATION_MARK ','VK_J ','VK_JAPANESE_HIRAGANA ','VK_JAPANESE_KATAKANA ','VK_JAPANESE_ROMAN ','VK_K ','VK_KANA ','VK_KANJI ','VK_KATAKANA ','VK_KP_DOWN ','VK_KP_LEFT ','VK_KP_RIGHT ','VK_KP_UP ','VK_L ','VK_LEFT ','VK_LEFT_PARENTHESIS ','VK_LESS ','VK_M ','VK_META ','VK_MODECHANGE ','VK_MULTIPLY ','VK_N ','VK_NONCONVERT ','VK_NUM_LOCK ','VK_NUMBER_SIGN ','VK_NUMPAD0 ','VK_NUMPAD1 ','VK_NUMPAD2 ','VK_NUMPAD3 ','VK_NUMPAD4 ','VK_NUMPAD5 ','VK_NUMPAD6 ','VK_NUMPAD7 ','VK_NUMPAD8 ','VK_NUMPAD9 ','VK_O ','VK_OPEN_BRACKET ','VK_P ','VK_PAGE_DOWN ','VK_PAGE_UP ','VK_PASTE ','VK_PAUSE ','VK_PERIOD ','VK_PLUS ','VK_PREVIOUS_CANDIDATE ','VK_PRINTSCREEN ','VK_PROPS ','VK_Q ','VK_QUOTE ','VK_QUOTEDBL ','VK_R ','VK_RIGHT ','VK_RIGHT_PARENTHESIS ','VK_ROMAN_CHARACTERS ','VK_S ','VK_SCROLL_LOCK ','VK_SEMICOLON ','VK_SEPARATER ','VK_SHIFT ','VK_SLASH ','VK_SPACE ','VK_STOP ','VK_SUBTRACT ','VK_T ','VK_TAB ','VK_U ','VK_UNDEFINED ','VK_UNDERSCORE ','VK_UNDO ','VK_UP ','VK_V ','VK_W ','VK_X ','VK_Y ','VK_Z'};
a=(find(~cellfun('isempty',strfind(keys,mykey))));
if ~isempty(a)
mykey=keys{a(1)};
robot = java.awt.Robot;
eval(['robot.keyPress (java.awt.event.KeyEvent.' mykey ')']);
eval(['robot.keyRelease (java.awt.event.KeyEvent.' mykey ')']);
end
end
Related
Prevent user from Enter-pressing on MESSAGE type I?
Is there any way to disable the enter key when a MESSAGE TYPE I is displayed? The users are just pressing away the note without reading it. We want to force them to actually click the green button to confirm the message instead (Yes, I know it's dumb, but I was tasked to implement this so wcyd). SELECT SINGLE text FROM ZWM_MATVERMERK INTO lv_verm WHERE matnr = <lf_main>-matnr AND werk = <lf_main>-werks. IF lv_verm IS NOT INITIAL. MESSAGE | Note: { lv_verm } | TYPE 'I'. CLEAR lv_verm. ENDIF.
You can use the function module POPUP_TO_CONFIRM to create a modal dialog which gives you more control than the standard MESSAGE TYPE 'I'. Among others, this function module has the parameter default_button which decides which button is the one highlighted when the popup appears and thus will be considered clicked when the user just presses enter. DATA lv_answer TYPE c. CALL FUNCTION 'POPUP_TO_CONFIRM' EXPORTING text_question = 'Are you sure?' default_button = 2 IMPORTING answer = lv_answer. " lv_answer will be '1' for yes, '2' for no and 'A' for canceling the dialog. If you want to make really really sure that the user read the message, then one option is to use POPUP_TO_GET_ONE_VALUE to make the user confirm that they read the message by reciting something from it. DATA lv_answer TYPE c. DATA lv_value TYPE pvarfield. CALL FUNCTION 'POPUP_TO_GET_ONE_VALUE' EXPORTING titel = 'Safety check' textline1 = |This operation will affect { lv_count } items.| textline2 = |When you are aware of that, please enter "{ lv_count }" below:| valuelength = 20 IMPORTING answer = lv_answer value1 = lv_value. IF lv_answer = 'J' and lv_value = lv_count. "...proceed... ENDIF. This will look like this: By the way: There are a lot more standard function modules starting with POPUP_* which cover a wide variety of common use-cases for modal dialogs. Some of those can be really useful.
Error in save as type using uiputfile - Matlab
In app designer I have two buttons one to declare the working folder: function setSaveLocationButtonPushed(app, event) app.path = uigetdir() end The other one to save an image function saveButtonPushed(app, event) pathSave = app.path; [file, pathSave] = uiputfile([pathSave,'*.jpg']); … end Why do I get in the save as type also the app.path? (as shown in image)
Your code [pathSave,'*.jpg'] concatenates the path and the filter and then passes the result as the only argument to the uiputfile function. This argument tells the function what file filter to use. Instead of storing the chosen directory, make it change the current directory. The file selection UI always opens in the current directory. function setSaveLocationButtonPushed(app, event) p = uigetdir; cd(p) end function saveButtonPushed(app, event) [file, pathSave] = uiputfile('*.jpg'); … end If you don’t want to change the current directory for the whole application, you can change it just before calling the uiputfile function, and change it back afterward: function saveButtonPushed(app, event) p = cd(app.path); [file, pathSave] = uiputfile('*.jpg'); cd(p); … end
controlling EV3 motor using Matlab
im trying to control my ev3 motor speed, but when I apply this code noting happen what should I do? thanks myev3 = legoev3; mymotor = motor(myev3,'A'); omega_1=[0 17.79123846 18.61264124 19.24807265 19.69118368 19.93754691 19.98470077 19.8321741 19.48149091 18.93615509 18.20161548 17.28521134 16.19609908 14.94516075 13.54489532 12.00929377 10.35369932 8.59465414 6.749734013 4.837372774 2.876678106 0.88724062 -1.11106188 -3.098263017 -5.054507334 -6.960248685 -8.796445531 -10.5447512 -12.1876972 -13.70886776 -15.09306385 -16.32645503 -17.39671767 -18.29315806 -19.00681925 -19.5305706 -19.85917893 -19.98936092 -19.91981582 -19.6512385 -19.18631251 -18.52968322 -17.68791146 -16.66940794 -15.48434921 -14.14457597 -12.66347481 -11.05584439 -9.337747634 -7.526351187 -5.639753927 -3.696806111 -1.716921029 0.280118959 2.274360092 4.245876571 6.174969654 8.042364482 9.829402662 11.5182287 13.0919684 14.53489749 15.83259868 ]; %% q=63; while q<=62 mymotor.Speed = omega_1(0:q,:); start(mymotor); pause(90); stop(mymotor); q+1; end
Your loop runs while q<=62, but you set the value q=63 before that. So the program never entered the loop to begin with.
VBA Access form: Submit Button to create new record but keep some values in the form
I have a form to enter all necessary data. With the wizard I created a button that saves the data as a new record, but this button clears the form. I want this button to do exactly that, but keep some of the entered values in the form, because those values will stay the same for a certain amount of records. Currently my button runs this code generated by the button creation wizard: Private Sub submit_btn_Click() On Error GoTo submit_btn_Click_Err On Error Resume Next DoCmd.GoToRecord , "", acNewRec If (MacroError <> 0) Then Beep MsgBox MacroError.Description, vbOKOnly, "" End If submit_btn_Click_Exit: Exit Sub submit_btn_Click_Err: MsgBox Error$ Resume submit_btn_Click_Exit End Sub When the button is clicked I want to clear all values in the form, except for the date and a group field. Can I easily do this in this code or is there a way to do this via the default value property of these fields?
Try the following: Go to the properties of your form and put the following code in the BeforeUpdate event: Private Sub Form_BeforeUpdate(Cancel As Integer) entry_date.Tag = CLng(entry_date.Value) acc_value.Tag = acc_value.Value End Sub In the Current event of the form, put the following code: Private Sub Form_Current() If Me.NewRecord Then entry_date = CDate(entry_date.Tag) acc_value = acc_value.Tag End If End Sub That is all you need to do. If you have any questions please let me know
Combination of specific key and any other key
I would like to turn F15 into a macro key. Pressing another key while F15 is held should call a function that will read a .ini file for instructions. I know that I can it this like this, but I'd rather not have the giant list: DoMacro(key) { ... } F15 & a::DoMacro('a') F15 & b::DoMacro('b') F15 & c::DoMacro('c') . . . I tried fiddling around with Input, but I couldn't figure out any way to capture (or even pass through) non-character keys. Is there any alternative to the long list?
Unfortunately there is no 100% nice way to do this in AHK (unless you know a way to do it through API calls which I don't). I think the best you could make out of this situation is this: GetAnyKey(timeout) { Input, PressedKey, T%timeout% L1, {F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{F14}{F15}{F16}{F17}{F18}{F19}{F20}{F21}{F22}{F23}{F24}{PrintScreen}{Del}{Home}{End}{PgUp}{PgDn}{ScrollLock}{Pause}{Ins}{BS}{Space}{Left}{Right}{Up}{Down}{Left}{Right}{NumLock}{NumPad1}{NumPad2}{NumPad3}{NumPad4}{NumPad5}{NumPad6}{NumPad7}{NumPad8}{NumPad9}{NumPad0}{NumPadAdd}{NumPadSub}{NumPadMult}{NumPadDiv}{NumPadEnter}{NumPadDot}{NumPadEnd}{NumPadHome}{NumPadPgDn}{NumPadPgUp}{NumpadClear}{NumpadDown}{NumpadIns}{NumpadLeft}{NumpadRight}{AppsKey}{LShift}{RShift}{LCtrl}{RCtrl}{LAlt}{RAlt}{LWin}{RWin} If (ErrorLevel = "Timeout") Return If PressedKey Key := PressedKey Else Key := SubStr(ErrorLevel,8) Return Key } F13:: Key := GetAnyKey(1) If (Key && GetKeyState("F13", "P")) { DoMacro(Key) } Return DoMacro(Key) { MsgBox, F13 and %Key% have been pressed! } I removed the hotkey (F13) from the Input key list, so that it doesn't trigger the Input when you wait too long. So, if you change the hotkey you have to change the input list accordingly.