Skip to content

Commit 73a7121

Browse files
committed
Add sample script
1 parent 0605b94 commit 73a7121

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

src/SampleScript/sample_key.csx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#r "PresentationCore"
2+
3+
using System.Diagnostics;
4+
using System.Windows.Input;
5+
6+
enum DebugMode : byte
7+
{
8+
None = 0x00,
9+
MouseOnly = 0x01,
10+
KeyOnly = 0x02,
11+
CreateLog = 0x04
12+
};
13+
14+
SetMode( ( byte )DebugMode.KeyOnly | ( byte )DebugMode.CreateLog );
15+
16+
Process.Start( "Notepad" );
17+
Delay(500);
18+
19+
KeyInput( Key.A );
20+
PressKey( (ushort)KeyInterop.VirtualKeyFromKey( Key.LeftShift ) );
21+
KeyInput( Key.B );
22+
KeyInput( Key.C );
23+
ReleaseKey( (ushort)KeyInterop.VirtualKeyFromKey( Key.LeftShift ) );
24+
PressKey( (ushort)KeyInterop.VirtualKeyFromKey( Key.LeftCtrl ) );
25+
KeyInput( Key.S );
26+
ReleaseKey( (ushort)KeyInterop.VirtualKeyFromKey( Key.LeftCtrl ) );
27+
28+
void KeyInput( Key key )
29+
{
30+
ushort virtualKey = (ushort)KeyInterop.VirtualKeyFromKey( key );
31+
32+
PressKey( virtualKey );
33+
Delay( 100 );
34+
ReleaseKey( virtualKey );
35+
Delay( 100 );
36+
}

src/SampleScript/sample_mouse.csx

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
[Flags]
5+
enum DebugMode : byte
6+
{
7+
None = 0x00,
8+
MouseOnly = 0x01,
9+
KeyOnly = 0x02,
10+
CreateLog = 0x04
11+
};
12+
13+
SetMode( ( byte )DebugMode.MouseOnly | ( byte )DebugMode.CreateLog );
14+
15+
SetCoordinate(100, 100);
16+
SetCoordinate(200, 100);
17+
SetCoordinate(300, 100);
18+
SetCoordinate(400, 100);
19+
SetCoordinate(500, 100);
20+
SetCoordinate(600, 100);
21+
SetCoordinate(700, 100);
22+
SetCoordinate(800, 100);
23+
SetCoordinate(900, 100);
24+
SetCoordinate(1000, 100);
25+
26+
WriteCustomLog( "test custom log" );
27+
28+
SetCoordinate(900, 100);
29+
SetCoordinate(800, 100);
30+
SetCoordinate(700, 100);
31+
SetCoordinate(600, 100);
32+
SetCoordinate(500, 100);
33+
SetCoordinate(400, 100);
34+
SetCoordinate(300, 100);
35+
SetCoordinate(200, 100);
36+
SetCoordinate(100, 100);
37+
38+
void SetCoordinate( int x, int y )
39+
{
40+
SetMousePos( x, y );
41+
Delay( 100 );
42+
}
43+
44+
void WriteCustomLog( string message )
45+
{
46+
var userCustomDic = new Dictionary<string, string>
47+
{
48+
{ "ScriptName", "sample_mouse" },
49+
{ "Message", message }
50+
};
51+
52+
WrileUserCustomLog( userCustomDic );
53+
54+
}

0 commit comments

Comments
 (0)