G-Trigger v0.9.0 beta [02-Jul-2009]
By Krupal Desai

Visit website: http://g-trigger.kneps.com

G-Trigger is a G-Sensor based ^shake^ detector application. It allows to trigger a predefined
action on shaking your windows mobile phone (built-in with G-Sensor) in particular direction. 
Currently it is in development phase, so please bare the bugs.

Supported shaking directions:
    * Horizontally
          o Left to right
          o Right to left
    * Vertically
          o Top to bottom
          o Bottom to top
    * Front & Back
          o Front to back
          o Back to front

It will trigger the specified action when phone is forcibly moved from left to right or moved 
as above mentioned directions. Also you can assign different actions with keeping device face 
up and shaking device in any of the above action or keeping device face down and shaking 
device in any of the above action.

Supported actions:
    * Close/Minimize active window
    * Dial a number
    * Answer/Reject incoming call
    * Launch Program
    * Ringer Loud/Vibrate/Silent
    * Screen orientation
    * Send Keys$
    * Task Switch
    * Screen On/Off/Toggle
    * Media Control# (Play/Pause/Next/Previous/Volume)
    * WiFi/Bluetooth/Phone Radio - On/Off/Toggle
    * Volume Change
    * Simulate Power Button
    * Open Control Panel Settings
    * Activate Profile
	* Save Screenshot (BMP/JPG/PNG/GIF at predefined location)
    * Change Wallpaper (Today Screen, Manila Home & S2U2) 
	* Show/Hide/Toggle On-Screen Keyboard (SIP)

$Using Send Keys:
(Reference: http://msdn.microsoft.com/en-au/library/system.windows.forms.sendkeys.aspx)

The plus sign (+), caret (^), percent sign (%), tilde (~), and parentheses () have special 
meanings to SendKeys. To specify one of these characters, enclose it within braces ({}). 
For example, to specify the plus sign, use "{+}". To specify brace characters, use "{{}" 
and "{}}". Brackets ([ ]) have no special meaning to SendKeys, but you must enclose them 
in braces.

To specify that any combination of SHIFT (+), CTRL (^), and ALT (%) should be held down while
several other keys are pressed, enclose the code for those keys in parentheses. For example, 
to specify to hold down SHIFT while E and C are pressed, use "+(EC)". To specify to hold down 
SHIFT while E is pressed, followed by C without SHIFT, use "+EC".

To specify repeating keys, use the form {key number}. You must put a space between key 
and number. For example, {LEFT 42} means press the LEFT ARROW key 42 times; {h 10} 
means press H 10 times.

#Currently supported media players are
    * Windows Media Player
    * S2P
    * Microfi Nitrogen
    * Core Player
    * TCPMP
    * Pocket Player
    * Pocket Music
    * Manila (TF3D) Music Tab

Features:
Customized actions
    You can assign any of the customized actions as mentioned above to any of the supported shaking 
    directions. Action will be triggered when you shake your phone in proper configured direction.

    For example: Launch calculator by shaking your phone from top to bottom or Launch S2U2 by shaking 
    your phone from bottom to top.

Conditional actions
    You can specify a particular condition which will be monitored before triggering an action and if 
    condition is matched action will be triggered otherwise ignored.

    For example: Play next track by shaking your phone from left to right only if Windows Media Player 
    is active.  

Suspend exceptions
    As G-Trigger Service continuously polls the G-Sensor to detect shake it might affect the other
    applications which uses the G-Sensor. Thus you can add such applications as suspend exception to 
    G-Trigger. When it will find any application from the suspend exceptions list as active, G-Trigger
    Service will be suspended, i.e. it will not access G-Sensor till that application is active.

    For example: Suspend the G-Trigger Service when Teeter is active.

Disable action exceptions
    Actions will be ignored if any of the application specified in the list of disable action exceptions 
    is active. Polling the G-Sensor will be continued by the G-Trigger Service no matter such application 
    is active or not. It is mainly kept to utilize the purpose of "Override disable action exceptions" 
    which can be activated from "Conditional actions".

    For example: If S2U2 is active no actions should be triggered, but you still want some actions like 
    "Media control Play/Pause/Next/Previous" to trigger. So put S2U2 in disable action exception and check 
    "Override disable action exceptions" from conditional action settings.   

Run service on device startup
    G-Trigger Service should be running to trigger actions on shaking your phone. Thus this option can be
    set to run service automatically when device is restarted.

Individual threshold settings for all three directions; Horizontal, Vertical & Front-Back
    You can customize the threshold values for individual directions. Higher the threshold values more you 
    need to apply force while shaking your phone to trigger an action.

    For example: You want to play next/previous music tracks by lightly shaking the phone on horizontal 
    direction and you want to lock your phone only by shaking phone with force from Front to Back. Then 
    apply horizontal shaking threshold to lower value (12) and apply Front-Back shaking threshold to 
    higher value (30). 

Action feedback vibration settings
    You can set vibration duration from 0 to 100 ms which will be used as feedback when any shake is 
    detected and action is triggered. To turn off vibration feedback keep its value 0.

Action feedback play sound settings
    You can set to play a sound as feedback when any shake is detected and action is triggered. Sound file 
    is present at location "G-Trigger\Res\trigger.wav". You can use your own .wav file which should be less 
    than 300KB. 

Settings for On Screen Display of triggered actions
    You can set On Screen Display of action icon to be shown for specified duration (0 to 2000 ms) which 
    will be displayed on the screen when any shake is detected and action is triggered.

AppToDate support
    G-Trigger supports the AppToDate tool which helps you to download and install the latest G-Trigger build.

Known Facts:
    * OSD is displayed with some delay after event is occurred
    * Sometimes shake actions are not triggered when device is busy processing
    * G-Trigger Service is made suspended when device goes in to sleep mode (may impact battery life if 
      overridden)
    * Action Media Control "Stop" does not work for all players
    * Media controls for "Pocket Player" works till it's window is active or minimized (not working when in 
      notification mode)

Usage:
     Transfer .cab file to any location in device.
     Run the .cab file and install application to device storage.
     Run the G-Trigger shortcut from programs.
     Click New button on Action tab.
     Enable the check boxes for the actions you want to activate.
     Assign any action by clicking  button on the right side of action text box.
     Click Save button on edit profile page, again click Save button on main page.
     Click Start button to start the service.
     Shake your phone and enjoy!

How G-Trigger works:
    G-TriggerService.exe application runs all the time and polls the G-Sensor to get current position of 
    the device. It polls G-Sensor for about 10 times a second and observes the positions of the device. 
    It keeps track of last 5 positions and scans all the 5 positions and checks if any shake is detected. 
    If shake is detected it looks for action and triggers an action.

FAQ:
    1.	Does polling of G-Sensor all the time damages it?
    -	It does not seems to damage sensor by polling but I dont take any responsibility in a case. Use 
     	it at your own risk!

    2.	Does G-TriggerService impacts my devices battery power?
    -	Yes! It runs all the time as soon as your device is awake and it keeps on polling the G-Sensor, 
	so it will consume some battery power. Although, I am running it all the time since I developed, 
	I dont see any legible battery consumption. Though you need to benchmark if you want to see exact 
	battery consumption.

    3.	How much memory does G-TriggerService eats?
    -	G-TriggerService takes around 500KB when OSD is off and takes around 1MB if OSD is on.


NOTE: Although running this application does not seem to make any damage, I take 
no responsibility for any kind of damage caused to the device or data due to this 
application.

It is developed for HTC Touch Diamond. I have not tested it on any other device. Let me know if you try it on 
other device.

I accept donation:
http:\\g-trigger.kneps.com

Cheers!
Krupal Desai