Unconfigured Ad Widget

Collapse

Anúncio

Collapse
No announcement yet.

Sendkeys isolado

Collapse
X
 
  • Filter
  • Tempo
  • Show
Clear All
new posts

  • Font Size
    #1

    Duvida Sendkeys isolado

    Estou usando o procedimento abaixo para enviar o texto para o edit de um form, e o procedimento deve estar sendo executado em um timer com interval de 1000 (SendKeys('Hello Word'));.

    Mais eu preciso que quando o form for minimizado o sendkeys, continue enviando a mensagem para o edit, mais o que acontece é que ele envia a mensagem para qualquer outro aplicativo que eu abra com algum campo digitável.

    É possível, isolar o meu aplicativo e enviar as teclas somente para ele e depois eu continuar usando o teclado para digitar em outros programas?





    procedure SimulateKeyDown(Key : byte);
    begin
    keybd_event(Key, 0, 0, 0);
    end;

    procedure SimulateKeyUp(Key : byte);
    begin
    keybd_event(Key, 0, KEYEVENTF_KEYUP, 0);
    end;

    procedure SimulateKeystroke(Key : byte;
    extra : DWORD);
    begin
    keybd_event(Key,
    extra,
    0,
    0);
    keybd_event(Key,
    extra,
    KEYEVENTF_KEYUP,
    0);
    end;

    procedure SendKeys(s : string);
    var
    i : integer;
    flag : bool;
    w : word;
    begin
    {Get the state of the caps lock key}
    flag := not GetKeyState(VK_CAPITAL) and 1 = 0;
    {If the caps lock key is on then turn it off}
    if flag then
    SimulateKeystroke(VK_CAPITAL, 0);
    for i := 1 to Length(s) do begin
    w := VkKeyScan(s);
    {If there is not an error in the key translation}
    if ((HiByte(w) <> $FF) and
    (LoByte(w) <> $FF)) then begin
    {If the key requires the shift key down - hold it down}
    if HiByte(w) and 1 = 1 then
    SimulateKeyDown(VK_SHIFT);
    {Send the VK_KEY}
    SimulateKeystroke(LoByte(w), 0);
    {If the key required the shift key down - release it}
    if HiByte(w) and 1 = 1 then
    SimulateKeyUp(VK_SHIFT);
    end;
    end;
    {if the caps lock key was on at start, turn it back on}
    if flag then
    SimulateKeystroke(VK_CAPITAL, 0);
    end;
X
Working...
X