win32-autogui 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,32 @@
1
+ object FormSplash: TFormSplash
2
+ Left = 584
3
+ Top = 496
4
+ Width = 261
5
+ Height = 181
6
+ Caption = 'FormSplash'
7
+ Color = clGrayText
8
+ Font.Charset = DEFAULT_CHARSET
9
+ Font.Color = clWindowText
10
+ Font.Height = -11
11
+ Font.Name = 'MS Shell Dlg 2'
12
+ Font.Style = []
13
+ OldCreateOrder = False
14
+ Position = poOwnerFormCenter
15
+ OnCreate = FormCreate
16
+ PixelsPerInch = 96
17
+ TextHeight = 13
18
+ object LabelLoading: TLabel
19
+ Left = 102
20
+ Top = 67
21
+ Width = 49
22
+ Height = 13
23
+ Caption = 'Loading...'
24
+ end
25
+ object Timer: TTimer
26
+ Enabled = False
27
+ Interval = 750
28
+ OnTimer = TimerTimer
29
+ Left = 184
30
+ Top = 32
31
+ end
32
+ end
@@ -0,0 +1,52 @@
1
+ unit FormSplashU;
2
+
3
+ interface
4
+
5
+ uses
6
+ Classes,
7
+ Controls,
8
+ Forms,
9
+ StdCtrls,
10
+ ExtCtrls;
11
+
12
+ type
13
+ TFormSplash = class(TForm)
14
+ Timer: TTimer;
15
+ LabelLoading: TLabel;
16
+
17
+ procedure FormCreate(Sender: TObject);
18
+ procedure TimerTimer(Sender: TObject);
19
+
20
+ private
21
+
22
+ public
23
+
24
+ end;
25
+
26
+ var
27
+ FormSplash: TFormSplash;
28
+
29
+ implementation
30
+
31
+ {$R *.dfm}
32
+
33
+ procedure TFormSplash.FormCreate(Sender: TObject);
34
+ begin
35
+ BorderIcons := [];
36
+ BorderStyle := bsNone;
37
+ BorderWidth := 1;
38
+ FormStyle := fsStayOnTop;
39
+
40
+ Position := poOwnerFormCenter;
41
+
42
+ Timer.Enabled := False;
43
+ Timer.Interval := 750;
44
+ end;
45
+
46
+ procedure TFormSplash.TimerTimer(Sender: TObject);
47
+ begin
48
+ Close;
49
+ Release;
50
+ end;
51
+
52
+ end.
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 GearheadForHire, LLC
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,28 @@
1
+ QuickNote README
2
+ ================
3
+
4
+ QuickNote is a stripped down Notepad clone written in Delphi. It is an example GUI executable with
5
+ source code for the Win32-autogui gem. It is not fit for any other purpose.
6
+
7
+
8
+ Modifications to the load paths for use in a real world project
9
+ ----------------------------------------------------------------
10
+
11
+ spec/spec_helper.rb
12
+
13
+ # use development version of win32/autogui
14
+ # remove these lines in production code
15
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__) unless
16
+ $LOAD_PATH.include? File.expand_path('../../../../lib', __FILE__)
17
+
18
+ lib/quicknote.rb
19
+
20
+ # use the development version of win32-autogui
21
+ # Production code should simply require 'win32/autogui'
22
+ require File.expand_path(File.dirname(__FILE__) + '/../../../lib/win32/autogui')
23
+
24
+
25
+ Copyright
26
+ ---------
27
+
28
+ Copyright (c) 2010 GearheadForHire, LLC. See [LICENSE](LICENSE) for details.
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+
5
+ require 'spec'
6
+ require 'spec/rake/spectask'
7
+ Spec::Rake::SpecTask.new(:spec) do |spec|
8
+ spec.libs << 'lib' << 'spec'
9
+ spec.spec_files = FileList['spec/**/*_spec.rb']
10
+ end
11
+
12
+ task :default => :spec
@@ -0,0 +1,15 @@
1
+ QuickNote TODO
2
+ ==============
3
+
4
+ general
5
+ -------
6
+
7
+ * (1.1) get rid off all dfm's by using dynamic component creation
8
+ * (1.1) make sure app compiles with FPC
9
+ * (1.1) add makefile
10
+
11
+
12
+ testing
13
+ -------
14
+
15
+ * (1.1) investigate TSynTest for unit testing
@@ -0,0 +1 @@
1
+ *.dcu
File without changes
@@ -0,0 +1,140 @@
1
+ # use the development version of win32-autogui
2
+ # Production code should simply require 'win32/autogui'
3
+ require File.expand_path(File.dirname(__FILE__) + '/../../../lib/win32/autogui')
4
+
5
+
6
+ class Quicknote < Autogui::Application
7
+
8
+ def initialize(options = {})
9
+ # relative path to app using Windows style path
10
+ @name ="exe\\quicknote.exe"
11
+ defaults = {
12
+ :title=> "QuickNote -",
13
+ :parameters => '--nosplash',
14
+ :main_window_timeout => 20
15
+ }
16
+ super defaults.merge(options)
17
+ end
18
+
19
+ def edit_window
20
+ main_window.children.find {|w| w.window_class == 'TMemo'}
21
+ end
22
+
23
+ def status_bar
24
+ main_window.children.find {|w| w.window_class == 'TStatusBar'}
25
+ end
26
+
27
+ def dialog_about
28
+ Autogui::EnumerateDesktopWindows.new.find do |w|
29
+ w.title.match(/About QuickNote/) && (w.pid == pid)
30
+ end
31
+ end
32
+
33
+ def splash
34
+ Autogui::EnumerateDesktopWindows.new.find do |w|
35
+ w.title.match(/FormSplash/) && (w.pid == pid)
36
+ end
37
+ end
38
+
39
+ def message_dialog_confirm
40
+ Autogui::EnumerateDesktopWindows.new.find do |w|
41
+ w.title.match(/Confirm/) && (w.pid == pid)
42
+ end
43
+ end
44
+
45
+ # Title and class are the same as dialog_overwrite_confirm
46
+ # Use child windows to differentiate
47
+ def dialog_overwrite_confirm
48
+ Autogui::EnumerateDesktopWindows.new.find do |w|
49
+ w.title.match(/^Text File Save$/) &&
50
+ (w.pid == pid) &&
51
+ (w.window_class == "#32770") &&
52
+ (w.combined_text.match(/already exists/))
53
+ end
54
+ end
55
+
56
+ # Title and class are the same as dialog_overwrite_confirm
57
+ def file_save_as_dialog
58
+ Autogui::EnumerateDesktopWindows.new.find do |w|
59
+ w.title.match(/Text File Save/) &&
60
+ (w.pid == pid) &&
61
+ (w.window_class == "#32770") &&
62
+ (w.combined_text.match(/Save \&in:/))
63
+ end
64
+ end
65
+
66
+ def file_open_dialog
67
+ Autogui::EnumerateDesktopWindows.new.find do |w|
68
+ w.title.match(/Text File Open/) && (w.pid == pid)
69
+ end
70
+ end
71
+
72
+ def error_dialog
73
+ Autogui::EnumerateDesktopWindows.new.find do |w|
74
+ w.title.match(/^QuickNote$/) && (w.pid == pid) && (w.window_class == "#32770")
75
+ end
76
+ end
77
+
78
+ # menu action File, New
79
+ def file_new(options={})
80
+ set_focus
81
+ keystroke(VK_MENU, VK_F, VK_N)
82
+ if message_dialog_confirm
83
+ options[:save] == true ? keystroke(VK_Y) : keystroke(VK_N)
84
+ end
85
+ # sanity check
86
+ raise "confirm dialog is still here" if message_dialog_confirm
87
+ end
88
+
89
+ # menu action File, New
90
+ def file_open(filename, options={})
91
+ set_focus
92
+ keystroke(VK_MENU, VK_F, VK_O)
93
+ if message_dialog_confirm
94
+ options[:save] == true ? keystroke(VK_Y) : keystroke(VK_N)
95
+ end
96
+
97
+ raise "sanity check, confirm dialog is still here" if message_dialog_confirm
98
+ raise "sanity check, file_open_dialog not found" unless file_open_dialog
99
+
100
+ # Paste in filename for speed, much faster than 'type_in(filename)'
101
+ clipboard.text = filename
102
+ keystroke(VK_CONTROL, VK_V)
103
+
104
+ keystroke(VK_RETURN)
105
+ end
106
+
107
+ # menu action File, Exit
108
+ def file_exit
109
+ set_focus
110
+ keystroke(VK_N) if message_dialog_confirm
111
+ keystroke(VK_ESCAPE) if file_open_dialog
112
+ keystroke(VK_MENU, VK_F, VK_X)
113
+ keystroke(VK_N) if message_dialog_confirm
114
+ end
115
+
116
+ # menu action File, Save
117
+ def file_save
118
+ set_focus
119
+ keystroke(VK_MENU, VK_F, VK_S)
120
+ end
121
+
122
+ # menu action File, Save As
123
+ def file_save_as(filename, options={})
124
+ set_focus
125
+ keystroke(VK_MENU, VK_F, VK_A)
126
+ raise "sanity check, file_save_as_dialog not found" unless file_save_as_dialog
127
+
128
+ # Paste in filename for speed, much faster than 'type_in(filename)'
129
+ clipboard.text = filename
130
+ keystroke(VK_CONTROL, VK_V)
131
+ keystroke(VK_RETURN)
132
+
133
+ if dialog_overwrite_confirm
134
+ options[:overwrite] == true ? keystroke(VK_Y) : keystroke(VK_N)
135
+ end
136
+ raise "sanity check, overwrite confirm dialog is still here" if dialog_overwrite_confirm
137
+
138
+ end
139
+
140
+ end
@@ -0,0 +1,37 @@
1
+ -$A8
2
+ -$B-
3
+ -$C-
4
+ -$D-
5
+ -$E-
6
+ -$F-
7
+ -$G+
8
+ -$H+
9
+ -$I+
10
+ -$J-
11
+ -$K-
12
+ -$L-
13
+ -$M-
14
+ -$N+
15
+ -$O+
16
+ -$P+
17
+ -$Q-
18
+ -$R-
19
+ -$S-
20
+ -$T-
21
+ -$U-
22
+ -$V+
23
+ -$W-
24
+ -$X+
25
+ -$Y-
26
+ -$Z1
27
+ -cg
28
+ -AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
29
+ -H+
30
+ -W+
31
+ -M
32
+ -$M16384,1048576
33
+ -K$00400000
34
+ -E"exe"
35
+ -N"dcu"
36
+ -LE"c:\program files\borland\delphi7\Projects\Bpl"
37
+ -LN"c:\program files\borland\delphi7\Projects\Bpl"
@@ -0,0 +1,158 @@
1
+ [FileVersion]
2
+ Version=7.0
3
+ [Compiler]
4
+ A=8
5
+ B=0
6
+ C=0
7
+ D=0
8
+ E=0
9
+ F=0
10
+ G=1
11
+ H=1
12
+ I=1
13
+ J=0
14
+ K=0
15
+ L=0
16
+ M=0
17
+ N=1
18
+ O=1
19
+ P=1
20
+ Q=0
21
+ R=0
22
+ S=0
23
+ T=0
24
+ U=0
25
+ V=1
26
+ W=0
27
+ X=1
28
+ Y=0
29
+ Z=1
30
+ ShowHints=1
31
+ ShowWarnings=1
32
+ UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
33
+ NamespacePrefix=
34
+ SymbolDeprecated=1
35
+ SymbolLibrary=1
36
+ SymbolPlatform=1
37
+ UnitLibrary=1
38
+ UnitPlatform=1
39
+ UnitDeprecated=1
40
+ HResultCompat=1
41
+ HidingMember=1
42
+ HiddenVirtual=1
43
+ Garbage=1
44
+ BoundsError=1
45
+ ZeroNilCompat=1
46
+ StringConstTruncated=1
47
+ ForLoopVarVarPar=1
48
+ TypedConstVarPar=1
49
+ AsgToTypedConst=1
50
+ CaseLabelRange=1
51
+ ForVariable=1
52
+ ConstructingAbstract=1
53
+ ComparisonFalse=1
54
+ ComparisonTrue=1
55
+ ComparingSignedUnsigned=1
56
+ CombiningSignedUnsigned=1
57
+ UnsupportedConstruct=1
58
+ FileOpen=1
59
+ FileOpenUnitSrc=1
60
+ BadGlobalSymbol=1
61
+ DuplicateConstructorDestructor=1
62
+ InvalidDirective=1
63
+ PackageNoLink=1
64
+ PackageThreadVar=1
65
+ ImplicitImport=1
66
+ HPPEMITIgnored=1
67
+ NoRetVal=1
68
+ UseBeforeDef=1
69
+ ForLoopVarUndef=1
70
+ UnitNameMismatch=1
71
+ NoCFGFileFound=1
72
+ MessageDirective=1
73
+ ImplicitVariants=1
74
+ UnicodeToLocale=1
75
+ LocaleToUnicode=1
76
+ ImagebaseMultiple=1
77
+ SuspiciousTypecast=1
78
+ PrivatePropAccessor=1
79
+ UnsafeType=1
80
+ UnsafeCode=1
81
+ UnsafeCast=1
82
+ [Linker]
83
+ MapFile=0
84
+ OutputObjs=0
85
+ ConsoleApp=1
86
+ DebugInfo=0
87
+ RemoteSymbols=0
88
+ MinStackSize=16384
89
+ MaxStackSize=1048576
90
+ ImageBase=4194304
91
+ ExeDescription=
92
+ [Directories]
93
+ OutputDir=exe
94
+ UnitOutputDir=dcu
95
+ PackageDLLOutputDir=
96
+ PackageDCPOutputDir=
97
+ SearchPath=
98
+ Packages=vcl;rtl;vclx;indy;vclie;xmlrtl;inetdbbde;inet;inetdbxpress;dbrtl;soaprtl;dsnap;VclSmp;dbexpress;vcldb;dbxcds;inetdb;bdertl;vcldbx;adortl;ibxpress;visualclx;visualdbclx;vclactnband;vclshlctrls;IntrawebDB_50_70;Intraweb_50_70;Rave50CLX;Rave50VCL;dclOfficeXP;VirtualTreesD7;VirtualShellToolsD7;tb2k_d7;Tee77;TeeUI77;TeeDB77;TeePro77;TeeGL77;TeeImage77;TeeLanguage77;Rz30Ctls70;Rz30DBCtls70;cxLibraryVCLD7;dxThemeD7;cxEditorsVCLD7;cxDataD7;cxExtEditorsVCLD7;cxPageControlVCLD7;cxGridVCLD7;rbRCL97;rbDAD97;rbDB97;cxExportVCLD7;GroupMaint;ConadExtraControls;caGrid
99
+ Conditionals=
100
+ DebugSourceDirs=
101
+ UsePackages=0
102
+ [Parameters]
103
+ RunParams=--nosplash
104
+ HostApplication=
105
+ Launcher=
106
+ UseLauncher=0
107
+ DebugCWD=
108
+ [Language]
109
+ ActiveLang=
110
+ ProjectLang=
111
+ RootDir=
112
+ [Version Info]
113
+ IncludeVerInfo=1
114
+ AutoIncBuild=0
115
+ MajorVer=1
116
+ MinorVer=0
117
+ Release=0
118
+ Build=1
119
+ Debug=0
120
+ PreRelease=0
121
+ Special=0
122
+ Private=0
123
+ DLL=0
124
+ Locale=1033
125
+ CodePage=1252
126
+ [Version Info Keys]
127
+ CompanyName=
128
+ FileDescription=
129
+ FileVersion=1.0.0.1
130
+ InternalName=
131
+ LegalCopyright=
132
+ LegalTrademarks=
133
+ OriginalFilename=
134
+ ProductName=
135
+ ProductVersion=1.0.0.0
136
+ Comments=
137
+ [Excluded Packages]
138
+ C:\Dat\CAI\ConAd\Source\exe\ChartRoutines.bpl=TeeChart Pro 5 Components
139
+ c:\program files\borland\delphi7\Projects\Bpl\hookkeyD6.bpl=(untitled)
140
+ C:\Program Files\Borland\Delphi7\Projects\Bpl\FR7.bpl=FastReport 2.52 Components
141
+ C:\Dat\Delphi\DevExpress\ExpressQuantumGrid 4\Lib\Delphi7\dclcxGridUtilsVCLD7.bpl=ExpressQuantumGrid 4 Utils (VCL Edition) by Developer Express Inc.
142
+ c:\dat\delphi\RBuilder\Lib\dclRBC97.bpl=ReportBuilder TeeChart 7.0 Components
143
+ c:\program files\borland\delphi7\Projects\Bpl\rbIBE97.bpl=ReportBuilder Data Access for Interbase Express
144
+ [HistoryLists\hlConditionals]
145
+ Count=1
146
+ Item0=d
147
+ [HistoryLists\hlUnitAliases]
148
+ Count=1
149
+ Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
150
+ [HistoryLists\hlSearchPath]
151
+ Count=1
152
+ Item0=;C:\Dat\delphi\TeeChartPro.D7\Sources\Compiled\Delphi7\Lib
153
+ [HistoryLists\hlUnitOutputDirectory]
154
+ Count=1
155
+ Item0=dcu
156
+ [HistoryLists\hlOutputDirectorry]
157
+ Count=1
158
+ Item0=exe