win32-autogui 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. data/.gitattributes +1 -0
  2. data/.gitignore +10 -0
  3. data/.yardopts +6 -0
  4. data/Gemfile +4 -0
  5. data/Gemfile.lock +60 -0
  6. data/HISTORY.markdown +11 -0
  7. data/LICENSE +20 -0
  8. data/README.markdown +265 -0
  9. data/Rakefile +55 -0
  10. data/TODO.markdown +9 -0
  11. data/VERSION +1 -0
  12. data/config/cucumber.yml +7 -0
  13. data/examples/quicknote/.gitignore +8 -0
  14. data/examples/quicknote/FormAboutU.dfm +44 -0
  15. data/examples/quicknote/FormAboutU.pas +36 -0
  16. data/examples/quicknote/FormMainU.dfm +110 -0
  17. data/examples/quicknote/FormMainU.pas +268 -0
  18. data/examples/quicknote/FormSplashU.dfm +32 -0
  19. data/examples/quicknote/FormSplashU.pas +52 -0
  20. data/examples/quicknote/LICENSE +20 -0
  21. data/examples/quicknote/README.markdown +28 -0
  22. data/examples/quicknote/Rakefile +12 -0
  23. data/examples/quicknote/TODO.markdown +15 -0
  24. data/examples/quicknote/dcu/.gitignore +1 -0
  25. data/examples/quicknote/exe/.gitignore +0 -0
  26. data/examples/quicknote/exe/quicknote.exe +0 -0
  27. data/examples/quicknote/lib/quicknote.rb +140 -0
  28. data/examples/quicknote/quicknote.cfg +37 -0
  29. data/examples/quicknote/quicknote.dof +158 -0
  30. data/examples/quicknote/quicknote.dpr +16 -0
  31. data/examples/quicknote/quicknote.res +0 -0
  32. data/examples/quicknote/spec/quicknote/form_about_spec.rb +50 -0
  33. data/examples/quicknote/spec/quicknote/form_main_spec.rb +274 -0
  34. data/examples/quicknote/spec/quicknote/form_splash_spec.rb +44 -0
  35. data/examples/quicknote/spec/spec.opts +2 -0
  36. data/examples/quicknote/spec/spec_helper.rb +34 -0
  37. data/examples/quicknote/spec/watchr.rb +143 -0
  38. data/examples/skeleton/.gitignore +8 -0
  39. data/examples/skeleton/LICENSE +20 -0
  40. data/examples/skeleton/README.markdown +62 -0
  41. data/examples/skeleton/Rakefile +21 -0
  42. data/examples/skeleton/TODO.markdown +9 -0
  43. data/examples/skeleton/config/cucumber.yml +7 -0
  44. data/examples/skeleton/dcu/.gitignore +1 -0
  45. data/examples/skeleton/exe/.gitignore +1 -0
  46. data/examples/skeleton/features/basic.feature +6 -0
  47. data/examples/skeleton/features/step_definitions/.gitignore +0 -0
  48. data/examples/skeleton/features/step_definitions/application_steps.rb +43 -0
  49. data/examples/skeleton/features/support/env.rb +5 -0
  50. data/examples/skeleton/lib/myapp.rb +73 -0
  51. data/examples/skeleton/spec/myapp/form_about_spec.rb +50 -0
  52. data/examples/skeleton/spec/myapp/form_main_spec.rb +60 -0
  53. data/examples/skeleton/spec/spec.opts +2 -0
  54. data/examples/skeleton/spec/spec_helper.rb +29 -0
  55. data/examples/skeleton/spec/watchr.rb +143 -0
  56. data/features/automating_an_application.feature +11 -0
  57. data/features/step_definitions/.gitignore +0 -0
  58. data/features/step_definitions/calculator_steps.rb +37 -0
  59. data/features/support/env.rb +4 -0
  60. data/lib/win32/autogui.rb +27 -0
  61. data/lib/win32/autogui/application.rb +249 -0
  62. data/lib/win32/autogui/input.rb +238 -0
  63. data/lib/win32/autogui/window.rb +191 -0
  64. data/lib/win32/autogui/windows/window.rb +22 -0
  65. data/spec/applications/calculator.rb +34 -0
  66. data/spec/auto_gui/application_spec.rb +132 -0
  67. data/spec/basic_gem/basic_gem_spec.rb +13 -0
  68. data/spec/spec.opts +2 -0
  69. data/spec/spec_helper.rb +31 -0
  70. data/spec/watchr.rb +144 -0
  71. data/win32-autogui.gemspec +43 -0
  72. metadata +329 -0
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.0
@@ -0,0 +1,7 @@
1
+ <%
2
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
+ rerun_opts = rerun.to_s.strip.empty? ? "--format pretty features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
+ std_opts = "#{rerun_opts} --format rerun --out rerun.txt --strict --tags ~@wip"
5
+ %>
6
+ default: <%= std_opts %>
7
+ wip: --tags @wip:3 --wip features
@@ -0,0 +1,8 @@
1
+ *.ddp
2
+ *.dsk
3
+ *.log
4
+ *.cfIndex
5
+ *.cfProject
6
+ tmp/aruba
7
+ tags
8
+ rerun.txt
@@ -0,0 +1,44 @@
1
+ object FormAbout: TFormAbout
2
+ Left = 503
3
+ Top = 355
4
+ BorderStyle = bsDialog
5
+ Caption = 'About QuickNote'
6
+ ClientHeight = 197
7
+ ClientWidth = 319
8
+ Color = clBtnFace
9
+ Font.Charset = DEFAULT_CHARSET
10
+ Font.Color = clWindowText
11
+ Font.Height = -11
12
+ Font.Name = 'MS Shell Dlg 2'
13
+ Font.Style = []
14
+ OldCreateOrder = False
15
+ Position = poMainFormCenter
16
+ PixelsPerInch = 96
17
+ TextHeight = 13
18
+ object LabelAbout: TLabel
19
+ Left = 16
20
+ Top = 16
21
+ Width = 259
22
+ Height = 26
23
+ Caption =
24
+ 'QuickNote is an example application for the RubyGem win32-autogu' +
25
+ 'i.'
26
+ WordWrap = True
27
+ end
28
+ object LabelCopyright: TLabel
29
+ Left = 52
30
+ Top = 80
31
+ Width = 214
32
+ Height = 13
33
+ Caption = 'Copyright 2010, GearheadForHire.com, LLC.'
34
+ end
35
+ object ButtonOk: TButton
36
+ Left = 122
37
+ Top = 136
38
+ Width = 75
39
+ Height = 25
40
+ Caption = 'OK'
41
+ TabOrder = 0
42
+ OnClick = ButtonOkClick
43
+ end
44
+ end
@@ -0,0 +1,36 @@
1
+ unit FormAboutU;
2
+
3
+ interface
4
+
5
+ uses
6
+ Classes,
7
+ Controls,
8
+ Forms,
9
+ StdCtrls;
10
+
11
+ type
12
+ TFormAbout = class(TForm)
13
+ LabelAbout: TLabel;
14
+ ButtonOk: TButton;
15
+ LabelCopyright: TLabel;
16
+ procedure ButtonOkClick(Sender: TObject);
17
+
18
+ private
19
+
20
+ public
21
+
22
+ end;
23
+
24
+ var
25
+ FormAbout: TFormAbout;
26
+
27
+ implementation
28
+
29
+ {$R *.dfm}
30
+
31
+ procedure TFormAbout.ButtonOkClick(Sender: TObject);
32
+ begin
33
+ Close;
34
+ end;
35
+
36
+ end.
@@ -0,0 +1,110 @@
1
+ object FormMain: TFormMain
2
+ Left = 848
3
+ Top = 217
4
+ Width = 248
5
+ Height = 366
6
+ Caption = 'QuickNote'
7
+ Color = clBtnFace
8
+ Font.Charset = DEFAULT_CHARSET
9
+ Font.Color = clWindowText
10
+ Font.Height = -11
11
+ Font.Name = 'MS Shell Dlg 2'
12
+ Font.Style = []
13
+ Menu = MainMenu
14
+ OldCreateOrder = False
15
+ Position = poDefault
16
+ OnCloseQuery = FormCloseQuery
17
+ OnCreate = FormCreate
18
+ PixelsPerInch = 96
19
+ TextHeight = 13
20
+ object StatusBar: TStatusBar
21
+ Left = 0
22
+ Top = 293
23
+ Width = 240
24
+ Height = 19
25
+ Panels = <>
26
+ end
27
+ object Memo: TMemo
28
+ Left = 0
29
+ Top = 0
30
+ Width = 240
31
+ Height = 293
32
+ Align = alClient
33
+ ScrollBars = ssVertical
34
+ TabOrder = 1
35
+ OnChange = MemoChange
36
+ end
37
+ object ActionList: TActionList
38
+ Left = 194
39
+ Top = 244
40
+ object ActionFileExit: TAction
41
+ Caption = 'E&xit'
42
+ OnExecute = ActionFileExitExecute
43
+ end
44
+ object ActionHelpAbout: TAction
45
+ Caption = '&About'
46
+ OnExecute = ActionHelpAboutExecute
47
+ end
48
+ object ActionFileNew: TAction
49
+ Caption = '&New'
50
+ OnExecute = ActionFileNewExecute
51
+ end
52
+ object ActionFileSave: TAction
53
+ Caption = '&Save'
54
+ OnExecute = ActionFileSaveExecute
55
+ OnUpdate = ActionFileSaveUpdate
56
+ end
57
+ object ActionFileOpen: TAction
58
+ Caption = '&Open'
59
+ OnExecute = ActionFileOpenExecute
60
+ end
61
+ object ActionFileSaveAs: TAction
62
+ Caption = 'Save &As'
63
+ OnExecute = ActionFileSaveAsExecute
64
+ end
65
+ end
66
+ object MainMenu: TMainMenu
67
+ Left = 136
68
+ Top = 244
69
+ object MenuFile: TMenuItem
70
+ Caption = '&File'
71
+ object MenuFileNew: TMenuItem
72
+ Action = ActionFileNew
73
+ end
74
+ object MenuFileOpen: TMenuItem
75
+ Action = ActionFileOpen
76
+ end
77
+ object MenuFileSave: TMenuItem
78
+ Action = ActionFileSave
79
+ end
80
+ object MenuFileSaveAs: TMenuItem
81
+ Action = ActionFileSaveAs
82
+ end
83
+ object MenuFileDividerAfterSaveAs: TMenuItem
84
+ Caption = '-'
85
+ end
86
+ object MenuExit: TMenuItem
87
+ Action = ActionFileExit
88
+ end
89
+ end
90
+ object MenuHelp: TMenuItem
91
+ Caption = '&Help'
92
+ object MenuHelpAbout: TMenuItem
93
+ Action = ActionHelpAbout
94
+ end
95
+ end
96
+ end
97
+ object XPManifest: TXPManifest
98
+ Left = 79
99
+ Top = 245
100
+ end
101
+ object FileOpenDialog: TOpenDialog
102
+ Left = 168
103
+ Top = 192
104
+ end
105
+ object FileSaveDialog: TSaveDialog
106
+ Options = [ofOverwritePrompt, ofHideReadOnly, ofEnableSizing]
107
+ Left = 80
108
+ Top = 192
109
+ end
110
+ end
@@ -0,0 +1,268 @@
1
+ unit FormMainU;
2
+
3
+ interface
4
+
5
+ uses
6
+ Windows,
7
+ Classes,
8
+ Controls,
9
+ Forms,
10
+ Menus,
11
+ StdCtrls,
12
+ ActnList,
13
+ XPMan,
14
+ ComCtrls,
15
+ StrUtils,
16
+ Dialogs;
17
+
18
+ type
19
+ TFormMain = class(TForm)
20
+ XPManifest: TXPManifest;
21
+ StatusBar: TStatusBar;
22
+ Memo: TMemo;
23
+
24
+ FileOpenDialog: TOpenDialog;
25
+ FileSaveDialog: TSaveDialog;
26
+
27
+ ActionList: TActionList;
28
+ ActionFileExit: TAction;
29
+ ActionHelpAbout: TAction;
30
+ ActionFileNew: TAction;
31
+ ActionFileSave: TAction;
32
+ ActionFileOpen: TAction;
33
+ ActionFileSaveAs: TAction;
34
+
35
+ MainMenu: TMainMenu;
36
+ MenuFile: TMenuItem;
37
+ MenuFileSaveAs: TMenuItem;
38
+ MenuFileNew: TMenuItem;
39
+ MenuFileOpen: TMenuItem;
40
+ MenuFileSave: TMenuItem;
41
+ MenuHelp: TMenuItem;
42
+ MenuFileDividerAfterSaveAs: TMenuItem;
43
+ MenuExit: TMenuItem;
44
+ MenuHelpAbout: TMenuItem;
45
+
46
+ procedure ActionFileExitExecute(Sender: TObject);
47
+ procedure FormCreate(Sender: TObject);
48
+ procedure ActionHelpAboutExecute(Sender: TObject);
49
+ procedure MemoChange(Sender: TObject);
50
+ procedure ActionFileNewExecute(Sender: TObject);
51
+ procedure ActionFileOpenExecute(Sender: TObject);
52
+ procedure ActionFileSaveExecute(Sender: TObject);
53
+ procedure ActionFileSaveUpdate(Sender: TObject);
54
+ procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
55
+ procedure ActionFileSaveAsExecute(Sender: TObject);
56
+
57
+ private
58
+ FDirtyFlag: Boolean;
59
+ FFileName: String;
60
+
61
+ function PromptAndSave: Integer;
62
+
63
+ procedure SetDirty(Value: Boolean);
64
+ procedure LoadTextFile(AFileName: String);
65
+ procedure SaveTextFile(AFileName: String);
66
+ procedure UpdateTitleBar;
67
+ procedure Reset;
68
+
69
+ property Dirty: Boolean read FDirtyFlag write SetDirty;
70
+ property FileName: String read FFileName write FFilename;
71
+
72
+ public
73
+
74
+ end;
75
+
76
+ var
77
+ FormMain: TFormMain;
78
+
79
+ implementation
80
+
81
+ uses
82
+ FormAboutU,
83
+ FormSplashU;
84
+
85
+ {$R *.dfm}
86
+
87
+ procedure TFormMain.ActionFileExitExecute(Sender: TObject);
88
+ begin
89
+ Close;
90
+ end;
91
+
92
+ procedure TFormMain.FormCreate(Sender: TObject);
93
+ var
94
+ SplashForm: TFormSplash;
95
+ i: integer;
96
+ splash: Boolean;
97
+ begin
98
+ // defaults
99
+ splash := true;
100
+
101
+ // parse commandline
102
+ if ParamCount >= 1 then
103
+ begin
104
+ for i := 1 to ParamCount do
105
+ begin
106
+ if AnsiStartsText('--NOSPLASH', ParamStr(i)) then
107
+ begin
108
+ splash := false;
109
+ end;
110
+ end;
111
+ end;
112
+
113
+ if splash then
114
+ begin
115
+ SplashForm := TFormSplash.Create(Application);
116
+ try
117
+ SplashForm.Show;
118
+ // Simulate app creation work load
119
+ for i:= 1 to 200 do
120
+ begin
121
+ Application.ProcessMessages;
122
+ Sleep(10);
123
+ end;
124
+ finally
125
+ // Enable a timer that will shutdown and release Splash
126
+ // form after a short wait
127
+ SplashForm.Timer.Enabled := True;
128
+ end;
129
+ end;
130
+
131
+ Reset;
132
+ end;
133
+
134
+ procedure TFormMain.SetDirty(Value: Boolean);
135
+ begin
136
+ if Value <> FDirtyFlag then
137
+ begin
138
+ FdirtyFlag := Value;
139
+ UpdateTitleBar;
140
+ end;
141
+ end;
142
+
143
+ procedure TFormMain.UpdateTitleBar;
144
+ var
145
+ fileFlags: String;
146
+ begin
147
+ if Dirty then
148
+ fileFlags := '+'
149
+ else
150
+ fileFlags := '';
151
+
152
+ FormMain.Caption := 'QuickNote' + ' - ' + fileFlags + FileName;
153
+ end;
154
+
155
+ procedure TFormMain.ActionHelpAboutExecute(Sender: TObject);
156
+ var
157
+ FormAbout: TFormAbout;
158
+ begin
159
+ FormAbout := TFormAbout.Create(Application);
160
+ try
161
+ FormAbout.ShowModal
162
+ finally
163
+ FormAbout.Release;
164
+ end;
165
+ end;
166
+
167
+ procedure TFormMain.MemoChange(Sender: TObject);
168
+ begin
169
+ Dirty := True;
170
+ end;
171
+
172
+ procedure TFormMain.Reset;
173
+ begin
174
+ Memo.Clear;
175
+ FileName := 'untitled.txt';
176
+ Dirty := False;
177
+ UpdateTitleBar;
178
+ end;
179
+
180
+ procedure TFormMain.ActionFileNewExecute(Sender: TObject);
181
+ begin
182
+ if PromptAndSave <> mrCancel then
183
+ begin
184
+ Reset;
185
+ end;
186
+ end;
187
+
188
+ procedure TFormMain.ActionFileSaveAsExecute(Sender: TObject);
189
+ begin
190
+ FileSaveDialog.Title := 'Text File Save';
191
+ FileSaveDialog.Filter := 'Text Files (*.txt)|*.txt|All files (*.*)|*.*';
192
+
193
+ if FileSaveDialog.Execute then
194
+ begin
195
+ SaveTextFile(FileSaveDialog.FileName);
196
+ end;
197
+ end;
198
+
199
+ procedure TFormMain.ActionFileOpenExecute(Sender: TObject);
200
+ begin
201
+ FileOpenDialog.Title := 'Text File Open';
202
+ FileOpenDialog.Filter := 'Text Files (*.txt)|*.txt|All files (*.*)|*.*';
203
+ FileOpenDialog.DefaultExt := '';
204
+ FileOpenDialog.FileName := '';
205
+ FileOpenDialog.Files.Clear;
206
+
207
+ if PromptAndSave = mrCancel then exit;
208
+
209
+ if FileOpenDialog.Execute then
210
+ begin
211
+ LoadTextFile(FileOpenDialog.FileName);
212
+ end;
213
+ end;
214
+
215
+ procedure TFormMain.ActionFileSaveExecute(Sender: TObject);
216
+ begin
217
+ SaveTextFile(FileName);
218
+ end;
219
+
220
+ procedure TFormMain.LoadTextFile(AFileName: String);
221
+ begin
222
+ FileName := AFileName;
223
+ Memo.Lines.LoadFromFile(FileName);
224
+ Dirty := False;
225
+ UpdateTitleBar;
226
+ end;
227
+
228
+ procedure TFormMain.SaveTextFile(AFileName: String);
229
+ begin
230
+ FileName := AFileName;
231
+ Memo.Lines.SaveToFile(FileName);
232
+ Dirty := False;
233
+ UpdateTitleBar;
234
+ end;
235
+
236
+ function TFormMain.PromptAndSave: Integer;
237
+ var
238
+ Msg: String;
239
+ begin
240
+ // Default
241
+ Result := mrYes;
242
+
243
+ if Dirty then
244
+ begin
245
+ Msg := 'Text has changed. Save changes to ' + FileName +'?';
246
+ Result := MessageDlg(msg, mtConfirmation, mbYesNoCancel, 0);
247
+ if Result = mrYes then
248
+ begin
249
+ ActionFileSaveExecute(self);
250
+ end;
251
+ end;
252
+ end;
253
+
254
+ procedure TFormMain.ActionFileSaveUpdate(Sender: TObject);
255
+ begin
256
+ TAction(Sender).Enabled := Dirty;
257
+ end;
258
+
259
+ procedure TFormMain.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
260
+ begin
261
+ // Prompt user to save changes
262
+ if PromptAndSave = mrCancel then
263
+ begin
264
+ CanClose := False;
265
+ end;
266
+ end;
267
+
268
+ end.