void readSettings()
{
	settings.showErrors = GetRCBoolDef("LSActiveDesktopShowErrors", TRUE) != FALSE;

	char line[MAX_LINE_LENGTH + 1];
	const char *tokenStart = line;
	char token[MAX_LINE_LENGTH + 1];
	GetRCLine("LSActiveDesktopWebWindows", line, MAX_LINE_LENGTH + 1, NULL);
	while (GetToken(tokenStart, token, &tokenStart, false)) {
		std::string name(token);
		std::transform(name.begin(), name.end(), name.begin(), tolower);

		LSADWebWndProp props;
		props.x = GetRCCoordinate((name + "X").c_str(), 0, GetSystemMetrics(SM_CXVIRTUALSCREEN));
		props.y = GetRCCoordinate((name + "Y").c_str(), 0, GetSystemMetrics(SM_CYVIRTUALSCREEN));
		props.width = GetRCInt((name + "Width").c_str(), 100);
		props.height = GetRCInt((name + "Height").c_str(), 100);
		props.showScrollbars = !(GetRCBool((name + "HideScrollbars").c_str(), TRUE) != FALSE);

		char url[MAX_LINE_LENGTH + 1];
		GetRCString((name + "URL").c_str(), url, "http://tlundberg.com", MAX_LINE_LENGTH + 1);
		props.url = url;

		settings.windowProperties.insert(make_pair(name, props));
	}
}
Example #2
0
BOOL LSUtils::PrefixedGetRCBool(LPCTSTR prefix, LPCTSTR setting, bool def)
{
	BOOL retValue;
	LPTSTR szTemp;
	AppendSetting(prefix, setting, szTemp);
	retValue = GetRCBool(szTemp, def);
#ifdef _DEBUG
	_LSLogPrintf(LOG_DEBUG, szLogName, "looking for setting: %s, got %d", szTemp, retValue);
#endif
	delete [] szTemp;	
	return retValue;
}
Example #3
0
File: hotkey.c Project: now/purels
void quitModule(HINSTANCE dllInst)
{
	int Msgs[10];
	
	Msgs[0] = LM_GETREVID;
	Msgs[1] = 0;
	SendMessage(parent, LM_UNREGISTERMESSAGE, (WPARAM) hMainWnd, (LPARAM) Msgs);
	freeHotkeys();
	if (GetRCBool("HotkeyLoadExplorerKeys", TRUE)){
		drizzt_FreeHotKeys ();
	}
	UnhookWindowsHookEx(hSystemHook);
	DestroyWindow(hMainWnd);
	UnregisterClass(szAppName, dllInst);
}
Example #4
0
File: hotkey.c Project: now/purels
int initModuleEx (HWND ParentWnd, HINSTANCE dllInst, LPCSTR szPath)
{
	int Msgs[10];
	strcpy (szLitestepPath, szPath);
	dll = dllInst;
	parent = ParentWnd;

    {
		WNDCLASS wc;

		memset(&wc, 0, sizeof(wc));
		wc.lpfnWndProc = WndProc;
		wc.hInstance = dllInst;
		wc.lpszClassName = szAppName;
		wc.style = 0;

		if (!RegisterClass(&wc))
		{  
			MessageBox(parent, "Error registering window class", szAppName, MB_OK);
			return 1;
		}
	}

	loadHotkeys();

	hMainWnd = CreateWindowEx(
		WS_EX_TOOLWINDOW,
		szAppName,
		"LSHotKey",
		WS_CHILD,
		0,
		0,
		0,
		0,
		parent,
		NULL,
		dllInst,
		NULL);
	
	Msgs[0] = LM_GETREVID;
	Msgs[1] = 0;
	SendMessage(parent, LM_REGISTERMESSAGE, (WPARAM) hMainWnd, (LPARAM) Msgs);
	if (GetRCBool("HotkeyLoadExplorerKeys", TRUE)){
		drizzt_InitHotKeys ();
	}
	return 0;
}
Example #5
0
File: hotkey.c Project: now/purels
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case LM_GETREVID:
		{
			char *buf = (char *) lParam;

			if (wParam == 0)
			{
				strcpy(buf, "hotkey.dll: ");
				strcat(buf, &rcsRevision[11]);
				buf[strlen(buf)-1] = '\0';
			}
			else if (wParam == 1)
			{
				strcpy(buf, &rcsId[1]);
				buf[strlen(buf)-1] = '\0';
			} else
			{
				strcpy(buf, "");
			}
			return strlen(buf);

		}
	case WM_ENDSESSION:
	case WM_QUERYENDSESSION:
		return SendMessage(parent,message,wParam,lParam);
	case WM_SYSCOMMAND:
		{
		switch (wParam)
			{
			case SC_CLOSE:
				PostMessage(parent,WM_KEYDOWN,LM_SHUTDOWN,0);
				return 0;
			default:
				return DefWindowProc(hwnd,message,wParam,lParam);
			}
		}

	case WM_CREATE:
		{
			int i;

			for (i=0;i<numHotkeys;i++)
			{
				RegisterHotKey(hwnd,i,hotkeys[i].sub,hotkeys[i].ch);
			}
			if (GetRCBool("HotkeyNoWinKeyPopup",FALSE)){
				if (!RegisterHotKey(hwnd, GlobalAddAtom("LWIN_KEY"),MOD_WIN, VK_LWIN)){
					MessageBox(NULL,"Error registering Win Key",szAppName,MB_OK);
				}
				if (!RegisterHotKey(hwnd, GlobalAddAtom("RWIN_KEY"),MOD_WIN, VK_RWIN)){
					MessageBox(NULL,"Error registering Win Key",szAppName,MB_OK);
				}
			}
			if (GetRCBool("LSNoShellWarning", FALSE) && GetRCBool("ExplorerNoWarn", FALSE)){
				if (!RegisterHotKey(hwnd, GlobalAddAtom("CTL_ESC"),MOD_CONTROL,VK_ESCAPE)){
					MessageBox(NULL,"Error registering Ctrl+Esc",szAppName,MB_OK);
				}
			} 
		}
		return 0;

	case WM_DESTROY:
		UnregisterHotKey(hwnd, GlobalFindAtom("LWIN_KEY"));
		UnregisterHotKey(hwnd, GlobalFindAtom("RWIN_KEY"));
		UnregisterHotKey(hwnd, GlobalFindAtom("CTL_ESC"));
		GlobalDeleteAtom(GlobalFindAtom("LWIN_KEY"));
		GlobalDeleteAtom(GlobalFindAtom("RWIN_KEY"));
		GlobalDeleteAtom(GlobalFindAtom("CTL_ESC"));
		return 0;

	case WM_ERASEBKGND: 
		return 0;

	case WM_PAINT:  
		return 0;

	case WM_HOTKEY:
		{
			if (wParam <  (WPARAM) numHotkeys)
			{
				int num = wParam;

				if (lstrlen(hotkeys[num].szCommand))
				{
					if (hotkeys[num].szCommand[0] == '!') {
						KillTimer(hwnd, 1);
						ParseBangCommand(hwnd, hotkeys[num].szCommand, hotkeys[num].szParameters);
					} else {
			            char workDirectory[_MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR];

						_splitpath(hotkeys[num].szCommand, drive, dir, NULL, NULL);
						strcpy(workDirectory, drive);
						strcat(workDirectory, dir);

						LSExecuteEx(GetDesktopWindow(), NULL, hotkeys[num].szCommand, hotkeys[num].szParameters, workDirectory, SW_SHOWNORMAL);

						KillTimer(hwnd, 1);
						/*
						SHELLEXECUTEINFO si;
						char workDirectory[MAX_PATH];
						char drive[_MAX_DRIVE];
						char dir[_MAX_DIR];
		
						_splitpath(hotkeys[num].szCommand, drive, dir, NULL, NULL);
						strcpy(workDirectory, drive);
						strcat(workDirectory, dir);
						memset(&si, 0, sizeof(si));
						si.cbSize = sizeof(SHELLEXECUTEINFO);
						si.lpDirectory = workDirectory;
						si.lpVerb = NULL;
						si.nShow = 1;
						si.fMask = SEE_MASK_DOENVSUBST;
						si.lpFile = hotkeys[num].szCommand;
						si.lpParameters = hotkeys[num].szParameters;
						ShellExecuteEx(&si);
						*/
					}
				}
			}
			else
			{
				char szCommand[1024];

				if (GlobalGetAtomName((ATOM)wParam, szCommand, 1024) > 0)
				{
					if (!strcmp(szCommand, "CTL_ESC"))
						SendMessage(parent, LM_POPUP, 0, 0);
					else if (!strcmp(szCommand, "REINIT") && GetRCBool("HotkeyLoadExplorerKeys", TRUE)) {
						drizzt_FreeHotKeys();
						drizzt_InitHotKeys();
					} else if (!strcmp(szCommand, "LWIN_KEY")) {
						SetTimer(hwnd, 1, 750, NULL);
					} else if (!strcmp(szCommand, "RWIN_KEY")) {
						SetTimer(hwnd, 1, 750, NULL);
					} else {
						KillTimer(hwnd, 1);
						if (GetRCBool("HotkeyLoadExplorerKeys", TRUE)){
							drizzt_execute(szCommand, NULL, NULL);
						}
					}
				}
			}

			break;
		}
	case WM_TIMER:
		if (wParam == 1) {
			ParseBangCommand(hwnd, "!Popup", NULL);
			KillTimer(hwnd, 1);
		}
	}
	return DefWindowProc(hwnd,message,wParam,lParam);
}