Careful with this rm -rf

November 11, 2003 on 8:14 pm | In General | 2 comments

“Coincidence?”:http://www.raibledesigns.com/page/rd?anchor=need_to_recover_deleted_files

I removed two projects in a row by tab-completing after rm -rf. Well, I’ll start the projects from scratch, but this serves me good.

FreeSnap002.jpg

Related Posts:

wxWindows Makefile template for Mac OS X

November 8, 2003 on 10:16 pm | In General | 4 comments

This Makefile contains the bare minimum to quickly create a Mac OS X application bundle for a wxWindows program. To use, simply add the proper directives to the Makefile and change various settings, such as the paths.

Technorati Tags: , , ,

Related Posts:

Capturing keystrokes with GetAsyncKeyState

November 5, 2003 on 3:09 pm | In General | 4 comments

An easy way to capture keystrokes in an application even if it is not the active one is by using the API function, GetAsyncKeyState, of the User32 DLL.

The trick is to set up a timer that regularly checks for the state of certain keys with GetAsyncKeyState

Here is an example:

using System;
using System.Windows.Forms;

public class Test {

	protected Timer timer = null;

	public Test {
		timer = new Timer();
		timer.Interval = 100; // check the keystate every 100ms
		timer.Click += new EventHandler(OnTimerTick);
		timer.Start();
	}

	private void OnTimerTick(Object sender, EventArgs args) {
		bool hotKeyPressed = true;
		// check the status of the left Windows key and the
		// right Control key
		Keys[] keys = {Keys.LWin, Keys.RControlKey};
		for (int i = 0; i < keys.Length; i++) {
			hotKeyPressed &= (GetAsyncKeyState( (int) keys[i]) & 0x8000) == 0x8000;
		}
		if (hotKeyPressed) {
			// do something
		}
	}

	// we expose the API function in the following lines
	[DllImport("User32.Dll")]
	private static extern int GetAsyncKeyState(int keyCode);

}

This technique is used in “TiBar”:http://www.jeysoft.com to detect whether the application launcher is being called.

Related Posts:




Powered by blog.mu with Pool theme design by Borja Fernandez.