Skip to content

Commit

Permalink
documents and codes update
Browse files Browse the repository at this point in the history
  • Loading branch information
Sfever authored Apr 12, 2024
1 parent 9978bd6 commit 772a906
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ MacOS: `brew install ffmpeg`

Linux: Since you're using linux distros, build them from source or finding a package by yourself.

### Native Windows

Codes of native win32 popup windows is provided in [/x64/Debug/](/x64/Debug/) folder, currently successfully compiled using latest VS2022 and msvc 14.39.

Linux and MacOS are currently not supported, Linux's version is currently only a plan and there will never be a MacOS version from me.

### Run

`python main.py` or `python3 main.py`, depends on your platform
Expand Down
48 changes: 48 additions & 0 deletions x64/Debug/poppup.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include<Python.h>
#include<windows.h>
#include<iostream>
#include<string>
#include<locale>
#include<atlconv.h>
#define PY_SSIZE_T_CLEAN


PyObject* ShowWindowWindows(PyObject* self, PyObject* args) {
char* parsed_title;
char* parsed_content;
try
{
int success = PyArg_ParseTuple(args, "ss", &parsed_title, &parsed_content);
if (!success || !parsed_title || !parsed_content) {
return NULL;
}
}
catch (const std::exception&)
{
return NULL;
}

WCHAR* wtitle;
WCHAR* wcontent;
USES_CONVERSION;
wtitle = A2W(parsed_title);
wcontent = A2W(parsed_content);
if (!wtitle || !wcontent) {
return NULL;
}

long returnvalue = MessageBox(NULL, wcontent, wtitle, MB_OK | MB_ICONWARNING);
return PyLong_FromLong(returnvalue);
}


static PyMethodDef PopMethods[] = {
{"PopWin",(PyCFunction)ShowWindowWindows,METH_VARARGS,"Show Native Windows Popups"},
{NULL,NULL,0,NULL}
};
static PyModuleDef nativepopup_module = {
PyModuleDef_HEAD_INIT,"nativepopup","Native Popups",0,PopMethods
};
PyMODINIT_FUNC PyInit_nativepopup() {
return PyModule_Create(&nativepopup_module);
}

0 comments on commit 772a906

Please sign in to comment.