| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4413c50 commit ce7f0a6
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,35 @@ | |||
| 1 | + #include "Python.h" | ||
| 2 | + #include <windows.h> | ||
| 3 | + | ||
| 4 | + static PyObject * | ||
| 5 | + _GetForegroundWindow(PyObject *module, PyObject *args) | ||
| 6 | + { | ||
| 7 | + HWND handle = GetForegroundWindow(); | ||
| 8 | + if (!PyArg_ParseTuple(args, ":GetForegroundWindow")) | ||
| 9 | + return NULL; | ||
| 10 | + return PyInt_FromLong((long) handle); | ||
| 11 | + } | ||
| 12 | + | ||
| 13 | + static PyObject * | ||
| 14 | + _SetForegroundWindow(PyObject *module, PyObject *args) | ||
| 15 | + { | ||
| 16 | + HWND handle; | ||
| 17 | + if (!PyArg_ParseTuple(args, "l:SetForegroundWindow", &handle)) | ||
| 18 | + return NULL; | ||
| 19 | + if (!SetForegroundWindow(handle)) | ||
| 20 | + return PyErr_Format(PyExc_RuntimeError, | ||
| 21 | + "Error setting window"); | ||
| 22 | + Py_INCREF(Py_None); | ||
| 23 | + return Py_None; | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + static PyMethodDef _windowing_methods[] = { | ||
| 27 | + {"GetForegroundWindow", _GetForegroundWindow, METH_VARARGS}, | ||
| 28 | + {"SetForegroundWindow", _SetForegroundWindow, METH_VARARGS}, | ||
| 29 | + {NULL, NULL} | ||
| 30 | + }; | ||
| 31 | + | ||
| 32 | + extern "C" DL_EXPORT(void) init_windowing() | ||
| 33 | + { | ||
| 34 | + Py_InitModule("_windowing", _windowing_methods); | ||
| 35 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments