Skip to content

Commit 558bfe7

Browse files
committed
Merge branch 'develop'
2 parents 0ad10a9 + 93794a5 commit 558bfe7

File tree

12 files changed

+5506
-5050
lines changed

12 files changed

+5506
-5050
lines changed

3hta/excel/excel.f

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
\ "Application Object (Excel)" http://msdn.microsoft.com/en-us/library/office/ff194565(v=office.15).aspx
66
\ VBA Language Reference http://msdn.microsoft.com/en-us/library/bb190882(v=office.11).aspx
77
\ Microsoft Excel Visual Basic Reference http://msdn.microsoft.com/en-us/library/aa272254(v=office.11).aspx
8+
\ Cell (Range) properties VBA Reference http://msdn.microsoft.com/en-us/library/office/aa174290(v=office.11).aspx
89
\ Excel constants, e.g. xlUp = -4162, can be found in AutoIt UDF source code excel.au3.
910

1011
include wsh.f
@@ -31,14 +32,15 @@
3132

3233
null value excel.app // ( -- obj ) The Excel.Application object or undefined if no excel exists.
3334
/// "Application Object (Excel)" http://msdn.microsoft.com/en-us/library/office/ff194565(v=office.15).aspx
34-
s" where name = 'ExCeL.ExE'" count-process ( count )
35+
3536
excel.app.count 1 > [if]
3637
cr cr ." W A R N I N G ! (from excel.f)" cr cr
3738
." Multiple Excel.Application are running, I can only handle one of them." cr
3839
." The excel I've got the handle should be high-lighted, you see that? Please use" cr
3940
." that one or you'll have to use the 'kill-excel' command to close all of them and" cr
4041
." then '--excel.f-- include excel.f' to restart me, the excel.f module, again." cr cr
4142
[then]
43+
4244
excel.app.count [if]
4345
\ 用這行就錯了! <vb> On Error Resume Next:Set xl=GetObject("","excel.application"):vm.push(xl)</vb> 會開出新 Excel.Application。
4446
<vb> On Error Resume Next:Set xl=GetObject(,"excel.application"):vm.push(xl)</vb> \ 這行才是沿用既有的 Excel.Application。
@@ -49,11 +51,22 @@
4951
excel.app [if] \ excel.app exists
5052

5153
: activeCell excel.app :> ActiveCell ; // ( -- obj ) Get the ActiveCell object
54+
/// The 3 active things: cell, sheet, and workbook
5255
/// activeCell :> offset(0,1).formula tib.
56+
/// activeCell :: Interior.Color=0xbbggrr
57+
/// activeCell :> worksheet.name tib.
58+
/// activeCell :> application \ ==> Microsoft Excel (object)
59+
/// activeWorkbook :> worksheets(1).name tib. --> sheet name
60+
/// activeWorkbook :> worksheets('NaMe').name tib. --> case insensitive
61+
/// activeWorkbook :> worksheets('匯總').name \ ==> 匯總 (string)
62+
/// activeWorkbook :> name tib. \ ==> filename
63+
5364
: activeSheet excel.app :> ActiveSheet ; // ( -- obj ) Get the ActiveSheet object
54-
/// activeSheet :> name tib.
65+
' activeCell :> comment last :: comment=pop()
66+
5567
: activeWorkbook excel.app :> ActiveWorkbook ; // ( -- obj ) Get the ActiveWorkbook object
56-
/// activeWorkbook :> name tib.
68+
' activeCell :> comment last :: comment=pop()
69+
5770
: selection excel.app :> selection ; // ( -- obj ) Get the selected object ( a range object )
5871
/// selection :> count tib.
5972
/// selection :: item(123).value="hello"
@@ -225,12 +238,20 @@
225238
else selection :: item(tos()).activate() then ;
226239
/// 這組工具:上,下,左,右,當格,的【判斷】都依賴這些 cell
227240
/// 值,若不然時就要用本命令 i?stop 透過 selection 來完成。
228-
/// \ Example, 選中的格子都去掉頭尾空白
241+
/// \ Example-1, 選中的格子都去掉頭尾空白,做完 i 自動消失
229242
/// manual 0 cut ( 前置準備 )
230-
/// i?stop ( 【判斷】兼【移位】,留下 i )
231-
/// cell@ trim cell! ( do 把當格前後空白都刪掉 )
243+
/// i?stop ( 【判斷】兼【移位】,留下 i,此 i 不能破壞 )
244+
/// cell@ trim cell! ( do 把當格前後空白都刪掉,i 沒用到就放著 )
232245
/// 1 nap rewind ( 重複 )
233-
/// auto ( 收尾 )
246+
/// auto ( 收尾 )
247+
///
248+
/// \ Example-2: 檢查選中的格子是否都是數字,若非就印出 i 繼續,做完 i 自動消失
249+
/// cr manual 0 [begin] ( 前置準備 )
250+
/// i?stop ( 【判斷】兼【移位】,留下 i,此 i 不能破壞 )
251+
/// cell@ js> typeof(pop())=='number' ( i number? )
252+
/// [if] ( i 不能破壞 ) [else] dup ( i 不能破壞 ) . cr [then] ( 若非 number 印出 i )
253+
/// 1 nap [again] ( 重複 )
254+
/// auto ( 收尾 )
234255

235256
: @?stop ?cell@ if drop else stop then ; // ( -- ) Stop if the activeCell is not value
236257
/// Example, 一路往下只要【當格】有值就把它抄到右邊去:
@@ -489,7 +510,7 @@ function lookup(index){ // return hash[index] or undefined
489510
[then] \ excel.app exists
490511

491512
\ -- end of source code --
492-
513+
493514
<comment>
494515
\ \ ================ How to open an Excel file ============================================
495516
\ \

3hta/f/git.f

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,12 @@
337337

338338
\ git log 很有用!
339339

340-
: log-verbose ( -- ) \ Read the commit log, 'q' to stop.
341-
<shell> git log </shell> ;
340+
: log-verbose ( [options...] -- ) \ Read the commit log, 'q' to stop.
341+
s" git log " CR word + </shell> ;
342+
/// See also 'log' command.
342343
/// "git log -10" to see only the recent 10 commits
344+
/// log-verbose master \ to see also newer commits of 'master' branch
345+
/// log-verbose develop \ to see also newer commits of 'develop' branch
343346

344347
: 還原檔案 ( <filename1 filename2 ...> -- ) \ 把檔案從「最後的 commit」裡恢復回來。
345348
s" git checkout -- " CR word + </shell> ;
@@ -468,8 +471,13 @@
468471

469472
\ 第 10 天:認識 Git 物件的絕對名稱
470473

471-
: log ( -- ) \ Read the simplified commit log, 'q' to stop. Also 'log-verbose'.
474+
: log ( -- ) \ Read the simplified commit log, 'q' to stop.
472475
<shell> git log --pretty=oneline --abbrev-commit </shell> ;
476+
/// HEAD may not be at top of the list when debugging older commit.
477+
/// Use below examples to see them all, even newer commits:
478+
/// git log master --pretty=oneline --abbrev-commit
479+
/// git log develop --pretty=oneline --abbrev-commit
480+
/// See also 'log-verbose' command
473481

474482
\ 第 11 天:認識 Git 物件的一般參照與符號參照
475483

@@ -1055,6 +1063,3 @@
10551063
js: dictate(pop()) ;
10561064
/// 抹掉本文 js> $(".article")[0] removeElement
10571065

1058-
1059-
1060-

3hta/f/misc.hta.f

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,38 @@ Math.sign = function sign(x) { return x > 0 ? 1 : x < 0 ? -1 : 0; };
5555
( Word array ) (aliases) ;
5656
/// Used in DOS box batch program for jeforth to ignore DOS words.
5757

58+
proc-env COMPUTERNAME char 31ENB667 = [if]
59+
5860
\ ----- NIC on/off utility -----
5961

60-
17 value officeLAN // ( -- n ) DeviceID of the OA LAN NIC. Change this for your case.
61-
/// "where deviceid = 19" is for my LRV2 OA only
62-
/// Need administrator privilege, run 'dos' check title.
63-
/// Run 3HTA.bat through right click to 'Run as administrator'.
64-
/// Set NIC deviceID : "19 to officeLAN" misc.f
65-
/// Get NIC deviceID : "activeNIC :> deviceid ." wmi.f
66-
/// See all NIC devices : "list-all-nic" wmi.f
62+
0 value officeLAN // ( -- n ) DeviceID of the OA LAN NIC. Change this for your case.
63+
/// Loaded by find-office-nic command automatically
64+
/// Need administrator privilege, Run 3HTA.bat through right click to 'Run as administrator'.
65+
/// Set NIC deviceID : 19 to officeLAN
66+
/// Get NIC deviceID : activeNIC :> deviceid
67+
/// See all NIC devices : list-all-nic
68+
/// "where deviceid = 8" is for my LRV2 OA
69+
70+
: is-office-nic? ( "caption" -- boolean ) \ 用 Caption 來辨認 OA 的 office LAN 是那個 nic
71+
<js> tos().indexOf("ThinkPad USB-C Dock Ethernet")!=-1</jsV>
72+
<js> pop(1).indexOf("Intel(R) Ethernet Connection (4) I219-LM")!=-1</jsV>
73+
or ;
74+
75+
: find-office-nic ( -- ) \ Load officeLAN with office NIC automatically
76+
"" getNIC ( nic nic ... ) \ No where clause, get all of them
77+
#nic ?dup if for
78+
>r r@ :> caption is-office-nic? \ 找到了
79+
if
80+
r@ :> NetConnectionStatus==2 \ must be connected
81+
if
82+
r@ :> DeviceID to officeLAN
83+
then
84+
then
85+
r> drop
86+
next then ;
87+
88+
0 to officeLAN find-office-nic officeLAN [if] [else]
89+
<js> alert("officeLAN not found! Manually '8 to officeLAN' for nicon,nicoff") </js> [then]
6790

6891
: (nicoff) ( -- ) \ Turn off the NIC (the certain where clause is for my LRV2 only)
6992
\ s" where deviceid = 19" getNIC :> disable()
@@ -102,4 +125,9 @@ Math.sign = function sign(x) { return x > 0 ? 1 : x < 0 ? -1 : 0; };
102125
\ nicoff 60 * 1000 * nap nicon ;
103126
\ last :: comment=tick('officeLAN').comment
104127

128+
[then]
129+
130+
131+
\ --- The End ---
132+
105133

3hta/f/skype.f

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
2+
\ Skype4com COM document
3+
\ http://users.skynet.be/fa258239/bestanden/skype4com/skype4com.pdf
4+
5+
6+
<vb>
7+
Set skype = GetObject("","skype4com.skype")
8+
vm.push(skype)
9+
</vb> constant skype // ( -- obj ) The skype4com COM object
10+
11+
: skype.isRunning skype :> Client.IsRunning ; // ( -- boolean )
12+
: skype.start ( -- ) \ start running the skype client
13+
skype.isRunning if else skype :: Client.Start() then ;
14+
/// None blocking command, you need to check status before using it.
15+
16+
: skype.attach ( -- ) \ attach the bot to skype
17+
skype :: Attach() ;
18+
19+
: skype.attachmentStatus ( -- statusCode ) \ check status code
20+
skype :> AttachmentStatus ;
21+
22+
: skype.Convert.TextToAttachmentStatus ( "TOKEN" -- statusCode )
23+
skype :> Convert.TextToAttachmentStatus(pop()) ;
24+
/// -1 means unknown token
25+
26+
\ 執行 ok 但不知在幹嘛
27+
\ skype js: tos().SendCommand(pop().Command(0,"PING","PONG",true))
28+
\ skype js: tos().SendCommand(pop().Command(0,"PING"))
29+
30+
: skype.CurrentUserHandle ( -- "skypeID" ) \ It returns "h.c.chen" for me
31+
skype :> CurrentUserHandle ;
32+
33+
\ 這個成功,好多!同時暗示這些 messages 可以操作。
34+
: skype.Messages ( -- obj ) \ All messages on the cloud I guess
35+
skype :> Messages ;
36+
skype.Messages :> Count tib.
37+
38+
39+
\ No error, but prints nothing
40+
<comment>
41+
skype <vb>
42+
set oSkype = vm.pop()
43+
vm.type("Active chats:"&VBCRLF) ' 這有點特別,我都忘了
44+
For Each oChat In oSkype.ActiveChats
45+
vm.type(oChat.Timestamp & " " & oChat.Name & " " & oChat.FriendlyName & VBCRLF)
46+
Next
47+
</vb>
48+
</comment>
49+
50+
<comment>
51+
\ 這個 loop 第一個就是我自己,但是我自己不會有我自己的 chat, 出錯可能因此 <-- 猜錯!
52+
\ oChat.Name --> #h.c.chen/$eugene.chin95;24270a00c9f054a7
53+
\ oChat.Timestamp --> VBscript error : Invalid chat name
54+
\ oChat.FriendlyName --> VBscript error : Invalid chat name
55+
56+
skype <vb>
57+
set oSkype = vm.pop()
58+
c = 0
59+
vm.type("All chats:"&VBCRLF)
60+
For Each oChat In oSkype.Chats
61+
If c = 2 Then
62+
vm.type(oChat.Name & VBCRLF)
63+
vm.type(oChat.Timestamp & VBCRLF)
64+
vm.type(oChat.FriendlyName & VBCRLF)
65+
End If
66+
c = c + 1
67+
Next
68+
</vb>
69+
All chats:
70+
#h.c.chen/$eugene.chin95;24270a00c9f054a7
71+
</comment>
72+
73+
<comment>
74+
skype <vb>
75+
set oSkype = vm.pop()
76+
' For Each oChat In oSkype.Chats
77+
' For Each oChat In oSkype.ActiveChats
78+
' For Each oChat In oSkype.MissedChats
79+
For Each oChat In oSkype.RecentChats
80+
' For Each oChat oSkype.BookmarkedChats
81+
vm.type(oChat.Name & VBCRLF)
82+
Next
83+
</vb>
84+
</comment>
85+
86+
<comment>
87+
> skype <vb>
88+
set oSkype = vm.pop()
89+
Set oUser = oSkype.User("echo123")
90+
vm.push(oUser)
91+
</vb> constant oUser // ( -- obj ) skype echo123 echo'er
92+
93+
OK
94+
> oUser :> OnlineStatus tib.
95+
oUser :> OnlineStatus \ ==> 1 (number)
96+
OK
97+
> oUser :> handle .
98+
echo123 OK
99+
> oUser skype :> Convert.OnlineStatusToText(pop().OnlineStatus) tib.
100+
oUser skype :> Convert.OnlineStatusToText(pop().OnlineStatus) \ ==> Online (string)
101+
OK
102+
103+
oUser skype <vb>
104+
set oSkype = vm.pop()
105+
set oUser = vm.pop()
106+
Set oCall = oSkype.PlaceCall(oUser.Handle)
107+
vm.push(oCall)
108+
</vb> constant oCall \ 成功! call 上了語音測試系統。
109+
110+
> oCall :> status tib.
111+
oCall :> status \ ==> 7 (number) 掛掉之後的 status
112+
113+
\ 不知幹啥的
114+
skype <js> tos().SendCommand(tos().Command(5,"GET USER echo123 DISPLAYNAME", "USER echo123 DISPLAYNAME", true))</jsV> \ ==> undefined (undefined)
115+
skype <js> tos().SendCommand(pop().Command(3, "GET CURRENTUSERHANDLE", "CURRENTUSERHANDLE", true)) </jsV> \ ==> undefined (undefined)
116+
</comment>
117+
118+
119+
stop
120+
121+
122+
123+
124+
125+
126+
127+
128+
> skype :> Client.Start() \ 真的就 Activate Skype Client 了!
129+
130+
> skype :> friends
131+
> .s
132+
0: undefined (undefined)
133+
1: [object Object] (object) \ 要用 enum 看
134+
135+
> dup Enumerator
136+
> .s
137+
0: undefined (undefined)
138+
1: [object Object] (object) \ skype.friends collection
139+
2: [object Object] (object) \ skype.friends enumerator
140+
> constant friends // ( -- enumerator ) my skype friends
141+
142+
friends <js>
143+
enum = pop()
144+
while(!enum.atEnd()){
145+
type(enum.item().Name + '\n')
146+
enum.moveNext()
147+
}
148+
</js>
149+
150+

3hta/f/wmi.f

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,7 @@
117117
/// activeNIC :> enable() \ return 5 is failed when not an administrator
118118
/// check #nic for the active NIC count if there are many.
119119

120-
: list-all-nic ( -- ) \ List all NIC devices
121-
cr ." ---- List all NIC ----" cr
122-
"" getNIC ( nic nic ... ) \ No where clause, get all of them
120+
: nics-on-stack ( nic1 nic2 ... -- ) \ Print NIC objects on data stack, #nic is their count
123121
#nic ?dup if for
124122
>r r@ :> caption . cr
125123
." / NetConnectionStatus: " r@ :> NetConnectionStatus . cr
@@ -131,6 +129,16 @@
131129
r> drop
132130
next then ;
133131

132+
: list-all-nic ( -- ) \ List all NIC devices
133+
cr ." ---- List all NICs ----" cr
134+
"" getNIC ( nic nic ... ) \ No where clause, get all of them
135+
nics-on-stack ;
136+
137+
: list-active-nic ( -- )
138+
cr ." ---- List Acive NICs ----" cr
139+
"" activeNIC ( nic nic ... ) \ No where clause, get all of them
140+
nics-on-stack ;
141+
134142
<selftest>
135143
." List all NIC" cr
136144
"" getNIC ( nic nic ... ) \ No where clause, get all of them

0 commit comments

Comments
 (0)