]> gitweb.ps.run Git - autorec/commitdiff
Makefile, auto ico
authorPatrick <patrick.schoenberger@posteo.de>
Wed, 12 Jan 2022 19:56:10 +0000 (20:56 +0100)
committerPatrick <patrick.schoenberger@posteo.de>
Wed, 12 Jan 2022 19:56:10 +0000 (20:56 +0100)
14 files changed:
Makefile [new file with mode: 0644]
build.cmd
res/icon.svg [new file with mode: 0644]
res/icon.xcf [deleted file]
res/icon_green.ico
res/icon_red.ico
res/icon_white.ico
res/main.exe.manifest [new file with mode: 0644]
res/res.o [new file with mode: 0644]
res/res.rc
res/res.res [deleted file]
src/main.cpp
src/win.cpp [deleted file]
src/ws.h

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..a7b8509
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,13 @@
+main.exe: src/main.cpp mongoose.o res/res.o\r
+       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\r
+\r
+mongoose.o: src/mongoose.c\r
+       g++ -c src/mongoose.c\r
+\r
+res/res.o: res/res.rc res/main.exe.manifest res/icon_white.ico\r
+       windres res/res.rc res/res.o\r
+\r
+res/icon_white.ico: res/icon.svg\r
+       magick convert -background none res/icon.svg -define icon:auto-resize -fuzz 60% -fill green -opaque white res/icon_green.ico\r
+       magick convert -background none res/icon.svg -define icon:auto-resize -fuzz 60% -fill red -opaque white res/icon_red.ico\r
+       magick convert -background none res/icon.svg -define icon:auto-resize res/icon_white.ico
\ No newline at end of file
index c55948099100cc5b8a4e2c7df36a4ca396eee549..c447ce0a739343c557434f9bec56b973499287d4 100644 (file)
--- a/build.cmd
+++ b/build.cmd
@@ -3,5 +3,5 @@
 REM cl src/mongoose.c -c\r
 REM rc res/res.rc\r
 \r
 REM cl src/mongoose.c -c\r
 REM rc res/res.rc\r
 \r
-cl /EHsc /Zi src/main.cpp mongoose.obj /link user32.lib gdi32.lib shell32.lib Shlwapi.lib ws2_32.lib res/res.res\r
+cl /EHsc src/main.cpp mongoose.obj /link user32.lib gdi32.lib shell32.lib Shlwapi.lib ws2_32.lib res/res.res\r
 mt -manifest .\main.exe.manifest -outputresource:main.exe;1
\ No newline at end of file
 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 (file)
index 0000000..3a1719e
--- /dev/null
@@ -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 (file)
index 0bcaac6..0000000
Binary files a/res/icon.xcf and /dev/null differ
index 8f1c2a0d749937bb2eea0eb8ccd81c7e15f541ca..11be6ba15d15772ea13b82606ebdf75a2502466e 100644 (file)
Binary files a/res/icon_green.ico and b/res/icon_green.ico differ
index 65f6015fc106b3e86e858217903f46ff559d6569..4a060c770036aaae05d4e9e43f912ddff714a301 100644 (file)
Binary files a/res/icon_red.ico and b/res/icon_red.ico differ
index 5097f83bd62ecc87d7b97958ab3101029a74b829..c883d7f5bfd90f9be444cd8766034c57891e6df8 100644 (file)
Binary files a/res/icon_white.ico and b/res/icon_white.ico differ
diff --git a/res/main.exe.manifest b/res/main.exe.manifest
new file mode 100644 (file)
index 0000000..f64dfc7
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version='1.0' encoding='UTF-8' standalone='yes'?>\r
+<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>\r
+  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">\r
+    <security>\r
+      <requestedPrivileges>\r
+        <requestedExecutionLevel level='asInvoker' uiAccess='false' />\r
+      </requestedPrivileges>\r
+    </security>\r
+  </trustInfo>\r
+  <dependency>\r
+    <dependentAssembly>\r
+      <assemblyIdentity type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*' />\r
+    </dependentAssembly>\r
+  </dependency>\r
+</assembly>\r
diff --git a/res/res.o b/res/res.o
new file mode 100644 (file)
index 0000000..600d86a
Binary files /dev/null and b/res/res.o differ
index f510d18f5ea5b76901f40793e3ec6bf966170fb5..e80e7ebb14c0676c54d4f4df69100bdff7251730 100644 (file)
@@ -1,5 +1,9 @@
 #include "resource.h"\r
 \r
 #include "resource.h"\r
 \r
+1 24 main.exe.manifest\r
+\r
+MAIN_ICON      ICON "icon_green.ico"\r
+\r
 IDI_ICON_WHITE ICON "icon_white.ico"\r
 IDI_ICON_GREEN ICON "icon_green.ico"\r
 IDI_ICON_RED   ICON "icon_red.ico"
\ No newline at end of file
 IDI_ICON_WHITE ICON "icon_white.ico"\r
 IDI_ICON_GREEN ICON "icon_green.ico"\r
 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 (file)
index 0891986..0000000
Binary files a/res/res.res and /dev/null differ
index d89c1991ea6a0ebc9eb3c5296e895fcb18a8c57e..4f4a866863bcfac8c36a19b50a00f2fa15e3fb08 100644 (file)
@@ -39,10 +39,9 @@ HideNotificationIcon()
 void changeIcon(HWND hwnd, HINSTANCE hInstance, WORD id)\r
 {\r
   HICON icon = LoadIcon(hInstance, MAKEINTRESOURCE(id));\r
 void changeIcon(HWND hwnd, HINSTANCE hInstance, WORD id)\r
 {\r
   HICON icon = LoadIcon(hInstance, MAKEINTRESOURCE(id));\r
-  HideNotificationIcon();\r
   niData.hIcon = icon;\r
   if (! IsWindowVisible(hwnd))\r
   niData.hIcon = icon;\r
   if (! IsWindowVisible(hwnd))\r
-    ShowNotificationIcon();\r
+    Shell_NotifyIconA(NIM_MODIFY, &niData);\r
   SendMessage(hwnd, WM_SETICON, 0, (LPARAM)icon);\r
   SendMessage(hwnd, WM_SETICON, 1, (LPARAM)icon);\r
 }\r
   SendMessage(hwnd, WM_SETICON, 0, (LPARAM)icon);\r
   SendMessage(hwnd, WM_SETICON, 1, (LPARAM)icon);\r
 }\r
@@ -188,7 +187,7 @@ WinMain(HINSTANCE hInstance,
   \r
   lay_id col1 = win::createLayId(&window.ctx, row2, 80, 0, LAY_COLUMN, LAY_VCENTER);\r
   lstActiveProcesses.addStyle(WS_VSCROLL);\r
   \r
   lay_id col1 = win::createLayId(&window.ctx, row2, 80, 0, LAY_COLUMN, LAY_VCENTER);\r
   lstActiveProcesses.addStyle(WS_VSCROLL);\r
-  \r
+\r
   lay_set_margins_ltrb(ctx, col1, 5, 0, 5, 0);\r
 \r
   win::ListBox lstMonitoredProcesses(&window, row2, 0, 0, 0, LAY_FILL);\r
   lay_set_margins_ltrb(ctx, col1, 5, 0, 5, 0);\r
 \r
   win::ListBox lstMonitoredProcesses(&window, row2, 0, 0, 0, LAY_FILL);\r
@@ -253,7 +252,7 @@ WinMain(HINSTANCE hInstance,
 \r
   SetTimer(window.hwnd, 10123, 100, [](HWND, UINT, UINT_PTR, DWORD) {\r
     if (!recording) {\r
 \r
   SetTimer(window.hwnd, 10123, 100, [](HWND, UINT, UINT_PTR, DWORD) {\r
     if (!recording) {\r
-      if (checkForegroundProcess("notepad.exe")) {\r
+      if (checkForegroundProcess("League of Legends.exe")) {\r
         recording = true;\r
         process = getHwndProcess(GetForegroundWindow());\r
         startRecording();\r
         recording = true;\r
         process = getHwndProcess(GetForegroundWindow());\r
         startRecording();\r
@@ -270,4 +269,6 @@ WinMain(HINSTANCE hInstance,
   while (window.update()) {\r
     ws::update();\r
   }\r
   while (window.update()) {\r
     ws::update();\r
   }\r
+\r
+  return 0;\r
 }\r
 }\r
diff --git a/src/win.cpp b/src/win.cpp
deleted file mode 100644 (file)
index 6080291..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-#pragma comment(linker,"\"/manifestdependency:type='win32' \\r
-name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \\r
-processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")\r
-\r
-#include <windows.h>\r
-#include <CommCtrl.h>\r
-\r
-HWND hwndButton1;\r
-HWND hwndList1;\r
-\r
-const char g_szClassName[] = "MyWindowClass";\r
-\r
-LRESULT CALLBACK\r
-WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)\r
-{\r
-  switch (msg) {\r
-    case WM_CLOSE:\r
-      DestroyWindow(hwnd);\r
-      break;\r
-    case WM_DESTROY:\r
-      PostQuitMessage(0);\r
-      break;\r
-    case WM_COMMAND:\r
-      if (HIWORD(wParam) == BN_CLICKED) {\r
-        if ((HWND)lParam == hwndButton1) {\r
-          SendMessage(hwndList1, LB_ADDSTRING, 0, (LPARAM)"Hello");\r
-        }\r
-      }\r
-      break;\r
-    case WM_NOTIFY:\r
-      break;\r
-    default:\r
-      return DefWindowProc(hwnd, msg, wParam, lParam);\r
-  }\r
-  return 0;\r
-}\r
-\r
-int WINAPI\r
-WinMain(HINSTANCE hInstance,\r
-        HINSTANCE hPrevInstance,\r
-        LPSTR lpCmdLine,\r
-        int nCmdShow)\r
-{\r
-  WNDCLASSEX wc;\r
-  HWND hwnd;\r
-  MSG Msg;\r
-\r
-  // Step 1: Registering the Window Class\r
-  wc.cbSize = sizeof(WNDCLASSEX);\r
-  wc.style = 0;\r
-  wc.lpfnWndProc = WndProc;\r
-  wc.cbClsExtra = 0;\r
-  wc.cbWndExtra = 0;\r
-  wc.hInstance = hInstance;\r
-  wc.hIcon = LoadIcon(nullptr, IDI_APPLICATION);\r
-  wc.hCursor = LoadCursor(nullptr, IDC_ARROW);\r
-  wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);\r
-  wc.lpszMenuName = nullptr;\r
-  wc.lpszClassName = g_szClassName;\r
-  wc.hIconSm = LoadIcon(nullptr, IDI_APPLICATION);\r
-\r
-\r
-  if (!RegisterClassEx(&wc)) {\r
-    MessageBox(nullptr,\r
-               "Window Registration Failed!",\r
-               "Error!",\r
-               MB_ICONEXCLAMATION | MB_OK);\r
-    return 0;\r
-  }\r
-\r
-  // Step 2: Creating the Window\r
-  hwnd = CreateWindowA(g_szClassName,\r
-                        "The title of my window",\r
-                        WS_OVERLAPPEDWINDOW,\r
-                        CW_USEDEFAULT,\r
-                        CW_USEDEFAULT,\r
-                        CW_USEDEFAULT,\r
-                        CW_USEDEFAULT,\r
-                        nullptr,\r
-                        nullptr,\r
-                        hInstance,\r
-                        nullptr);\r
-\r
-  HWND tab = CreateWindowExA(0, WC_TABCONTROLA, "", WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS, 10, 10, 300, 300, hwnd, nullptr, nullptr, nullptr);\r
-  hwndButton1 = CreateWindowExA(0, WC_BUTTONA, "OK", WS_VISIBLE | WS_CHILD, 10, 10, 100, 100, tab, nullptr, nullptr, nullptr);\r
-  hwndList1   = CreateWindowExA(0, WC_LISTBOXA, "OK", WS_VISIBLE | WS_CHILD | WS_BORDER | WS_VSCROLL, 110, 10, 100, 100, tab, nullptr, nullptr, nullptr);\r
-\r
-  TCITEMA tie;\r
-  tie.mask = TCIF_TEXT;\r
-  tie.pszText = "Hallo";\r
-  TabCtrl_InsertItem(tab, 0, &tie);\r
-  tie.mask = TCIF_TEXT;\r
-  tie.pszText = "Ciao";\r
-  TabCtrl_InsertItem(tab, 1, &tie);\r
-\r
-  if (hwnd == nullptr) {\r
-    MessageBox(\r
-      nullptr, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);\r
-    return 0;\r
-  }\r
-\r
-  ShowWindow(hwnd, nCmdShow);\r
-  \r
-  UpdateWindow(hwnd);\r
-\r
-  EnumChildWindows(hwnd, [](HWND hwnd, LPARAM lParam) -> BOOL {\r
-    HFONT guiFont = (HFONT) GetStockObject(DEFAULT_GUI_FONT);\r
-    SendMessage(hwnd, WM_SETFONT, (WPARAM)guiFont, MAKELPARAM(TRUE, 0));\r
-    return TRUE;\r
-  }, 0);\r
-\r
-  // Step 3: The Message Loop\r
-  while (GetMessage(&Msg, nullptr, 0, 0) > 0) {\r
-    TranslateMessage(&Msg);\r
-    DispatchMessage(&Msg);\r
-  }\r
-  return Msg.wParam;\r
-}
\ No newline at end of file
index 058f69b707f776d84e95cdaa11c2128697909f1b..4bebc1fb22bb0481f33a27a0a0d3bc68dc76e01e 100644 (file)
--- a/src/ws.h
+++ b/src/ws.h
@@ -44,7 +44,7 @@ namespace ws
     }\r
 \r
     if (ev == MG_EV_ERROR) {\r
     }\r
 \r
     if (ev == MG_EV_ERROR) {\r
-      puts("Error");\r
+      printf("Error: %s\n", (char*)ev_data);\r
       done = true;\r
     }\r
     if (ev == MG_EV_CLOSE) {\r
       done = true;\r
     }\r
     if (ev == MG_EV_CLOSE) {\r
@@ -75,7 +75,7 @@ namespace ws
                       { "d",\r
                         {\r
                           { "requestType", requestType },\r
                       { "d",\r
                         {\r
                           { "requestType", requestType },\r
-                          { "requestId", std::to_string(NULL).c_str() }\r
+                          { "requestId", std::to_string(time(nullptr)).c_str() }\r
                         } } };\r
     auto requestStr = request.dump();\r
     mg_ws_send(c, requestStr.c_str(), requestStr.size(), WEBSOCKET_OP_TEXT);\r
                         } } };\r
     auto requestStr = request.dump();\r
     mg_ws_send(c, requestStr.c_str(), requestStr.size(), WEBSOCKET_OP_TEXT);\r