Virtual Key output to external software lazarus / 62-General ---------------------------------------------------------------------- TheLastCayen · 2021-03-30 03:58 Hi, I am using  - Linux mint 20.1 XFCE 64 bit  - Lazarus 2.0.12  - FPC 3.2.0 I did a small software to type my password for me. My goal is to type the text when I push F5. I have no problem with the F5 part, tested with ShowMessage('Hellow World'); .  My problem is if I open a text editor and I push F5, it won't output my password(But again it will show "hello world" no problem). If I am in my application, click on an edit filed and push F5, It will enter my password without the special character.... I have 2 questions:   - How Can I output text in an external application not managed per my software?   - How Can I output Special Character.  This is my code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TFMain.KeyPressed(Sender: TObject; Key: Word; Shift: TShiftState);var  I: integer;begin  if Key = Fkey then    begin      p:=MEPassword.Text;      For I := 1 to Length(P) do        begin        if IsUpper(P[I]) then KeyInput.Apply([ssShift]);          KeyInput.Press(Char2VK(P[I]));          if IsUpper(P[I]) then KeyInput.Unapply([ssShift]);        end;      P:='';      ShowMessage('Hellow World');    end;end;   Thank you ---------------------------------------------------------------------- MarkMLl · 2021-03-30 06:50 Quote from: TheLastCayen on March 30, 2021, 05:58:27 amI am using  - Linux mint 20.1 XFCE 64 bit  - Lazarus 2.0.12  - FPC 3.2.0 Thank $DEITY that for once somebody is sufficiently clued up to tell us the important bit! Quote  - How Can I output text in an external application not managed per my software? Depends how the child program is invoked. You could pipe it, or you could a pseudoterminal via ptmx. Or you could research how people write "wedges" to inject barcodes etc. (there was discussion of that in this forum a few weeks ago). BUT Quote  - How Can I output Special Character.  I think the only way to do this is to rewrite entries on the event queue. See https://wiki.lazarus.freepascal.org/Lazarus_IDE_with_Nostro mo_Keypad_on_Linux which is for a gamepad but might help. MarkMLl ---------------------------------------------------------------------- TheLastCayen · 2021-03-31 01:33 Thank you for your reply MArkMLI For now, I will skip the part where I try to inject text into another application. I will read about what you said later. I manage to use KeyInput.Press to write basic char. But I have a hard time with a few special characters. So this is my new code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TFMain.Typetext;var  I: integer;  s: string;begin  //s:=fdecrypt(P);  s:='ABCdefGHIjklMNOpqrSTUvwxYZ*/+.-#$%^&@[\<>';    For I:= 1 to Length(S) do    Begin      case S[I] of         //No idea how to make those char        ':': Useshift(VK_OEM_1);        ';': KeyInput.Press(VK_OEM_1);        '>': Useshift(VK_OEM_102);        '<': KeyInput.Press(VK_OEM_102);        '?': Useshift(VK_OEM_2);       '~': Useshift(VK_OEM_3);        '`': KeyInput.Press(VK_OEM_3);      '{': Useshift(VK_OEM_4);        '[': KeyInput.Press(VK_OEM_4);        '|': Useshift(VK_OEM_5);        '\': KeyInput.Press(VK_OEM_5);        '}': Useshift(VK_OEM_6);        ']': KeyInput.Press(VK_OEM_6);        '"': Useshift(VK_OEM_7);        '''': KeyInput.Press(VK_OEM_7);      ',': Useshift(VK_OEM_COMMA);        '!': Useshift(VK_OEM_8);        '@': KeyInput.Press($40);        '#': KeyInput.Press($23);        '$': KeyInput.Press(36);        '%': KeyInput.Press(37);        '^': KeyInput.Press(94);        '&': KeyInput.Press(38);        '(': KeyInput.Press(40);        ')': KeyInput.Press(41);         //Next Part is tested and working        '*': KeyInput.Press(VK_MULTIPLY);      '/': KeyInput.Press(VK_DIVIDE);        '+': KeyInput.Press(VK_ADD);        '.': KeyInput.Press(VK_DECIMAL);      '-': KeyInput.Press(VK_SUBTRACT);        '0': KeyInput.Press(VK_NUMPAD0);        '1': KeyInput.Press(VK_NUMPAD1);      '2': KeyInput.Press(VK_NUMPAD2);        '3': KeyInput.Press(VK_NUMPAD3);        '4': KeyInput.Press(VK_NUMPAD4);      '5': KeyInput.Press(VK_NUMPAD5);        '6': KeyInput.Press(VK_NUMPAD6);        '7': KeyInput.Press(VK_NUMPAD7);      '8': KeyInput.Press(VK_NUMPAD8);        '9': KeyInput.Press(VK_NUMPAD9);        'a': KeyInput.Press(VK_A);        'A': Useshift(VK_A);        'b': KeyInput.Press(VK_B);        'B': Useshift(VK_B);        'c': KeyInput.Press(VK_C);        'C': Useshift(VK_C);        'd': KeyInput.Press(VK_D);        'D': Useshift(VK_D);        'e': KeyInput.Press(VK_E);        'E': Useshift(VK_E);        'f': KeyInput.Press(VK_F);        'F': Useshift(VK_F);        'g': KeyInput.Press(VK_G);        'G': Useshift(VK_G);        'h': KeyInput.Press(VK_H);        'H': Useshift(VK_H);        'i': KeyInput.Press(VK_I);        'I': Useshift(VK_I);        'j': KeyInput.Press(VK_J);        'J': Useshift(VK_J);        'k': KeyInput.Press(VK_K);        'K': Useshift(VK_K);        'l': KeyInput.Press(VK_L);        'L': Useshift(VK_L);        'm': KeyInput.Press(VK_M);        'M': Useshift(VK_M);        'n': KeyInput.Press(VK_N);        'N': Useshift(VK_N);        'o': KeyInput.Press(VK_O);        'O': Useshift(VK_O);        'p': KeyInput.Press(VK_P);        'P': Useshift(VK_P);        'q': KeyInput.Press(VK_Q);        'Q': Useshift(VK_Q);        'r': KeyInput.Press(VK_R);        'R': Useshift(VK_R);        's': KeyInput.Press(VK_S);        'S': Useshift(VK_S);        't': KeyInput.Press(VK_T);        'T': Useshift(VK_T);        'u': KeyInput.Press(VK_U);        'U': Useshift(VK_U);        'v': KeyInput.Press(VK_V);        'V': Useshift(VK_V);        'w': KeyInput.Press(VK_W);        'W': Useshift(VK_W);        'x': KeyInput.Press(VK_X);        'X': Useshift(VK_X);        'y': KeyInput.Press(VK_Y);        'Y': Useshift(VK_Y);        'z': KeyInput.Press(VK_Z);        'Z': Useshift(VK_Z);      end;    end;end; Procedure TFMain.Useshift(s:Word);begin  KeyInput.Apply([ssShift]);  KeyInput.Press(s);  KeyInput.Unapply([ssShift]);end;   As noted in the example, there are a few special characters I can't do. I try using the Ascii table hex and decimal... Use the code from LCLType... nothing seems to work. Anyone knows how to use KeyInput.Press to make those characters? or an alternative? Thank you ---------------------------------------------------------------------- MarkMLl · 2021-03-31 07:32 I'd suggest starting off with the example program that comes with KeyInput in the FPC sources, and trying to modify that for the "specials". I notice that the only time that I've got deeply into this (writing a terminal emulator) I was using the VK_LCL codes, not VK_OEM. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i (* Return true if the key is one of the standard alphanumerics, tab, space,     *)(* backspace, escape, enter (or one of the shifted variants of enter which      *)(* might represent LF or attention). In short it's not a function or cursor-    *)(* control key, or noise from a shift key                                     *)(*                                                                            *)(* Expect this to be widget-set specific, and also to vary with localisation.   *)//function typewriterKey(key: word): boolean; begin  result := true;//  WrDebug(DbgKey, Key, 2, true);        (* Normally disabled                  *) (* Refer to lcl/lcltype.pp                                                    *)   case key of    VK_BACK, VK_TAB, VK_RETURN, VK_ESCAPE, VK_SPACE,    VK_0..VK_9,    VK_A..VK_Z,    VK_LCL_EQUAL, VK_LCL_COMMA, VK_LCL_POINT,    VK_LCL_SLASH, VK_LCL_SEMI_COMMA, VK_LCL_MINUS,    VK_LCL_OPEN_BRAKET, VK_LCL_CLOSE_BRAKET,    VK_LCL_BACKSLASH, VK_LCL_TILDE, VK_LCL_QUOTE,    VK_SEPARATOR, VK_SUBTRACT, VK_DECIMAL, VK_DIVIDE, (* Required for Qt as of LCL 1.0 *) (* Non-standard keys as of Lazarus 1.0 and FPC 2.6.                           *)     $92,                                (* Hash (unshifted) and tilde (shifted) *)    $93..$96: begin end               (* "OEM specific"                       *)  otherwise    result := false  endend { typewriterKey } ;  I haven't a clue what the difference is, but some of those correspond to the characters giving you problems. (In the context of that program, I was piping characters or sending them via a socket rather than using KeyInput.Press() etc.) MarkMLl