master | develop |
---|---|
CreviceApp is a mouse gesture utility which is consisted of small and robust core of 2000 lines fully tested, thin GUI wrapper, and Microsoft Roslyn. Mouse gestures can be defined as a csx file, so there is nothing that can not be done.[citation needed]
This software requires Windows 7 or later, and .Net Framework 4.6.
After the first startup of CreviceApp.exe
, move to %APPDATA%\Crevice\CreviceApp
, and you could find default.csx
. It's the user script file. Please open it with a text editor and take a look at it.
It is merely a csharp script file. You can use #load
directive to load another csx file and can use #r
directive to add assembly references to the script. By default, the script has the assembly references to microlib.dll
, System.dll
, System.Core.dll
, Microsoft.CSharp.dll
and CreviceApp.exe
. In other words, if there need to add an another assembly reference to the script, it should be declared by using #r
directive at the head of the script.
For more details, see Directives - Interactive Window Β· dotnet/roslyn Wiki.
All mouse gesture definition starting from @when
clause represents the condition for the activation of a mouse gesture.
var Chrome = @when((ctx) =>
{
return ctx.ForegroundWindow.ModuleName == "chrome.exe";
});
The next @when
is @on
, the next will continue @if
, and @do
.
Chrome.
@on(RightButton).
@if(MoveDown, MoveRight).
@do((ctx) =>
{
SendInput.Multiple().
ExtendedKeyDown(VK_LCONTROL).
KeyDown(VK_W).
KeyUp(VK_W).
ExtendedKeyUp(VK_LCONTROL).
Send(); // Send Ctrl+W to Chrome
});
@on
caluse tells the system which mouse button will be used at start of the gesture.
@on
clause takes an argument any of following; LeftButton
, MiddleButton
, RightButton
, X1Button
, X2Button
.
@if
clause tells the trigger of the action of the gesture.
And finally, @do
clause represents the action of the gesture to be activated when all given conditions to be satisfied.
"Mouse gestures by strokes", namely "stroke gesture" is in the functions of mouse gesture utilities, is the most important part. CreviceApp naturally supports this.
@if
clause takes arguments that consist of combination of MoveUp
, MoveDown
, MoveLeft
and MoveRight
. These are directions of movements of the mouse pointer.
Chrome.
@on(RightButton).
@if(MoveUp, MoveDown, MoveLeft, MoveRight, ...). // There is no limit on the length.
@do((ctx) => {
SendInput.Multiple().
ExtendedKeyDown(VK_LCONTROL).
ExtendedKeyDown(VK_LSHIFT).
KeyDown(VK_T).
KeyUp(VK_T).
ExtendedKeyUp(VK_LSHIFT).
ExtendedKeyUp(VK_LCONTROL).
Send(); // Send Ctrl+Shift+T to Chrome
});
As you may know, mouse gestures with buttons is called "rocker gestures" in mouse gesture utility communities.
But we call it "button gestures" here.
CreviceApp supports two kinds of button gestures.
Both these button gestures are almost the same except that the one have @on
clause and the other do not have it.
@if
clause takes an argument any of following; LeftButton
, MiddleButton
, RightButton
, WheelUp
, WheelDown
, WheelLeft
, WheelRight
, X1Button
, X2Button
.
Chrome.
@on(RightButton).
@if(WheelDown).
@do((ctx) =>
{
SendInput.Multiple().
ExtendedKeyDown(VK_CONTROL).
ExtendedKeyDown(VK_TAB).
ExtendedKeyUp(VK_TAB).
ExtendedKeyUp(VK_CONTROL).
Send(); // Send Ctrl+Tab to Chrome
});
Chrome.
@if(WheelLeft).
@do((ctx) =>
{
SendInput.Multiple().
ExtendedKeyDown(VK_LMENU).
ExtendedKeyDown(VK_LEFT).
ExtendedKeyUp(VK_LEFT).
ExtendedKeyUp(VK_LMENU).
Send(); // Send Alt+Left to Chrome
});
@do
clause is just simple but does not fit to cases where there is need to hook push / release events of mouse buttons. @before
and @after
clauses support it. These can be written just after @if
clause given with a double action mouse button any of following; LeftButton
, MiddleButton
, RightButton
, X1Button
, X2Button
.
var Whenever = @when((ctx) => {
return true;
});
// Convert X1Button to Win-key.
Whenever.
@if(X1Button).
@before((ctx) =>
{
SendInput.ExtendedKeyDown(VK_LWIN);
}).
@after((ctx) =>
{
SendInput.ExtendedKeyUp(VK_LWIN);
});
Actions given in @before
and @after
clauses are different from it of @do
clause, the execution of these actions are assured.
Whenever.
@if(X2Button).
@before((ctx) =>
{
// Assured.
}).
@do((ctx) =>
{
// Not assured.
// e.g. When the gesture to timeout,
// this action will not be executed.
}).
@after((ctx) =>
{
// Assured.
});
Note 1: Calling @before
and @after
clauses from @if
clause given with a single action mouse button causes compilation error because the event of these buttons can not be separated into two parts.
Note 2: Even if you specify a part of @before
or @after
, the other one will automatically be captured and be ignored. This is the limitation on the specification. When you want to set a hook to the one, and want to bypass the other one, you should do it by your hands.
The system default parameters can be configured by using Config
as following:
// When moved distance of the cursor is exceeded this value, the first stroke
// will be established.
Config.Gesture.InitialStrokeThreshold = 10;
// When moved distance of the cursor is exceeded this value, and the direction is changed,
// new stroke for new direction will be established.
Config.Gesture.StrokeDirectionChangeThreshold = 20;
// When moved distance of the cursor is exceeded this value, and the direction is not changed,
// it will be extended.
Config.Gesture.StrokeExtensionThreshold = 10;
// Interval time for updating strokes.
Config.Gesture.WatchInterval = 10; // ms
// When stroke is not established and this period of time has passed,
// the gesture will be canceled and the original click event will be reproduced.
Config.Gesture.Timeout = 1000; // ms
// The period of time for showing a tooltip message.
Config.UI.TooltipTimeout = 3000; // ms
// The period of time for showing a baloon message.
Config.UI.BaloonTimeout = 10000; // ms
// Binding for the position of tooltip messages.
Config.UI.TooltipPositionBinding = (point) =>
{
var newPoint = // Create new point.
return newPoint;
}
@when
and @do
clause take an argument of a function, and the function takes an argument of an ExecutionContext
.
An ExecutionContext
will be generated each time a gesture started, and the same instance will be passed to the actions of @when
and @do
to guarantee that these actions to be executed on the same context.
The window which was on the foreground when a gesture started.
This is an instance of WindowInfo
.
The window which was under the cursor when a gesture started.
This is an instance of WindowInfo
.
WindowInfo
is a thin wrapper of the handle of a window. This class provides properties and methods to use window handles more easily.
This class provides properties as following; WindowHandle
, ThreadId
, ProcessId
, WindowId
, Text
, ClassName
, Parent
, ModulePath
, ModuleName
.
A shortcut to win32 API SendMessage(WindowHandle, Msg, wParam, lParam)
.
This function returns a long
value directly from win32 API.
A shortcut to win32 API PostMessage(WindowHandle, Msg, wParam, lParam)
.
This function returns a bool
value directly from win32 API.
A shortcut to win32 API BringWindowToTop(WindowHandle)
.
This function returns a bool
value directly from win32 API.
A shortcut to win32 API FindWindowEx(WindowHandle, hwndChildAfter, lpszClass, lpszWindow)
.
This function returns an instance of WindowInfo
.
A shortcut to win32 API FindWindowEx(WindowHandle, IntPtr.Zero, lpszClass, lpszWindow)
.
This function returns an instance of WindowInfo
.
A shortcut to win32 API EnumChildWindows(WindowHandle, EnumWindowProc, IntPtr.Zero)
.
This function returns an instance of IEmumerable<WindowInfo>
.
A shortcut to win32 API ChildWindowFromPointEx(hWnd, point, flags)
.
This function recursively calls ChildWindowFromPointEx
until the last descendant window and returns an instance of IEmumerable<WindowInfo>
.
A shortcut to win32 API ChildWindowFromPointEx(hWnd, point, Window.WindowFromPointFlags.CWP_ALL)
.
This function recursively calls ChildWindowFromPointEx
until the last descendant window and returns an instance of IEmumerable<WindowInfo>
.
Brings window into the foreground and activates the window.
Send mouse and keyboard input events to the foreground window.
This API provides single and multiple sending method.
The events sent by single sending method is guaranteed to arrive to the window in order, but this does not necessarily mean it will not be interrupted by the other events.
Multiple sending method guarantees that the events sent by it will not be interrupted by the other events.
Both methods support the same API for sending mouse and keyboard events except that multiple sending method is need to be called Send()
at last.
SendInput.ExtendedKeyDown(VK_LWIN);
// When D key interrupts here,
// Win+D will be invoked unintentionally.
SendInput.ExtendedKeyUp(VK_LWIN);
SendInput.Multiple().
ExtendedKeyDown(VK_LWIN).
ExtendedKeyUp(VK_LWIN).
Send(); // This won't be interrupted by any other input.
Down
, Up
, and Click
events are supported for the push-release type buttons of mouse devices as following; LeftButton
, MiddleButton
, RightButton
, X1Button
, X2Button
. For example, the provided API for LeftButton
is LeftDown()
, LeftUp()
and LeftClick()
.
For single push type buttons, WheelUp()
, WheelDown()
, WheelLeft()
and WheelRight()
are provided.
For move events, Move(int dx, int dy)
and MoveTo(int x, int y)
are provided.
- LeftDown()
- LeftUp()
- LeftClick()
- RightDown()
- RightUp()
- RightClick()
- Move(int dx, int dy)
- MoveTo(int x, int y)
- MiddleDown()
- MiddleUp()
- MiddleClick()
- VerticalWheel(short delta)
- WheelDown()
- WheelUp()
- HorizontalWheel(short delta)
- WheelLeft()
- WheelRight()
- X1Down()
- X1Up()
- X1Click()
- X2Down()
- X2Up()
- X2Click()
A keyboard event is synthesized from a key code and two logical flags, ExtendedKey
and ScanCode
. For sending Up
and Down
events, KeyDown(ushort keyCode)
and KeyUp(ushort keyCode)
are provided.
SendInput.KeyDown(VK_A);
SendInput.KeyUp(VK_A); // Send `A` to the foreground application.
ExetendedKeyDown(ushort keyCode)
and ExtentedKeyUp(ushort keyCode)
are provided when ExtendedKey
flag is needed to be set.
SendInput.ExetendedKeyDown(VK_LWIN);
SendInput.ExtentedKeyUp(VK_LWIN); // Send `Win` to the foreground application.
For four API above mentioned, combined it with ScanCode
flag,
KeyDownWithScanCode(ushort keyCode)
, KeyUpWithScanCode(ushort keyCode)
, ExtendedKeyDownWithScanCode(ushort keyCode)
and ExtendedKeyUpWithScanCode(ushort keyCode)
are provided.
SendInput.ExtendedKeyDownWithScanCode(VK_LCONTROL);
SendInput.KeyDownWithScanCode(VK_S);
SendInput.KeyUpWithScanCode(VK_S);
SendInput.ExtendedKeyUpWithScanCode(VK_LCONTROL); // Send `Ctrl+S` with scan code to the foreground application.
And finally, for to support Unicode
flag, following functions are provided; UnicodeKeyDown(char c)
, UnicodeKeyUp(char c)
, UnicodeKeyStroke(string str)
.
SendInput.UnicodeKeyDown('π£');
SendInput.UnicodeKeyUp('π£'); // Send `Sushi` to the foreground application.
Note: keyCode
is a virtual key code. See VirtualKeys.
- KeyDown(ushort keyCode)
- KeyUp(ushort keyCode)
- ExtendedKeyDown(ushort keyCode)
- ExtendedKeyUp(ushort keyCode)
- KeyDownWithScanCode(ushort keyCode)
- KeyUpWithScanCode(ushort keyCode)
- ExtendedKeyDownWithScanCode(ushort keyCode)
- ExtendedKeyUpWithScanCode(ushort keyCode)
- UnicodeKeyDown(char c)
- UnicodeKeyUp(char c)
- UnicodeKeyStroke(string str)
Show tooltip message at the right bottom corner of the display on the cursor.
Tooptip("This is tooltip.");
Show a tooltip message at the specified position.
Show a tooltip message at the specified position for a specified period.
Show a baloon message.
Baloon("This is baloon.");
Show a baloon message and a title.
Show a baloon message and a title for a specified period.
Show a baloon message, a title, and a icon.
Show a baloon message, a title, and a icon for a specified period.
This class provides the virtual key constants.
Note: for VK_0
to VK_9
and VK_A
to VK_Z
, this is an extension for convenience limited in this application.
To use this class, declare as following:
using static CreviceApp.WinAPI.Constants.VirtualKeys;
For more details, see Virtual-Key Codes (Windows).
This class provides the windows message constants. To use this class, declare as following:
using static CreviceApp.WinAPI.Constants.WindowsMessages;
For more details, see Window Messages (Windows).
Window
is a utility static class about Windows's window.
To use this class, declare as following:
using CreviceApp.WinAPI.Window;
This function wraps IntPtr
and returns an instance of WindowInfo
.
Returns current position of the cursor.
This function returns an instance of Point
.
Returns a window under the cursor.
This function returns an instance of WindowInfo
.
Find a window matches given class name and window name.
This function returns an instance of WindowInfo
.
Enumerates all windows.
This function returns an instance of IEnumerable<WindowInfo>
.
Enumerates all windows belonging specified thread.
This function returns an instance of IEnumerable<WindowInfo>
.
VolumeControl
is a utility class about system audio volume.
To use this class, declare as following:
using CreviceApp.WinAPI.CoreAudio;
var VolumeControl = new VolumeControl();
Returns window's current master mixer volume.
This function returns a float
value, within the range between 0 and 1.
Sets window's current master mixer volume. The value should be within the range between 0 and 1.
MIT Lisense
Branch | Status | Download |
---|---|---|
master | crevice.zip | |
develop | crevice.zip |