Skip to content

Commit

Permalink
Auto-start changes:
Browse files Browse the repository at this point in the history
- Fix: program can't found Spammy.json
- Fix: minimized state
  • Loading branch information
FrostAtom committed Sep 11, 2022
1 parent 043b31c commit 51e74e7
Show file tree
Hide file tree
Showing 34 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
add_subdirectory( Exe )
add_subdirectory( Spammy )
12 changes: 10 additions & 2 deletions src/Exe/App.cpp → src/Spammy/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

App* App::_self = NULL;

App::App(int argc, wchar_t* argv[])
App::App(int argc, char** argv)
: _isRunning(false), _enabled(false), _mainWindow(NULL), _autoStartEnabled(false),
_lastUpdate(0), _activeHwnd(NULL), _activeProfile(NULL), _editingProfile(NULL)
{
_self = this;

wchar_t buf[MAX_PATH];
GetCurrentDirectoryW(std::size(buf), buf);
GetModuleFileNameW(NULL, buf, std::size(buf));
SetCurrentDirectoryW(std::filesystem::path(buf).parent_path().wstring().c_str());

if (!loadConfig()) {
int action = MessageBoxW(NULL, L"Can't load config, reset to defaults?", L"" APP_NAME, MB_ICONQUESTION | MB_OKCANCEL);
if (action != IDOK) return;
Expand All @@ -17,6 +22,9 @@ App::App(int argc, wchar_t* argv[])
_mainWindow = new MainWindow(L"" APP_NAME);
if (!_mainWindow->initialize()) return;

if (argc > 1 && strcmp(argv[1], "autolaunch") == 0)
_mainWindow->hide();

sKeyboard.atttach();
sKeyboard.onPress(std::bind_front(&App::onKeyPress, this));
sKeyboard.onRelease(std::bind_front(&App::onKeyRelease, this));
Expand Down Expand Up @@ -296,7 +304,7 @@ void App::onFocusChanged()
_activeProfile = findProfileByApp((const char*)path.filename().u8string().c_str());
}

auto main(int argc, wchar_t* argv[]) -> int
int main(int argc, char** argv)
{
std::unique_ptr<App> app(new App(argc, argv));
return app->run();
Expand Down
3 changes: 1 addition & 2 deletions src/Exe/App.h → src/Spammy/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class App {
Profile* _activeProfile, *_editingProfile;

public:
App(int argc, wchar_t* argv[]);
App(int argc, char** argv);
~App();

static App& instance();
Expand Down Expand Up @@ -54,7 +54,6 @@ class App {
void saveConfig();

void onFocusChanged();
void onWindowUpdate();
bool onKeyPress(UINT vkCode, bool repeat);
bool onKeyRelease(UINT vkCode, bool repeat);
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/Exe/Window/Window.cpp → src/Spammy/Window/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ bool Window::isNormalized()

void Window::show()
{
if (_hwnd) ShowWindow(_hwnd, SW_NORMAL);
if (_hwnd) ShowWindow(_hwnd, SW_SHOWNORMAL);
}

void Window::hide()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 51e74e7

Please sign in to comment.