Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hcchengithub committed Jun 17, 2018
2 parents 0ad10a9 + 93794a5 commit 558bfe7
Show file tree
Hide file tree
Showing 12 changed files with 5,506 additions and 5,050 deletions.
37 changes: 29 additions & 8 deletions 3hta/excel/excel.f
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
\ "Application Object (Excel)" http://msdn.microsoft.com/en-us/library/office/ff194565(v=office.15).aspx
\ VBA Language Reference http://msdn.microsoft.com/en-us/library/bb190882(v=office.11).aspx
\ Microsoft Excel Visual Basic Reference http://msdn.microsoft.com/en-us/library/aa272254(v=office.11).aspx
\ Cell (Range) properties VBA Reference http://msdn.microsoft.com/en-us/library/office/aa174290(v=office.11).aspx
\ Excel constants, e.g. xlUp = -4162, can be found in AutoIt UDF source code excel.au3.

include wsh.f
Expand All @@ -31,14 +32,15 @@

null value excel.app // ( -- obj ) The Excel.Application object or undefined if no excel exists.
/// "Application Object (Excel)" http://msdn.microsoft.com/en-us/library/office/ff194565(v=office.15).aspx
s" where name = 'ExCeL.ExE'" count-process ( count )

excel.app.count 1 > [if]
cr cr ." W A R N I N G ! (from excel.f)" cr cr
." Multiple Excel.Application are running, I can only handle one of them." cr
." The excel I've got the handle should be high-lighted, you see that? Please use" cr
." that one or you'll have to use the 'kill-excel' command to close all of them and" cr
." then '--excel.f-- include excel.f' to restart me, the excel.f module, again." cr cr
[then]

excel.app.count [if]
\ 用這行就錯了! <vb> On Error Resume Next:Set xl=GetObject("","excel.application"):vm.push(xl)</vb> 會開出新 Excel.Application。
<vb> On Error Resume Next:Set xl=GetObject(,"excel.application"):vm.push(xl)</vb> \ 這行才是沿用既有的 Excel.Application。
Expand All @@ -49,11 +51,22 @@
excel.app [if] \ excel.app exists

: activeCell excel.app :> ActiveCell ; // ( -- obj ) Get the ActiveCell object
/// The 3 active things: cell, sheet, and workbook
/// activeCell :> offset(0,1).formula tib.
/// activeCell :: Interior.Color=0xbbggrr
/// activeCell :> worksheet.name tib.
/// activeCell :> application \ ==> Microsoft Excel (object)
/// activeWorkbook :> worksheets(1).name tib. --> sheet name
/// activeWorkbook :> worksheets('NaMe').name tib. --> case insensitive
/// activeWorkbook :> worksheets('匯總').name \ ==> 匯總 (string)
/// activeWorkbook :> name tib. \ ==> filename

: activeSheet excel.app :> ActiveSheet ; // ( -- obj ) Get the ActiveSheet object
/// activeSheet :> name tib.
' activeCell :> comment last :: comment=pop()

: activeWorkbook excel.app :> ActiveWorkbook ; // ( -- obj ) Get the ActiveWorkbook object
/// activeWorkbook :> name tib.
' activeCell :> comment last :: comment=pop()

: selection excel.app :> selection ; // ( -- obj ) Get the selected object ( a range object )
/// selection :> count tib.
/// selection :: item(123).value="hello"
Expand Down Expand Up @@ -225,12 +238,20 @@
else selection :: item(tos()).activate() then ;
/// 這組工具:上,下,左,右,當格,的【判斷】都依賴這些 cell
/// 值,若不然時就要用本命令 i?stop 透過 selection 來完成。
/// \ Example, 選中的格子都去掉頭尾空白
/// \ Example-1, 選中的格子都去掉頭尾空白,做完 i 自動消失
/// manual 0 cut ( 前置準備 )
/// i?stop ( 【判斷】兼【移位】,留下 i )
/// cell@ trim cell! ( do 把當格前後空白都刪掉 )
/// i?stop ( 【判斷】兼【移位】,留下 i,此 i 不能破壞 )
/// cell@ trim cell! ( do 把當格前後空白都刪掉,i 沒用到就放著 )
/// 1 nap rewind ( 重複 )
/// auto ( 收尾 )
/// auto ( 收尾 )
///
/// \ Example-2: 檢查選中的格子是否都是數字,若非就印出 i 繼續,做完 i 自動消失
/// cr manual 0 [begin] ( 前置準備 )
/// i?stop ( 【判斷】兼【移位】,留下 i,此 i 不能破壞 )
/// cell@ js> typeof(pop())=='number' ( i number? )
/// [if] ( i 不能破壞 ) [else] dup ( i 不能破壞 ) . cr [then] ( 若非 number 印出 i )
/// 1 nap [again] ( 重複 )
/// auto ( 收尾 )

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

\ -- end of source code --

<comment>
\ \ ================ How to open an Excel file ============================================
\ \
Expand Down
17 changes: 11 additions & 6 deletions 3hta/f/git.f
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,12 @@

\ git log 很有用!

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

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

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

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

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

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




42 changes: 35 additions & 7 deletions 3hta/f/misc.hta.f
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,38 @@ Math.sign = function sign(x) { return x > 0 ? 1 : x < 0 ? -1 : 0; };
( Word array ) (aliases) ;
/// Used in DOS box batch program for jeforth to ignore DOS words.

proc-env COMPUTERNAME char 31ENB667 = [if]

\ ----- NIC on/off utility -----

17 value officeLAN // ( -- n ) DeviceID of the OA LAN NIC. Change this for your case.
/// "where deviceid = 19" is for my LRV2 OA only
/// Need administrator privilege, run 'dos' check title.
/// Run 3HTA.bat through right click to 'Run as administrator'.
/// Set NIC deviceID : "19 to officeLAN" misc.f
/// Get NIC deviceID : "activeNIC :> deviceid ." wmi.f
/// See all NIC devices : "list-all-nic" wmi.f
0 value officeLAN // ( -- n ) DeviceID of the OA LAN NIC. Change this for your case.
/// Loaded by find-office-nic command automatically
/// Need administrator privilege, Run 3HTA.bat through right click to 'Run as administrator'.
/// Set NIC deviceID : 19 to officeLAN
/// Get NIC deviceID : activeNIC :> deviceid
/// See all NIC devices : list-all-nic
/// "where deviceid = 8" is for my LRV2 OA

: is-office-nic? ( "caption" -- boolean ) \ 用 Caption 來辨認 OA 的 office LAN 是那個 nic
<js> tos().indexOf("ThinkPad USB-C Dock Ethernet")!=-1</jsV>
<js> pop(1).indexOf("Intel(R) Ethernet Connection (4) I219-LM")!=-1</jsV>
or ;

: find-office-nic ( -- ) \ Load officeLAN with office NIC automatically
"" getNIC ( nic nic ... ) \ No where clause, get all of them
#nic ?dup if for
>r r@ :> caption is-office-nic? \ 找到了
if
r@ :> NetConnectionStatus==2 \ must be connected
if
r@ :> DeviceID to officeLAN
then
then
r> drop
next then ;

0 to officeLAN find-office-nic officeLAN [if] [else]
<js> alert("officeLAN not found! Manually '8 to officeLAN' for nicon,nicoff") </js> [then]

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

[then]


\ --- The End ---


150 changes: 150 additions & 0 deletions 3hta/f/skype.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@

\ Skype4com COM document
\ http://users.skynet.be/fa258239/bestanden/skype4com/skype4com.pdf


<vb>
Set skype = GetObject("","skype4com.skype")
vm.push(skype)
</vb> constant skype // ( -- obj ) The skype4com COM object

: skype.isRunning skype :> Client.IsRunning ; // ( -- boolean )
: skype.start ( -- ) \ start running the skype client
skype.isRunning if else skype :: Client.Start() then ;
/// None blocking command, you need to check status before using it.

: skype.attach ( -- ) \ attach the bot to skype
skype :: Attach() ;

: skype.attachmentStatus ( -- statusCode ) \ check status code
skype :> AttachmentStatus ;

: skype.Convert.TextToAttachmentStatus ( "TOKEN" -- statusCode )
skype :> Convert.TextToAttachmentStatus(pop()) ;
/// -1 means unknown token

\ 執行 ok 但不知在幹嘛
\ skype js: tos().SendCommand(pop().Command(0,"PING","PONG",true))
\ skype js: tos().SendCommand(pop().Command(0,"PING"))

: skype.CurrentUserHandle ( -- "skypeID" ) \ It returns "h.c.chen" for me
skype :> CurrentUserHandle ;

\ 這個成功,好多!同時暗示這些 messages 可以操作。
: skype.Messages ( -- obj ) \ All messages on the cloud I guess
skype :> Messages ;
skype.Messages :> Count tib.


\ No error, but prints nothing
<comment>
skype <vb>
set oSkype = vm.pop()
vm.type("Active chats:"&VBCRLF) ' 這有點特別,我都忘了
For Each oChat In oSkype.ActiveChats
vm.type(oChat.Timestamp & " " & oChat.Name & " " & oChat.FriendlyName & VBCRLF)
Next
</vb>
</comment>

<comment>
\ 這個 loop 第一個就是我自己,但是我自己不會有我自己的 chat, 出錯可能因此 <-- 猜錯!
\ oChat.Name --> #h.c.chen/$eugene.chin95;24270a00c9f054a7
\ oChat.Timestamp --> VBscript error : Invalid chat name
\ oChat.FriendlyName --> VBscript error : Invalid chat name

skype <vb>
set oSkype = vm.pop()
c = 0
vm.type("All chats:"&VBCRLF)
For Each oChat In oSkype.Chats
If c = 2 Then
vm.type(oChat.Name & VBCRLF)
vm.type(oChat.Timestamp & VBCRLF)
vm.type(oChat.FriendlyName & VBCRLF)
End If
c = c + 1
Next
</vb>
All chats:
#h.c.chen/$eugene.chin95;24270a00c9f054a7
</comment>

<comment>
skype <vb>
set oSkype = vm.pop()
' For Each oChat In oSkype.Chats
' For Each oChat In oSkype.ActiveChats
' For Each oChat In oSkype.MissedChats
For Each oChat In oSkype.RecentChats
' For Each oChat oSkype.BookmarkedChats
vm.type(oChat.Name & VBCRLF)
Next
</vb>
</comment>

<comment>
> skype <vb>
set oSkype = vm.pop()
Set oUser = oSkype.User("echo123")
vm.push(oUser)
</vb> constant oUser // ( -- obj ) skype echo123 echo'er

OK
> oUser :> OnlineStatus tib.
oUser :> OnlineStatus \ ==> 1 (number)
OK
> oUser :> handle .
echo123 OK
> oUser skype :> Convert.OnlineStatusToText(pop().OnlineStatus) tib.
oUser skype :> Convert.OnlineStatusToText(pop().OnlineStatus) \ ==> Online (string)
OK

oUser skype <vb>
set oSkype = vm.pop()
set oUser = vm.pop()
Set oCall = oSkype.PlaceCall(oUser.Handle)
vm.push(oCall)
</vb> constant oCall \ 成功! call 上了語音測試系統。

> oCall :> status tib.
oCall :> status \ ==> 7 (number) 掛掉之後的 status

\ 不知幹啥的
skype <js> tos().SendCommand(tos().Command(5,"GET USER echo123 DISPLAYNAME", "USER echo123 DISPLAYNAME", true))</jsV> \ ==> undefined (undefined)
skype <js> tos().SendCommand(pop().Command(3, "GET CURRENTUSERHANDLE", "CURRENTUSERHANDLE", true)) </jsV> \ ==> undefined (undefined)
</comment>


stop








> skype :> Client.Start() \ 真的就 Activate Skype Client 了!

> skype :> friends
> .s
0: undefined (undefined)
1: [object Object] (object) \ 要用 enum 看

> dup Enumerator
> .s
0: undefined (undefined)
1: [object Object] (object) \ skype.friends collection
2: [object Object] (object) \ skype.friends enumerator
> constant friends // ( -- enumerator ) my skype friends

friends <js>
enum = pop()
while(!enum.atEnd()){
type(enum.item().Name + '\n')
enum.moveNext()
}
</js>


14 changes: 11 additions & 3 deletions 3hta/f/wmi.f
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@
/// activeNIC :> enable() \ return 5 is failed when not an administrator
/// check #nic for the active NIC count if there are many.

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

: list-all-nic ( -- ) \ List all NIC devices
cr ." ---- List all NICs ----" cr
"" getNIC ( nic nic ... ) \ No where clause, get all of them
nics-on-stack ;

: list-active-nic ( -- )
cr ." ---- List Acive NICs ----" cr
"" activeNIC ( nic nic ... ) \ No where clause, get all of them
nics-on-stack ;

<selftest>
." List all NIC" cr
"" getNIC ( nic nic ... ) \ No where clause, get all of them
Expand Down
Loading

0 comments on commit 558bfe7

Please sign in to comment.