' Last update: ver.1 2020/01/12 ver.2 2020/11/16 ' F-name = AA_Tibet_Auto.vbs ' [ Please save this file to your Disk, by Ctrl+S (or, mouse right click/ save file as), as name "AA_Tibet_Auto.vbs" ' (not "AA_Tibet_Auto.vbs.txt") ] ' line left " ' (comma)" indicates a comment-line. ' *** Automatic keyboard operation by vbs. in Windows *** (C) Kumara Douji on 2019/12/10 ,, this is freeware. *** FREEWARE *** ' At least, This job works in Window + Google Chrome. In other environment, I didn't test. ' "Kumara-hand" is an alias name of "Kumara Auto Macro", hand = manipulation. ' 【Remark: 】This AP is not difficult, so, if you encounter a trouble, please fix by yourself. perhaps , it's possible. I think so. ' Save folder is Windows OS's "DownLoad" folder is OK, you are able to forget the save-place. ' File name is not important, after download, you can change its name to your favorite name. but, extension ".vbs" must not be changed. ' This job's dialog Box resides on display left-top corner. ' '*** manual *** ' ↓ request input --- 4 functions supported. inputbox value last one character is subject to "s", ".", "3" or "others" "3" is default. ' if necessary, explicit click to activate the page.s --- from url to url HTML source generator ' if necessary, explicit click to activate the page. --- add pronunciation to dictitionary view ' if necessary, explicit click to activate the page.x --- convert Tibetan words spell into pronounce ' if necessary, explicit click to activate the page.3 --- 3 mode selection mode: "s" or "." or other? ' 2022/10/10 Google Crome の addressbar から%d, {tab} で以前は、本体ページに移動したが、 ' 最近は、addressbar に tab_icon が 2 個追加されたため、{tab 3} しないといけなくなった。 ' このため、動作不正となった。これを正した。個数が将来増えると、再度補正必要。疲れる。 '*** manual end *** '**** Subroutine **** Function kb(str0, msec, ite) 'sendkeys() and sleep() Subroutine ' kb = keyboard ; str0 = sendkeys string image, msec = number of sleep msec, ite = number of iteration/ repeat n ' ommit 3 parameters was rejected by compiler, so you must write as kb "^c",0,1 . thus style. ' kb "^c",, was err. kb "^c", was err , too. all numeric value must be specified explicitly. For i = 1 To 1000 if str0 <> "" then 'WshShell.Popup "str0 = " & str0,,"debug2" ' debug mode WshShell.SendKeys str0 ' *** sendkeys core command *** end if if msec <> 0 then : Wscript.Sleep msec : end if If i = ite Then : Exit For ' n times case Next End Function Function wait_load(acc) ' call by on Alt+T or Alt+S position, acc are "%t" or "%s" ' variable wait time tuning acc_mark = "Alt+T" ' access-key mark if acc = "%s" then acc_mark = "Alt+S" end if For jj = 1 to 10 ' wait for LOAD complete 300ms cycle chk,,, if LOAD complete, pos is InBox str1 = "" kb "",300,1 'sleep 300 ms kb "+{tab}",50,1 ' locate outer iframe from inputBox like kb acc,100,1 ' locate Alt+T/ Alt+S dummy box (= load counter) , sendkeys("%t" or "%s") kb "^c",100,1 ' copy its value to clipboard str1 = createobject("htmlfile").parentwindow.clipboarddata.getdata("text") & "" ' force string 'msgbox "debug strTTT = " & str1 & ", jj = " & jj if str1 = acc_mark then 'msgbox "debug " &acc_mark& " = " & str1 & ", jj = " & jj exit for ' pos = Alt+T or Alt+S end if ' this is not LOAD completed, wait 500 ms more Next End Function Function ak(acc) 'access-key through %d+{tab} ' Sometimes Google %t executes was egnored from inner INPUTBOX. this is avoid this. ' but readonly inputbox was excepted. ' ex. old: kb "%t",300,1 rewrite: ak("%t") kb "%d",300,1 ' inserted to address bar position, kb "{tab}",50,3 ' inserted from 2022/10 {tab} to {tab 3} ; Google degrade in address bar. kb acc,500,1 ' enter keyboard acc image. ex. acc = %l etc. i.e. jump %l interface End Function '************************* '**** Main Routine start *********************** Set WshShell=Wscript.CreateObject("Wscript.Shell") ' parameters cnt = 1 ' loop counter, including cnt = 1 is make option "ON" at 1st time loop flag. ' now is ended " ." every times ON mode is not default. ret = "if necessary, explicit click to activate the page.2" ' InputBox function value init. --- inherit in Do Loop Do ' Do loop (AP body) : endless loop ,, end by "cancell" request. For kkk=1 to 1 ' one only loop 99999 ---- inner one cycle ("For" structure easy to exit/skip than "If" structure.) ' InputBox --- (xpos, ypos) = (-4000, 0) please tuning to your display. -4000 Twips, Twip=1/1440 inch, so 4000 Twips=4000*2.54 /1440=7.056 cm ---- so, 10 cm ≒ 5670 Twip ok? 'ret=InputBox ("#" & cnt& ": Hello, now activated caret position is on Kumara page & not in THL converter iframe ?," &vbCrLf & vbCrLf& "if so, you can push right OK button." ,"Kumara Auto Macro", ret ,-4000, 0) ret=InputBox ("#" & cnt& ": Hello, if You want to quit , push right Cancel button." &vbCrLf & vbCrLf& "↓ request input","Kumara Auto Macro", ret ,-4000, 0) if ret = "" then '= cancell ' -1-1-1-1 WScript.Quit end if ' -1-1-1-1 ' *** start confirm message dialog *** ended = Right(ret,1) ' inner ended character if ended = "2" then '00000 mess2 = """2"" ended. 2 select mode" &vbcr & vbcr& "Search + add phenetics → 【 Yes 】 ," &vbcr& "THL Phonetics tool → 【 No 】 ," &vbcr& "Add phenetics only , or Cancel → 【 Cancel 】" ret_select = msgbox(mess2,vbYesNoCancel+vbQuestion,"Kumara Auto Macro") if ret_select = vbYes then '11111 ended = "s" ' trick , change ' old "s" + "old "." together func elseif ret_select = vbNo then ended = "x" 'trick , change elseif ret_select = vbCancel then ended = "." 'Exit For 'exit this cycle ' 33333 if msgbox("Add Phonetics only → 【 OK 】 ," &vbcr& "true Exit → 【 Cancel 】" ,vbOKCancel+vbQuestion,"Kumara Auto Macro") = vbCancel then Exit For 'exit this cycle end if ' 33333 end if '11111 else mess = "*** Start confirm ***" &vbcr&vbcr& "-- This is "" " & Right(ret,1) & " "" ended mode. OK ?" if msgbox(mess,vbOKCancel+vbQuestion,"Kumara Auto Macro") = vbCancel then '2222 'if WshShell.Popup(mess,,"Kumara Auto Macro",vbOKCancel+vbQuestion) = vbCancel then Exit For 'exit this cycle end if '22222 end if ' 00000 ' end: strt confirm proc. ' debug 'if msgbox ("ended = " & ended, vbOKCancel,"debug") = vbCancel then 'Exit For 'exit this cycle 'end if '2020/11 add this procedure *** Get HTML source image function ***** ' sendkeys on parade !! it is. '*** src_src_src *** start if ended = "s" then ' "s mode" strt + "dot mode" preperation strt kb "%d",50,1 ' Alt+T preparation kb "{tab}",50,3 ' 2022/10, {tab} to {tab 3} kb "%t",20,1 kb "{del}",50,1 ' clear in_Box , reset "wdlist" comlete mark "Alt+T" kb "%d",50,1 kb "{tab}",50,6 ' r-src bottun positioning ; 更に、2020/11/22 r-src に、iframe 初期 road 実施を追加 ' ↑ 2022/10; 50,4 to 50,6 changed. +2 shift kb "~",500,1 ' click , get url& set url to inputbox 'chk url get failure --- destroy clipboard !!! 2020/11/28 kb "{tab}",50,10 'pos to url input box kb "^c",200,1 ' copy url string to clipboard chkurl = createobject("htmlfile").parentwindow.clipboarddata.getdata("text") if Left(chkurl,4) <> "http" then msgbox "err happened in getting url. so, exit. ex. word was not registered." Exit For 'exit this cycle ' err happen, all is over -- exit end if 'if msgbox ("test",vbOKCancel,"debug") = vbCancel then 'Exit For 'exit this cycle 'end if kb "+{tab}",50,2 ' copy below url bottun positioning kb "~",300,1 ' click "copy url add to clip button" 'kb "{tab}",50,1 ' move out from inputbox, cuz, "alt+s" action ignored in inputbox. -- Now, dont happen? why? 'kb "%s",500,1 ak("%s") ' replaced 'kb "{tab}~",500,1 'click init iframe load , click init Tool href. 500 msec 待ち。 ' init load 待ちは、wait_load("%s") 方式を採用しない。∵ clipboard が壊され、 url add が消えるから。 'msgbox "debug" ' 2020/11/22 以降、r_src ボタンにて init 実施済。 'kb "%s",20,1 kb "{del}",50,1 ' clear in_Box , reset load compelted mark 'msgbox "debug" kb "{tab}",50,5 ' go into iframe inner kb " ",50,1 ' write "space" , reset the option mark "HTTP headers" kb "+{tab}",50,1 kb "^v~",500,1 'set url into input box, and push "enter" 'msgbox "??? debug" wait_load("%s") ' wait i/o completed at end pos= alt+S ; exactly wait kb "{tab}",50,2 ' go to in iframe kb "^a",100,1 'ctrl+A kb "^c",1000,1 'ctrl+C kb "{tab}",50,1 ' out inframe box , move to textarea box kb "^a",100,1 'ctrl+A kb "^v",1000,1 'ctrl+V kb "%d",50,1 ' jump to address bar kb "{tab}",50,11 ' move to "Modern" button , 2022/10 , 9 to 11 change. kb "~",50,1 ' click ' Exit For 'exit this cycle ' all is over -- exit, so, don't go to next <>"." check. no more. ended = "." ' trick next proc. continue wait_load("%t") ' wait wdlist completed at end pos= alt+T ; exactly wait end if ' ' "s mode" end '*** src_src_src *** end ' above is "s" mode added procedure, below is old procedure,, -- no changed. ' *** start secret macro : "Non-Dot" mode *** --- new logic under inputBox Max size is 2046 bytes limit. if ended <> "." then ' Dialog input value end is not "." --- converter only signal. *** new 00000 *** kb "^c",300,1 ' copy user now selcted data to clip board. "^c",0,1 was sometimes bad. so, set 300. str2 = createobject("htmlfile").parentwindow.clipboarddata.getdata("text") ' original input image 'msgbox "x mode debug" '2020/11/24 mis ope check if lenb(str2) > 2000 then ' 0000_big if msgbox ("Yuor clipboard data is > 2000 bytes, ok?", vbOKCancel+vbInformation,"ope miss?") = vbCancel then ' 1111_big Exit For 'exit this cycle end if ' 1111_big end if ' 0000_big ret1 = vbOK ' init Do while ret1 = vbOK ' vbCancel case or Location chk was OK case, exits ** loop1 ** kb "%d",50,1 ' address bar in Windows web ' in note-pad, string is now selected, and {tab} sendkeys does, then, makes delete string and pos shift. ' 2022/10 Google adressbar 仕様変更で、{tab} は{tab 3} に変更必要。しかし、下記 coding 意味不明。 ' このままにしておく。多分、ここは、走らない。 kb "{home}{tab}{bs}",50,1 ' trick of avoiding for note pad file destruction 2020/11/22 'kb "{tab}",50,1 ' supposed InputBox of Phonetics iframe, go outer kb "%t",500,1 ' Loate Alt+T accesskey --- dummy kb "^c",0,1 ' read Alt+T data ck_str = createobject("htmlfile").parentwindow.clipboarddata.getdata("text") if ck_str = "Alt+T" then exit Do ' exit loop1 end if ' validity check alternate --- this is need. avoid file destroying. ret1 = msgbox ("Validity check :" &vbCRLF& "*** Input data is out of Kumara page case. ***:" &vbCRLF& "Is ""Alt+T"" InputBox's background color is not ""gray"", now,"&vbCRLF& "if re-try, Push OK (= I'll 3 sec. sleep & re-check) or Cancel (= end)."&vbCRLF&"[if re-try, Please open/ click the TAB of Kumara Dictionary web-page, soon.]"&vbCRLF&"(Kumara-hand execites short-cut-key, Alt+D (= address bar Focus), {tab}, Alt+T after then.)" &vbCRLF& "If TAB click falls in loop, in such case, Please click any point of Kumara Dictionary page body area out of iframe." ,vbOKCancel, "Kumara Non-Dot mode") kb "",3000,1 'sleep 3000 ms Loop ' retry loop ** loop1 ** IF ret1 = vbCancel THEN ' cancell 123123 Exit For 'exit this cycle --- force end END IF '123123 ' every time ON check last image is {space}{non dot} , in this mode, cnt=1 chk is not supported, on purpose. if Left(Right(ret,2),1) = " " then ' = space/ blank ONONON ---- changed to always kb "+{tab}",20,1 ' locate "init/ clear" button kb "~",2000,1 ' {enter} & 2000ms sleep ---- when Load complete, location is in InputBox. kb "{tab}",20,5 ' locate "Add input to output" Option kb " ",50,1 'push {space} --- switch "ON" kb "+{tab}",20,5 ' return Alt end if ' ONONON 'str2 = createobject("htmlfile").parentwindow.clipboarddata.getdata("text") ' original input image mat_ = split(str2,vbCRLF) ' mat_(0), ..., mat_(UBound(mat_)) str3 = "" For mm=0 To UBound(mat_) ' mm is matrix # 'WshShell.Popup "mm = " & mm & ", mat_(mm) = " & mat_(mm),,"debug" if len(mat_(mm)) <> 0 then str3 = str3 & "| " & mat_(mm) & " $" & vbCRLF end if Next 'WshShell.Popup "str3 = " & str3,,"debug2" ' copy to clipboard WshShell.Run "AA_Tibet_Auto_C.vbs", 0, false ' DOS prompt invisible, false = no wait complete, 1000ms after, ^c execute if lenb(str3) < 2046 then ' 88888 InputBox "work1","Kumara copy",str3, -4000,0 ' display dialogBox, All selected input area else WshShell.Popup str3,,"Kumara copy [Popup method]" end if ' 88888 'msgbox "??? debug" ' now clipboard is new image kb "{tab}",100,1 ' move to iframe InputBox kb "^a",0,1 ' select all kb "^v",100,1 ' paste ' restore clipboard original image WshShell.Run "AA_Tibet_Auto_C.vbs", 0, false if lenb(str3) < 2046 then ' 99999 InputBox "work1","Kumara copy",str2, -4000,0 ' display dialogBox, All selected input area else WshShell.Popup str2,,"Kumara copy" end if ' 99999 ' execute Converter kb "+{tab}",50,1 ' locate "Alt+T button", inplicit all select kb " ",50,1 ' set {space} , not set "i" as init kb "{tab}",50,1 ' locate inpuBox again kb "^{enter}",0,1 ' execute converter 'kb "",3000,1 ' 1000 ms later --- this is last, so, we can set long sleep time before 1000, now 3000 wait_load("%t") ' wait i/o completed at end pos= alt+T ; exactly wait kb "{tab}",50,7 'positining OutputBox kb "^a",50,1 ' Ctrl+A all select kb "^c",0,1 ' Copy kb"%d",200,1 ' jump to address bar kb "{tab 3}",50,1 ' {tab} , 2022/10 {tab} to {tab 3} changed. kb "%b",100,1 ' jump to Alt+B --- Bigger textarea kb "^a",50,1 'all select kb "^v",100,1 ' paste Exit For 'exit this cycle end if ' *** new 00000 *** ' *** END: secret macro *** ' *** "Dot" mode : start *** ' You entered "OK" --- 1st, jump to address bar "Alt+D", and , then {tab}, and "Alt+L" dummy input read-only box. kb "%d",100,1 ' address bar in Windows web kb "{tab 3}",50,1 ' 2022/10 Google de_grade , so {tab} to {tab 3} change. kb "%l",500,1 'Alt+L Accesskey "l" dummy readonly input box , implicit Ctrl+A ' *** validity check *** kb "^c",0,1 'ctrl+C copy to clipboard 'read clipboard --- this special interface is Windows & vbs only. javascript no supported. str1 = createobject("htmlfile").parentwindow.clipboarddata.getdata("text") IF str1 <> "Alt+L" THEN ' illegal format 22222 msgbox "** ERROR ** Alt+L access was failed. I will skip." &vbCrLf& "check environment. ex. call from in a THL iframe. (?)",,"Kumara Dot mode" Exit For 'exit this cycle END IF ' 22222 ' Next, we do option force "ON" chk. before copying wd_list to clip board. clipboard will be destroyed. ' do Initial load, and , set flag "ON" , i/o complete logic applied. ' 2020/11/24 Monitor input box のoff/ on 管理機能追加。 位置は、Alt+T に飛ぶ。 kb "%t",50,1 kb "+{tab}",50,2 'postioning to Monitor input_box kb "^c",50,1 ' Ctrl+C copy to clipboard str1 = createobject("htmlfile").parentwindow.clipboarddata.getdata("text") if str1 = "off" then ' ON_ 100100100 kb " ",50,1 ' set "space" as non-off mark to Monitor box 日本語 fep 介入も平気。変換候補ナシ '2020/11/24 Monitor 値が off とは、Dic Ap road 直後, or init ボタン実施直後なので、init road は不要。 '単に iframe 内の option 変更と monitor 値の off を space に変更、だけで良い。{space} senkeyは、無い。 'if true or cnt = 1 or Right(ret,2) = " ." then ' ★★ true or を追加した。★★ ON_ 100100100 'kb "{tab}",50,2 'Alt+T ' jump Alt+T dummy inputBox, implicit all_select 'kb " ",50,1 ' set {space} , not set "i" as init -- "i" is bad by batting of Japanese Kanji converter ' {space} key is only one Japanese Kanji converter ignored special key. 'kb "+{tab}",50,1 ' locate "init/reset" button 強制再ロードした。 'kb "~",0,1 ' click button 'wait_load("%t") ' wait i/o completed 'kb "%t",50,1 'ak("%t") ' replaced Alt+T にいて動いていない。多分。 kb "{tab}",20,8 'from Alt+T to "Add input to output" option, repeat times 8 kb " ",50,1 ' space 1 time = check click --- check mark "ON" 'kb "+{tab}",20,6 'back to Alt+T end if ' ON_ 100100100 ak("%l") ' replaced Alt+L の位置に戻る。fron iframe to outer jmp tric. %d 経由 trick ' wd_list textarea positioning kb "{tab}",0,1 kb "^a",0,1 'ctrl+A select all kb "^c",300,1 'ctrl+C copy to clipboard ---- i.e. input data saved kb "{tab}",20,1 '+ out inptbox ' Next, operation of "THL’s Online Tibetan Phonetics Converter" kb "%t",500,1 'Alt+T ' jump Alt+T dummy inputBox ' Option make force "ON" at first time only. after 2, I don't know. this maintenance is due to user oneself. ' Locate to inputBox to Paste the input image kb "{tab}",50,1 ' positionaing to inputBox kb "^a",0,1 'select all kb "^v",300,1 'ctrl+V paste to inputBox of Phonetics converter 'msgbox "After paste inputBox" kb "+{tab}",50,1 ' locate "Alt+T button", inplicit all select kb " ",50,1 ' set {space} , not set "i" as init kb "{tab}",50,1 ' locate inpuBox again 'msgbox "After i-mark set" kb "^{enter}",0,1 '{enter} = "Make Phonetics" button push;; 4000 msec under 4000 is bad, ^A is odd. heavy ' variable wait time tuning wait_load("%t") ' wait i/o completed 'For jj = 1 to 10 ' wait for LOAD complete 300ms cycle chk,,, if LOAD complete, pos is InBox 'str1 = "" 'kb "",300,1 'sleep 300 ms 'kb "+{tab}",50,1 ' locate outer iframe from inputBox like 'kb "%t",100,1 ' locate Alt+T dummy box (= load counter) 'kb "^c",100,1 ' copy its value to clipboard 'str1 = createobject("htmlfile").parentwindow.clipboarddata.getdata("text") & "" ' force string ''msgbox "debug strTTT = " & str1 & ", jj = " & jj 'if str1 = "Alt+T" then ''msgbox "debug strTTT = " & str1 & ", jj = " & jj 'exit for 'end if '' this is not LOAD completed, wait 500 ms more 'Next '---- outputbox has created ' After output box, control is odd. So, back to start point by back {tab}. and re-positioning. ' now location is inputBox in iframe (^{enter} sleep time is very long needed. ) kb "{tab}",50,7 '---- positioning Alt+T to outputBox ; repeat 7 times 'msgbox "debug2 after move to outbox" kb "^a",0,1 'ctrl+A --- copy outputbox / textarea kb "^c",300,1 'ctrl+C 'msgbox "debug3 after out copy" kb "{tab}",50,6 ' positioning to Pair_list ; repeat 6 times kb "^a",0,1 ' select all kb "^v",300,1 ' Paste, now, copy from Converter to Dict. is complete kb "+{tab}",50,1 'shift+{tab} kb "{enter}",0,1 ' click Re-make button ---- 2020/11 sometimes , ignored why? '2020/11 ignored. non reflect inner HTML replace result. ' -- so, insert dummy setTiomout in parent javascript after remake_dic() function call. ' logic is not wrong. so not to change interrupt circomstance, this Ap should sleep on purpose. ' この loop 一サイクルが終わるとこのAP は inputbox 再表示等、cpu 喰い処理がはいる。 ' また、日本語 fep の漢字・英字切り替え mess も出て、tak 的には busy 状況を生む。 ' inner HTML すっぽ抜けと関係する?? 。疑問。ignore は、Kumara 辞書が置き立て直後の英単語検索時に多い。 kb "",2000,1 ' Long sleep 2 sec. i.e. No disturb other task. ' *** "Dot" mode : end *** Next ' one only For kkk=1 loop , 9999 cnt = cnt +1 Loop ' Do endless loop Set WshShell = Nothing WScript.Quit