Página 1 de 1

Converter API do Windows

Enviado: 19 Abr 2021 14:16
por chicaomogi1970
Tem uma função da API do Windows chamada SendInput, só que não sei como converter ela pra Harbour.

Estou usando Harbour MiniGUI Extended Edition 21.03 (Update 2)

SINTAXE em C++
==============

Código: Selecionar todos

UINT SendInput(
  UINT    cInputs,
  LPINPUT pInputs,
  int     cbSize
);
PARAMETROS
===========

Código: Selecionar todos

cInputs

Type: UINT

The number of structures in the pInputs array.

pInputs

Type: LPINPUT

An array of INPUT structures. Each structure represents an event to be inserted into the keyboard or mouse input stream.

cbSize

Type: int

The size, in bytes, of an INPUT structure. If cbSize is not the size of an INPUT structure, the function fails.
RETORNO
========

Código: Selecionar todos

Type: UINT

The function returns the number of events that it successfully inserted into the keyboard or mouse input stream. If the function returns zero, the input was already blocked by another thread. To get extended error information, call GetLastError.

This function fails when it is blocked by UIPI. Note that neither GetLastError nor the return value will indicate the failure was caused by UIPI blocking.
EXEMPLO
========

Código: Selecionar todos

//**********************************************************************
//
// Sends Win + D to toggle to the desktop
//
//**********************************************************************
void ShowDesktop()
{
    OutputString(L"Sending 'Win-D'\r\n");
    INPUT inputs[4];
    ZeroMemory(inputs, sizeof(inputs));

    inputs[0].type = INPUT_KEYBOARD;
    inputs[0].ki.wVk = VK_LWIN;
    
    inputs[1].type = INPUT_KEYBOARD;
    inputs[1].ki.wVk = VK_D;

    inputs[2].type = INPUT_KEYBOARD;
    inputs[2].ki.wVk = VK_D;
    inputs[2].ki.dwFlags = KEYEVENTF_KEYUP;

    inputs[3].type = INPUT_KEYBOARD;
    inputs[3].ki.wVk = VK_LWIN;
    inputs[3].ki.dwFlags = KEYEVENTF_KEYUP;

    UINT uSent = SendInput(ARRAYSIZE(inputs), inputs, sizeof(INPUT));
    if (uSent != ARRAYSIZE(inputs))
    {
        OutputString(L"SendInput failed: 0x%x\n", HRESULT_FROM_WIN32(GetLastError()));
    }
}
REQUERIMENTOS
==============

Código: Selecionar todos

Minimum supported client 	Windows 2000 Professional [desktop apps only]
Minimum supported server 	Windows 2000 Server [desktop apps only]
Target Platform 	                Windows
Header 	                                winuser.h (include Windows.h)
Library 	                                User32.lib
DLL 	                                        User32.dll
Queria saber como faz, ou se existe algum artigo que ensina a fazer essa conversão.

Converter API do Windows

Enviado: 19 Abr 2021 16:00
por JoséQuintas
O problema que vejo nesse é o parâmetro array, contendo uma variável do tipo "input".
Não basta passar parâmetros, tem que ser do tipo certo, e esse tipo foge das regras conhecidas pelo Harbour.
Se não me engano existe a SendKeys(), específica pra comandos de teclado, que pode simplificar os parâmetros.
Mas acho que a maioria das LIBs tem algo pra isso pronto.