Skip to content
This repository has been archived by the owner on Sep 7, 2021. It is now read-only.

unable to use with console applications on Windows #55

Open
OverMalo opened this issue Jun 26, 2018 · 4 comments
Open

unable to use with console applications on Windows #55

OverMalo opened this issue Jun 26, 2018 · 4 comments

Comments

@OverMalo
Copy link

Hi,

I want to use your library to monitorize the keyboard on console application (without windows). is it possible or is it compulsory to have a HWND?

Regards,

@xnhunter
Copy link

xnhunter commented Jul 3, 2018

GaInput requires using HWND through WinAPI to work with a keyboard/mouse etc. So, if you want to monitorize the keyboard in console you may take a look at this: Detect function keys in c++ console.

@RicoP
Copy link

RicoP commented Jul 16, 2018

One thing you could try is you can create a native windows application (something that starts with a WinMain and get's a handle passed in right away) but don't create a native win form window. Instead you can create a Console window with AllocConsole.

@RicoP
Copy link

RicoP commented Jul 16, 2018

#include <iostream>
#include <windows.h>
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, INT) {
  if (AllocConsole())
  {
    freopen("CONOUT$", "wt", stdout);
    freopen("CONIN$", "rt", stdin);
    SetConsoleTitle(L"Debug Console");
    std::ios::sync_with_stdio(1);
  }

  std::cout << "Hello\n" << std::endl;

  return 0;
}

@RicoP
Copy link

RicoP commented Jul 16, 2018

Ok forget it. I assumed you need a HINSTANCe to get access to the window, but you need a HWND handle. I couldnt find a way to get a handle. for the console...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants