Skip to content

Commit

Permalink
Merge pull request #6 from Apophenic/master
Browse files Browse the repository at this point in the history
Added support for user defined pause key
  • Loading branch information
ryanries committed Jun 11, 2015
2 parents daabbaa + 0cca502 commit 108165e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
22 changes: 20 additions & 2 deletions Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <Psapi.h>
#include <stdio.h>
#include "resource.h"
#include <fstream>
#include <string>

#define WM_TRAYICON (WM_USER + 1)

Expand Down Expand Up @@ -79,6 +81,23 @@ LRESULT CALLBACK WindowClassCallback(_In_ HWND Window, _In_ UINT Message, _In_ W
return(Result);
}

int readPauseKey()
{
std::ifstream settings("settings.txt");
std::string delimiter = "=";

for (std::string line; getline(settings, line);)
{
int delimiterPos = line.find(delimiter);
std::string option = line.substr(0, delimiterPos);
if (option == "KEY")
{
std::string value = line.substr(delimiterPos + 1, line.length());
return std::stoul(value, nullptr, 16);
}
}
}

// Entry point.
int CALLBACK WinMain(_In_ HINSTANCE Instance, _In_opt_ HINSTANCE, _In_ LPSTR, _In_ int)
{
Expand Down Expand Up @@ -146,7 +165,6 @@ int CALLBACK WinMain(_In_ HINSTANCE Instance, _In_opt_ HINSTANCE, _In_ LPSTR, _I
}

MSG SysTrayWindowMessage = { 0 };
static int PauseKeyWasDown = 0;
DWORD PreviouslySuspendedProcessID = 0;
wchar_t PreviouslySuspendedProcessText[256] = { 0 };
HANDLE ProcessHandle = 0;
Expand All @@ -158,7 +176,7 @@ int CALLBACK WinMain(_In_ HINSTANCE Instance, _In_opt_ HINSTANCE, _In_ LPSTR, _I
DispatchMessage(&SysTrayWindowMessage);
}

int PauseKeyIsDown = GetAsyncKeyState(VK_PAUSE);
int PauseKeyIsDown = GetAsyncKeyState(readPauseKey());

if (PauseKeyIsDown && !PauseKeyWasDown)
{
Expand Down
4 changes: 4 additions & 0 deletions settings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
KEY=0x13

FOR KEY VALUES, SEE:
https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx

0 comments on commit 108165e

Please sign in to comment.