forked from CamDavidsonPilon/matplotlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_windowing.cpp
More file actions
44 lines (39 loc) · 1023 Bytes
/
_windowing.cpp
File metadata and controls
44 lines (39 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* -*- mode: c++; c-basic-offset: 4 -*- */
#include "Python.h"
#include <windows.h>
static PyObject *
_GetForegroundWindow(PyObject *module, PyObject *args)
{
HWND handle = GetForegroundWindow();
if (!PyArg_ParseTuple(args, ":GetForegroundWindow"))
{
return NULL;
}
return PyInt_FromLong((long) handle);
}
static PyObject *
_SetForegroundWindow(PyObject *module, PyObject *args)
{
HWND handle;
if (!PyArg_ParseTuple(args, "l:SetForegroundWindow", &handle))
{
return NULL;
}
if (!SetForegroundWindow(handle))
{
return PyErr_Format(PyExc_RuntimeError,
"Error setting window");
}
Py_INCREF(Py_None);
return Py_None;
}
static PyMethodDef _windowing_methods[] =
{
{"GetForegroundWindow", _GetForegroundWindow, METH_VARARGS},
{"SetForegroundWindow", _SetForegroundWindow, METH_VARARGS},
{NULL, NULL}
};
extern "C" DL_EXPORT(void) init_windowing()
{
Py_InitModule("_windowing", _windowing_methods);
}