treesummaryrefslogcommitdiff
diff options
context:
space:
mode:
authorPatrick2022-01-12 20:56:10 +0100
committerPatrick2022-01-12 20:56:10 +0100
commit8d3cfb2ed7f4d2a70832526e1a2a68926e8a8d4b (patch)
treecaebfbef362ee689de07c19361fdc05597a97088
parent4264345d06a81cb561047d0973c44a129db934aa (diff)
downloadautorec-8d3cfb2ed7f4d2a70832526e1a2a68926e8a8d4b.tar.gz
autorec-8d3cfb2ed7f4d2a70832526e1a2a68926e8a8d4b.zip
Makefile, auto ico
-rw-r--r--Makefile13
-rw-r--r--build.cmd2
-rw-r--r--res/icon.svg77
-rw-r--r--res/icon.xcfbin14926 -> 0 bytes
-rw-r--r--res/icon_green.icobin13162 -> 329612 bytes
-rw-r--r--res/icon_red.icobin13160 -> 325711 bytes
-rw-r--r--res/icon_white.icobin75123 -> 316189 bytes
-rw-r--r--res/main.exe.manifest15
-rw-r--r--res/res.obin0 -> 1304524 bytes
-rw-r--r--res/res.rc4
-rw-r--r--res/res.resbin102124 -> 0 bytes
-rw-r--r--src/main.cpp9
-rw-r--r--src/win.cpp118
-rw-r--r--src/ws.h4
14 files changed, 117 insertions, 125 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..a7b8509
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,13 @@
+main.exe: src/main.cpp mongoose.o res/res.o
+ g++ src/main.cpp mongoose.o res/res.o -luser32 -lgdi32 -lshell32 -lshlwapi -lws2_32 -static-libgcc -static-libstdc++ -Os -s -o main.exe -mwindows
+
+mongoose.o: src/mongoose.c
+ g++ -c src/mongoose.c
+
+res/res.o: res/res.rc res/main.exe.manifest res/icon_white.ico
+ windres res/res.rc res/res.o
+
+res/icon_white.ico: res/icon.svg
+ magick convert -background none res/icon.svg -define icon:auto-resize -fuzz 60% -fill green -opaque white res/icon_green.ico
+ magick convert -background none res/icon.svg -define icon:auto-resize -fuzz 60% -fill red -opaque white res/icon_red.ico
+ magick convert -background none res/icon.svg -define icon:auto-resize res/icon_white.ico \ No newline at end of file
diff --git a/build.cmd b/build.cmd
index c559480..c447ce0 100644
--- a/build.cmd
+++ b/build.cmd
@@ -3,5 +3,5 @@
REM cl src/mongoose.c -c
REM rc res/res.rc
-cl /EHsc /Zi src/main.cpp mongoose.obj /link user32.lib gdi32.lib shell32.lib Shlwapi.lib ws2_32.lib res/res.res
+cl /EHsc src/main.cpp mongoose.obj /link user32.lib gdi32.lib shell32.lib Shlwapi.lib ws2_32.lib res/res.res
mt -manifest .\main.exe.manifest -outputresource:main.exe;1 \ No newline at end of file
diff --git a/res/icon.svg b/res/icon.svg
new file mode 100644
index 0000000..3a1719e
--- /dev/null
+++ b/res/icon.svg
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="100mm"
+ height="100mm"
+ viewBox="0 0 100 100"
+ version="1.1"
+ id="svg8"
+ inkscape:version="1.0.2 (e86c870879, 2021-01-15)"
+ sodipodi:docname="icon.svg">
+ <defs
+ id="defs2" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1"
+ inkscape:cx="90.608715"
+ inkscape:cy="221.364"
+ inkscape:document-units="mm"
+ inkscape:current-layer="layer1"
+ inkscape:document-rotation="0"
+ showgrid="false"
+ inkscape:pagecheckerboard="true"
+ inkscape:showpageshadow="false"
+ showborder="true"
+ borderlayer="false"
+ inkscape:window-width="1920"
+ inkscape:window-height="1027"
+ inkscape:window-x="-8"
+ inkscape:window-y="-8"
+ inkscape:window-maximized="1" />
+ <metadata
+ id="metadata5">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Ebene 1"
+ inkscape:groupmode="layer"
+ id="layer1">
+ <circle
+ style="opacity:1;fill:#000000;fill-opacity:1;stroke-width:0.298;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none"
+ id="path16"
+ cx="50"
+ cy="50"
+ r="50" />
+ <circle
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke-width:0.298;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none"
+ id="circle843"
+ cx="50"
+ cy="50"
+ r="42" />
+ <circle
+ style="opacity:1;fill:#000000;fill-opacity:1;stroke-width:0.298;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none"
+ id="circle9"
+ cx="50"
+ cy="50"
+ r="15" />
+ </g>
+</svg>
diff --git a/res/icon.xcf b/res/icon.xcf
deleted file mode 100644
index 0bcaac6..0000000
--- a/res/icon.xcf
+++ /dev/null
Binary files differ
diff --git a/res/icon_green.ico b/res/icon_green.ico
index 8f1c2a0..11be6ba 100644
--- a/res/icon_green.ico
+++ b/res/icon_green.ico
Binary files differ
diff --git a/res/icon_red.ico b/res/icon_red.ico
index 65f6015..4a060c7 100644
--- a/res/icon_red.ico
+++ b/res/icon_red.ico
Binary files differ
diff --git a/res/icon_white.ico b/res/icon_white.ico
index 5097f83..c883d7f 100644
--- a/res/icon_white.ico
+++ b/res/icon_white.ico
Binary files differ
diff --git a/res/main.exe.manifest b/res/main.exe.manifest
new file mode 100644
index 0000000..f64dfc7
--- /dev/null
+++ b/res/main.exe.manifest
@@ -0,0 +1,15 @@
+<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
+<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
+ <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
+ <security>
+ <requestedPrivileges>
+ <requestedExecutionLevel level='asInvoker' uiAccess='false' />
+ </requestedPrivileges>
+ </security>
+ </trustInfo>
+ <dependency>
+ <dependentAssembly>
+ <assemblyIdentity type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*' />
+ </dependentAssembly>
+ </dependency>
+</assembly>
diff --git a/res/res.o b/res/res.o
new file mode 100644
index 0000000..600d86a
--- /dev/null
+++ b/res/res.o
Binary files differ
diff --git a/res/res.rc b/res/res.rc
index f510d18..e80e7eb 100644
--- a/res/res.rc
+++ b/res/res.rc
@@ -1,5 +1,9 @@
#include "resource.h"
+1 24 main.exe.manifest
+
+MAIN_ICON ICON "icon_green.ico"
+
IDI_ICON_WHITE ICON "icon_white.ico"
IDI_ICON_GREEN ICON "icon_green.ico"
IDI_ICON_RED ICON "icon_red.ico" \ No newline at end of file
diff --git a/res/res.res b/res/res.res
deleted file mode 100644
index 0891986..0000000
--- a/res/res.res
+++ /dev/null
Binary files differ
diff --git a/src/main.cpp b/src/main.cpp
index d89c199..4f4a866 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -39,10 +39,9 @@ HideNotificationIcon()
void changeIcon(HWND hwnd, HINSTANCE hInstance, WORD id)
{
HICON icon = LoadIcon(hInstance, MAKEINTRESOURCE(id));
- HideNotificationIcon();
niData.hIcon = icon;
if (! IsWindowVisible(hwnd))
- ShowNotificationIcon();
+ Shell_NotifyIconA(NIM_MODIFY, &niData);
SendMessage(hwnd, WM_SETICON, 0, (LPARAM)icon);
SendMessage(hwnd, WM_SETICON, 1, (LPARAM)icon);
}
@@ -188,7 +187,7 @@ WinMain(HINSTANCE hInstance,
lay_id col1 = win::createLayId(&window.ctx, row2, 80, 0, LAY_COLUMN, LAY_VCENTER);
lstActiveProcesses.addStyle(WS_VSCROLL);
-
+
lay_set_margins_ltrb(ctx, col1, 5, 0, 5, 0);
win::ListBox lstMonitoredProcesses(&window, row2, 0, 0, 0, LAY_FILL);
@@ -253,7 +252,7 @@ WinMain(HINSTANCE hInstance,
SetTimer(window.hwnd, 10123, 100, [](HWND, UINT, UINT_PTR, DWORD) {
if (!recording) {
- if (checkForegroundProcess("notepad.exe")) {
+ if (checkForegroundProcess("League of Legends.exe")) {
recording = true;
process = getHwndProcess(GetForegroundWindow());
startRecording();
@@ -270,4 +269,6 @@ WinMain(HINSTANCE hInstance,
while (window.update()) {
ws::update();
}
+
+ return 0;
}
diff --git a/src/win.cpp b/src/win.cpp
deleted file mode 100644
index 6080291..0000000
--- a/src/win.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-#pragma comment(linker,"\"/manifestdependency:type='win32' \
-name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
-processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
-
-#include <windows.h>
-#include <CommCtrl.h>
-
-HWND hwndButton1;
-HWND hwndList1;
-
-const char g_szClassName[] = "MyWindowClass";
-
-LRESULT CALLBACK
-WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch (msg) {
- case WM_CLOSE:
- DestroyWindow(hwnd);
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- case WM_COMMAND:
- if (HIWORD(wParam) == BN_CLICKED) {
- if ((HWND)lParam == hwndButton1) {
- SendMessage(hwndList1, LB_ADDSTRING, 0, (LPARAM)"Hello");
- }
- }
- break;
- case WM_NOTIFY:
- break;
- default:
- return DefWindowProc(hwnd, msg, wParam, lParam);
- }
- return 0;
-}
-
-int WINAPI
-WinMain(HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- LPSTR lpCmdLine,
- int nCmdShow)
-{
- WNDCLASSEX wc;
- HWND hwnd;
- MSG Msg;
-
- // Step 1: Registering the Window Class
- wc.cbSize = sizeof(WNDCLASSEX);
- wc.style = 0;
- wc.lpfnWndProc = WndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hInstance;
- wc.hIcon = LoadIcon(nullptr, IDI_APPLICATION);
- wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
- wc.lpszMenuName = nullptr;
- wc.lpszClassName = g_szClassName;
- wc.hIconSm = LoadIcon(nullptr, IDI_APPLICATION);
-
-
- if (!RegisterClassEx(&wc)) {
- MessageBox(nullptr,
- "Window Registration Failed!",
- "Error!",
- MB_ICONEXCLAMATION | MB_OK);
- return 0;
- }
-
- // Step 2: Creating the Window
- hwnd = CreateWindowA(g_szClassName,
- "The title of my window",
- WS_OVERLAPPEDWINDOW,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- nullptr,
- nullptr,
- hInstance,
- nullptr);
-
- HWND tab = CreateWindowExA(0, WC_TABCONTROLA, "", WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS, 10, 10, 300, 300, hwnd, nullptr, nullptr, nullptr);
- hwndButton1 = CreateWindowExA(0, WC_BUTTONA, "OK", WS_VISIBLE | WS_CHILD, 10, 10, 100, 100, tab, nullptr, nullptr, nullptr);
- hwndList1 = CreateWindowExA(0, WC_LISTBOXA, "OK", WS_VISIBLE | WS_CHILD | WS_BORDER | WS_VSCROLL, 110, 10, 100, 100, tab, nullptr, nullptr, nullptr);
-
- TCITEMA tie;
- tie.mask = TCIF_TEXT;
- tie.pszText = "Hallo";
- TabCtrl_InsertItem(tab, 0, &tie);
- tie.mask = TCIF_TEXT;
- tie.pszText = "Ciao";
- TabCtrl_InsertItem(tab, 1, &tie);
-
- if (hwnd == nullptr) {
- MessageBox(
- nullptr, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
- return 0;
- }
-
- ShowWindow(hwnd, nCmdShow);
-
- UpdateWindow(hwnd);
-
- EnumChildWindows(hwnd, [](HWND hwnd, LPARAM lParam) -> BOOL {
- HFONT guiFont = (HFONT) GetStockObject(DEFAULT_GUI_FONT);
- SendMessage(hwnd, WM_SETFONT, (WPARAM)guiFont, MAKELPARAM(TRUE, 0));
- return TRUE;
- }, 0);
-
- // Step 3: The Message Loop
- while (GetMessage(&Msg, nullptr, 0, 0) > 0) {
- TranslateMessage(&Msg);
- DispatchMessage(&Msg);
- }
- return Msg.wParam;
-} \ No newline at end of file
diff --git a/src/ws.h b/src/ws.h
index 058f69b..4bebc1f 100644
--- a/src/ws.h
+++ b/src/ws.h
@@ -44,7 +44,7 @@ namespace ws
}
if (ev == MG_EV_ERROR) {
- puts("Error");
+ printf("Error: %s\n", (char*)ev_data);
done = true;
}
if (ev == MG_EV_CLOSE) {
@@ -75,7 +75,7 @@ namespace ws
{ "d",
{
{ "requestType", requestType },
- { "requestId", std::to_string(NULL).c_str() }
+ { "requestId", std::to_string(time(nullptr)).c_str() }
} } };
auto requestStr = request.dump();
mg_ws_send(c, requestStr.c_str(), requestStr.size(), WEBSOCKET_OP_TEXT);