How can I take a screenshot in a windows application?

HDC hScreenDC = GetDC(nullptr); // CreateDC(“DISPLAY”,nullptr,nullptr,nullptr); HDC hMemoryDC = CreateCompatibleDC(hScreenDC); int width = GetDeviceCaps(hScreenDC,HORZRES); int height = GetDeviceCaps(hScreenDC,VERTRES); HBITMAP hBitmap = CreateCompatibleBitmap(hScreenDC,width,height); HBITMAP hOldBitmap = static_cast<HBITMAP>(SelectObject(hMemoryDC,hBitmap)); BitBlt(hMemoryDC,0,0,width,height,hScreenDC,0,0,SRCCOPY); hBitmap = static_cast<HBITMAP>(SelectObject(hMemoryDC,hOldBitmap)); DeleteDC(hMemoryDC); DeleteDC(hScreenDC);

How do I properly map a `MagImageScalingCallback` using JNA?

The callback is proper – there is no flaw in your code, besides you are using deprecated functions. Consider using this: try { Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()); BufferedImage capture = new Robot().createScreenCapture(screenRect); ImageIO.write(capture, “JPEG”, new File(“printed1.jpg”)); } catch (Exception e) { e.printStackTrace(); }

How to use Win32 API with Python?

PyWin32 is the way to go – but how to use it? One approach is to begin with a concrete problem you’re having and attempting to solve it. PyWin32 provides bindings for the Win32 API functions for which there are many, and you really have to pick a specific goal first. In my Python 2.5 … Read more

Get current cursor position

You get the cursor position by calling GetCursorPos. POINT p; if (GetCursorPos(&p)) { //cursor position now in p.x and p.y } This returns the cursor position relative to screen coordinates. Call ScreenToClient to map to window coordinates. if (ScreenToClient(hwnd, &p)) { //p.x and p.y are now relative to hwnd’s client area } You hide and … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)