Skip to content

Commit f25e404

Browse files
committed
SplitSideBySide, AccessibilityInspector, BrowserAutomation & index generator
1 parent db44b94 commit f25e404

23 files changed

+228
-7
lines changed

.gen/index.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const { readdirSync, readFileSync, writeFileSync } = require("fs");
2+
let paths = readdirSync("../examples").map(e => `../examples/${e}/README.md`);
3+
let regex = /<!--\s*({(?:\s|(?!-->).)*})\s*-->/;
4+
let metas = paths.map(e => ({ path: e, text: readFileSync(e).toString() }))
5+
.filter(e => regex.test(e.text))
6+
.map(e => ({ path: e.path, data: JSON.parse(regex.exec(e.text)[1]) }))
7+
console.log(metas)
8+
9+
let md = `
10+
# \`stdVBA\` Examples
11+
12+
This repository holds examples of using \`stdVBA\`. This should give people a better idea of how to use \`stdVBA\` and libraries.
13+
14+
## Contents
15+
16+
| Title | Tags | Dependencies |
17+
|-------|------|--------------|
18+
${metas.map(function (meta) {
19+
return "|" + [
20+
"[" + meta.data.description + "](" + encodeURI(meta.path.substring(3, meta.path.length - "/README.md".length)) + ")",
21+
meta.data.tags.join(", "),
22+
meta.data.deps.join(", ")
23+
].join("|") + "|"
24+
}).join("\r\n")}
25+
`
26+
writeFileSync("../README.md", md)
27+

.gen/readme.build.bat

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node .
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<!--
2+
{
3+
"description": "Accessibility Inspector",
4+
"tags":["ui", "window", "automation", "embedding"],
5+
"deps":["stdAcc", "stdProcess", "stdWindow", "stdICallable"]
6+
}
7+
-->
8+
9+
# Accessibility Inspector
10+
11+
While using `stdAcc` it is often useful to be able to obtain the accessibility information at the cursor. This can help you find elements to further investigate the accessibility tree. This example provides a utility application which can be used to:
12+
13+
* Pinpoint element attributes to assist during automation.
14+
* Allows setting of `accValue`, typically useful to test setting fields with information.
15+
* Allows execution of `DoDefaultAction`.
16+
17+
18+
![inspector](./docs/inspector.png)
19+
20+
## Requirements
21+
22+
* [stdVBA](http://github.com/sancarn/stdVBA)
23+
* stdAcc
24+
* stdWindow
25+
* stdICallable
26+
* Currently only works on Windows OS
27+
28+
## Usage
29+
30+
Open xlsm and click launch!
31+
32+
Move your mouse around to extract accessibility information
33+
34+
## Roadmap
35+
36+
* [X] Extract basic accessibility information
37+
* [X] Provide a button to freeze time, allowing the copy and paste of data out of the form.
38+
* [X] Make form topmost
39+
* [ ] FIXME: Slow path creation over Excel.
40+
* [ ] Option to highlighting the hovered accessibility element with a yellow rect created with GDI+ to help indicate which window is being inspected.
41+
* [ ] Display the accessibility tree in a treeview control. Navigating the tree should navigate the inspected element and navigate "hover rectangle" above - this will likely be a different project.
42+
43+
## Known issues
44+
45+
* Path field has currently been disabled. See roadmap.
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
VERSION 5.00
2+
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} AccHelper
3+
Caption = "Accessibility Helper"
4+
ClientHeight = 4800
5+
ClientLeft = 45
6+
ClientTop = 390
7+
ClientWidth = 4755
8+
OleObjectBlob = "AccHelper.frx":0000
9+
ShowModal = 0 'False
10+
StartUpPosition = 1 'CenterOwner
11+
End
12+
Attribute VB_Name = "AccHelper"
13+
Attribute VB_GlobalNameSpace = False
14+
Attribute VB_Creatable = False
15+
Attribute VB_PredeclaredId = True
16+
Attribute VB_Exposed = False
17+
'in a module
18+
Option Explicit
19+
20+
Public Shown As Boolean
21+
22+
Public Enum EInspectState
23+
Permanent
24+
Temporary
25+
End Enum
26+
27+
Private pInspectorState As EInspectState
28+
Private pDisabledTime As Date
29+
Private oInspected As stdAcc
30+
31+
32+
33+
Private Sub DoDefaultAction_Click()
34+
stdWindow.CreateFromHwnd(oInspected.hwnd).Activate
35+
oInspected.DoDefaultAction
36+
End Sub
37+
38+
Private Sub SetValue_Click()
39+
stdWindow.CreateFromHwnd(oInspected.hwnd).Activate
40+
oInspected.value = InputBox("What value due you want to set it to?")
41+
Call UpdateFromInspected
42+
End Sub
43+
44+
Private Sub UserForm_Initialize()
45+
Me.Show
46+
Shown = True
47+
End Sub
48+
49+
Public Sub Watch()
50+
stdWindow.CreateFromIUnknown(Me).isTopmost = True
51+
While Shown
52+
If Inspecting.value Then
53+
Set oInspected = stdAcc.CreateFromMouse()
54+
Call UpdateFromInspected
55+
End If
56+
57+
'Handle temporary inspector
58+
If pInspectorState = Temporary Then
59+
Dim c: c = Now()
60+
Dim timeLeft As Double: timeLeft = Round(Second(Application.Max(pDisabledTime - Now(), 0)), 1)
61+
If timeLeft = 0 Then
62+
Inspecting.value = False
63+
pInspectorState = Permanent
64+
End If
65+
SecondsLeft.Caption = timeLeft
66+
End If
67+
68+
DoEvents
69+
Wend
70+
End Sub
71+
72+
Public Sub UpdateFromInspected()
73+
On Error Resume Next
74+
With oInspected
75+
Me.crName.value = .name & "[P:" & .parent.name & "]"
76+
Me.crDefaultAction.value = .DefaultAction
77+
Me.crDescription.value = .Description
78+
Me.crRole.value = .Role
79+
Me.crStates.value = .States
80+
Me.crValue.value = .value
81+
Me.crLocation.value = "X: " & .Location!left & " Y: " & .Location!top & " W: " & .Location!width & " H: " & .Location!height
82+
Me.crHWND.value = .hwnd
83+
With stdWindow.CreateFromHwnd(.hwnd)
84+
If .Exists Then
85+
Me.crAppName.value = .ProcessName
86+
Me.crWindowClass.value = .Class
87+
End If
88+
End With
89+
On Error Resume Next
90+
'Me.crPath.value = ""
91+
'Me.crPath.value = .getPath()
92+
On Error GoTo 0
93+
End With
94+
End Sub
95+
96+
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
97+
Shown = False
98+
Unload Me
99+
End Sub
100+
101+
Private Sub Enable5_Click()
102+
pInspectorState = Temporary
103+
pDisabledTime = Now() + TimeSerial(0, 0, 5)
104+
Inspecting.value = True
105+
End Sub
106+
Private Sub Inspecting_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
107+
pInspectorState = Permanent
108+
End Sub
109+
110+
Private Sub UserForm_Terminate()
111+
Unload Me
112+
End Sub
113+
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Attribute VB_Name = "LaunchInspect"
2+
Sub Launch()
3+
Call AccHelper.Show
4+
Call AccHelper.Watch
5+
End Sub

Examples/Various/BrowserAutomation/README.md renamed to Examples/BrowserAutomation/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
<!--
2+
{
3+
"description": "Automate the web with Chrome",
4+
"tags":["web", "automation", "accessibility"],
5+
"deps":["stdAcc", "stdEnumerator", "stdLambda", "stdProcess", "stdWindow", "stdICallable"]
6+
}
7+
-->
18
# Browser Automation with stdVBA
29

310
On 15th June 2022, Internet explorer officially retires as an application. It is uncertain what will happen when this occurs, however many users of VBA rely heavily on Internet Explorer to automate web reports etc.
406 KB
Binary file not shown.

Examples/stdWindow/SplitSideBySide/README.md renamed to Examples/SplitSideBySide/README.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
# TextBoxEx for VBA UserForms
2-
3-
Split the screen into 2 halves. The left half should contain the excel window. The right half should contain a browser window of your choosing
4-
5-
1+
<!--
2+
{
3+
"description": "Split windows side by side",
4+
"tags":["window", "automation"],
5+
"deps":["stdLambda", "stdWindow", "stdICallable"]
6+
}
7+
-->
68

9+
# Excel and Browser side-by-side
710

11+
Split the screen into 2 halves. The left half should contain the excel window. The right half should contain a browser window of your choosing
812

913
## Requirements
1014

@@ -29,5 +33,3 @@ End Sub
2933
With `stdVBA` we've trimmed our solution down to 162 lines to about 62. `stdVBA` helps you cut down on boiler plate and helps you focus on the important questions like "How do I move my window" rather than "How do I get the caption text of a window?".
3034

3135
![comparison](docs/comparison.png)
32-
33-

Examples/stdWindow/uiTextBoxEx-WordControl/README.md renamed to Examples/uiTextBoxEx-WordControl/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
<!--
2+
{
3+
"description": "Embed Microsoft Word into a userform",
4+
"tags":["ui", "window", "automation", "embedding"],
5+
"deps":["stdLambda", "stdWindow", "stdICallable", "stdProcess"]
6+
}
7+
-->
8+
19
# TextBoxEx for VBA UserForms
210

311
This is a text box control which uses a Microsoft Word instance as a userform control. This control offers all the features you get in word, critically **spell checking**.

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
# `stdVBA` Examples
3+
4+
This repository holds examples of using `stdVBA`. This should give people a better idea of how to use `stdVBA` and libraries.
5+
6+
## Contents
7+
8+
| Title | Tags | Dependencies |
9+
|-------|------|--------------|
10+
|[Accessibility Inspector](examples/Accessibility%20Inspector)|ui, window, automation, embedding|stdAcc, stdProcess, stdWindow, stdICallable|
11+
|[Automate the web with Chrome](examples/BrowserAutomation)|web, automation, accessibility|stdAcc, stdEnumerator, stdLambda, stdProcess, stdWindow, stdICallable|
12+
|[Split windows side by side](examples/SplitSideBySide)|window, automation|stdLambda, stdWindow, stdICallable|
13+
|[Embed Microsoft Word into a userform](examples/uiTextBoxEx-WordControl)|ui, window, automation, embedding|stdLambda, stdWindow, stdICallable, stdProcess|

0 commit comments

Comments
 (0)