-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create header, add installer and disallow multiple instances
- Loading branch information
1 parent
f2cd7e0
commit b9774f9
Showing
7 changed files
with
167 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
; Script generated by the Inno Setup Script Wizard. | ||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! | ||
|
||
#define MyAppName "Resizer 2" | ||
#define MyAppVersion "4" | ||
#define MyAppPublisher "Alve Svarén" | ||
#define MyAppURL "https://github.com/alvesvaren/resizer2" | ||
#define MyAppExeName "resizer2.exe" | ||
|
||
[Setup] | ||
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. | ||
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) | ||
AppId={{3C32B837-6368-48A2-A026-F0EB8B1E6311} | ||
AppName={#MyAppName} | ||
AppVerName={#MyAppName} v{#MyAppVersion} | ||
AppPublisher={#MyAppPublisher} | ||
AppPublisherURL={#MyAppURL} | ||
AppSupportURL={#MyAppURL} | ||
AppUpdatesURL={#MyAppURL} | ||
DefaultDirName={autopf}\Resizer2 | ||
; "ArchitecturesAllowed=x64compatible" specifies that Setup cannot run | ||
; on anything but x64 and Windows 11 on Arm. | ||
ArchitecturesAllowed=x64compatible | ||
; "ArchitecturesInstallIn64BitMode=x64compatible" requests that the | ||
; install be done in "64-bit mode" on x64 or Windows 11 on Arm, | ||
; meaning it should use the native 64-bit Program Files directory and | ||
; the 64-bit view of the registry. | ||
ArchitecturesInstallIn64BitMode=x64compatible | ||
DefaultGroupName={#MyAppName} | ||
AppMutex=Resizer2Mutex | ||
AllowNoIcons=yes | ||
; Uncomment the following line to run in non administrative install mode (install for current user only.) | ||
;PrivilegesRequired=lowest | ||
OutputBaseFilename=resizer2-setup | ||
Compression=lzma | ||
SolidCompression=yes | ||
WizardStyle=modern | ||
|
||
[Languages] | ||
Name: "english"; MessagesFile: "compiler:Default.isl" | ||
|
||
[Tasks] | ||
Name: "autostart"; Description: "Start Resizer 2 (as administrator) automatically with Windows"; GroupDescription: "Other Tasks"; | ||
|
||
[Files] | ||
Source: "C:\Users\alve\source\repos\resizer2\x64\Release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion | ||
|
||
[Icons] | ||
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" | ||
|
||
[Run] | ||
Filename: "schtasks"; Parameters: "/Delete /TN ""Resizer2"" /F"; Flags: runhidden; | ||
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent runascurrentuser | ||
Filename: "schtasks"; Parameters: "/Create /TN ""Resizer2"" /TR ""\""{app}\{#MyAppExeName}""\"" /SC ONLOGON /RL HIGHEST"; Flags: runhidden; Tasks: autostart | ||
|
||
[UninstallRun] | ||
Filename: "schtasks"; Parameters: "/Delete /TN ""Resizer2"" /F"; Flags: runhidden; RunOnceId: "autostart-task-remove" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#pragma once | ||
|
||
#include <windows.h> | ||
#include <iostream> | ||
#include <chrono> | ||
|
||
#pragma comment(lib, "user32.lib") | ||
|
||
#define TRAY_ICON_UID 1001 | ||
#define WM_TRAYICON (WM_USER + 1) | ||
|
||
// Config | ||
const int DOUBLE_CLICK_THRESHOLD = 300; // ms | ||
const BYTE MIN_OPACITY = 64; | ||
const BYTE MAX_OPACITY = 255; | ||
const BYTE OPACITY_STEP = 26; // Around 10% of 255 | ||
const int DUMMY_KEY = VK_F13; // Any key that doesn't do anything when pressed together with the Windows key | ||
|
||
enum ContextType { | ||
MOVE, | ||
RESIZE | ||
}; | ||
|
||
struct Context { | ||
bool inProgress = false; | ||
HANDLE hEvent = NULL; | ||
POINT startMousePos{}; | ||
RECT startWindowRect{}; | ||
HWND targetWindow = NULL; | ||
ContextType operationType; | ||
}; | ||
|
||
struct MonitorSearchData { | ||
int x, y; | ||
HMONITOR hMonitor; | ||
}; | ||
|
||
enum ResizerCursor { | ||
SIZEALL, | ||
SIZENWSE, | ||
SIZENESW, | ||
UNSET, | ||
}; | ||
|
||
// Declarations | ||
extern const int systemCursors[]; | ||
|
||
extern Context ctx; | ||
extern HHOOK hKeyboardHook; | ||
extern HHOOK hMouseHook; | ||
extern bool modKeyPressed; | ||
extern bool didUseWindowsKey; | ||
extern bool shouldMinimize; | ||
extern std::chrono::steady_clock::time_point lastClickTime; | ||
extern NOTIFYICONDATA nid; | ||
|
||
LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam); | ||
LRESULT CALLBACK LowLevelMouseProc(int nCode, WPARAM wParam, LPARAM lParam); | ||
DWORD WINAPI WindowOperationThreadProc(LPVOID lpParam); | ||
|
||
void adjustWindowOpacity(int change); | ||
void minimizeWindow(); | ||
template <ContextType type> | ||
void startWindowOperation(); | ||
void stopWindowOperation(); | ||
HWND getTopLevelParent(HWND hwnd); | ||
void snapToMonitor(HWND window, HMONITOR screen); | ||
template <ResizerCursor cursor> | ||
void SetGlobalCursor(); | ||
void AddTrayIcon(HWND hWnd); | ||
void RemoveTrayIcon(); | ||
LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); | ||
BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData); | ||
HMONITOR SysGetMonitorContainingPoint(int x, int y); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters