sudo mirakurun restart
pm2 restart epgstation
カードリーダーのチェック sudo pcsc_scan でOK Japanese Chijou Digital B-CAS Card (pay TV)
tgifで作られた古いepsファイルがフォントのエラーで開けない時の対処法。。
epsファイルがフォントが理由で開けない場合のチェック事項。。
テキストエディタでepsファイルを直接ひらく。
%! %%BoundingBox: 248 573 467 716 %%Title: prob_circ %%CreationDate: Tue Sep 18 17:13:49 2001 %%Creator: Tgif-3.0J.18 by William Chia-Wei Cheng (william@cs.UCLA.edu)
こんなふうにtgifで作られてるかわかる。
- 以下のページのようなeps かチェック。
http://www.tnlab.inf.uec.ac.jp/tips/postscript.html
下みたいの状態だと今回の方法でうまくいくかも。
%%Title: OCFeucfont.ps %%Creator: shikida@cs.titech.ac.jp, ueno@cs.titech.ac.jp %%CreationDate: 1991-2-27 %%EndComments % <font> OCFcopyfont <font> /OCFcopyfont { dup maxlength 1 add dict begin { 1 index /FID ne 2 index /UniqueID ne and {def} {pop pop} ifelse } forall currentdict end } bind def % <newfont> <asciifont> <kanjifont> OCFeucfont /OCFeucfont { 12 dict begin dup type /nametype eq { findfont } if dup /WMode known { dup /WMode get /WMode exch def WMode 1 eq { [0.0 1.0 -1.0 0.0 0.0 0.30] makefont } if } if OCFcopyfont dup begin /Encoding Encoding FMapType dup 2 eq { pop 128 128 } { 5 eq { 256 256 } { /compositefont errordict /invalidfont get exec } ifelse } ifelse getinterval def end /kanjifont exch definefont exch dup type /nametype eq { findfont } if exch /FDepVector [ 4 2 roll ] def /FontType 0 def /FMapType 4 def /FontMatrix matrix def /Encoding [ 0 1 ] def /FontBBox {0 0 0 0} def dup /FontName exch def currentdict end definefont pop } def % <newfont> <asciifont> <kanjifont> eucfont /eucfont { dup findfont /FMapType get 9 eq { CIDeucfont} { OCFeucfont} ifelse } def
objファイルを新しいtgifで開き、保存しなおす。epsで出力すれば修正されている。
以下のように修正
1. 2行ある部分の片方をコメントアウト。
2. 日本語はTime-Roman- などの接頭字を消す。
% TEXT 0 setgray newpath 515 235 moveto 584 235 lineto 584 255 lineto 515 255 lineto closepath 1 setgray fill 0 setgray /Times-Roman-GothicBBB-Medium-EUC-H /Times-Roman /GothicBBB-Medium-EUC-H eucfont /Times-Roman-GothicBBB-Medium-EUC-H findfont [17 0 0 -17 0 0] makefont setfont gsave 516 251 moveto (\245\327\245\355\241\274\245\326) show grestore
修正後
% TEXT 0 setgray newpath 515 235 moveto 584 235 lineto 584 255 lineto 515 255 lineto closepath 1 setgray fill 0 setgray %/Times-Roman-GothicBBB-Medium-EUC-H /Times-Roman /GothicBBB-Medium-EUC-H eucfont /GothicBBB-Medium-EUC-H findfont [17 0 0 -17 0 0] makefont setfont gsave 516 251 moveto (\245\327\245\355\241\274\245\326) show grestore
以下のような新しい書き方に変えてしまう
- \241\274 が8進数の文字
- move xxx が位置
- [,,] が文字の大きさなので、
下のような形にいれかえる。
% TEXT newpath 0 setgray gsave 1 setlinewidth 430 175 moveto gsave 0 setgray /Ryumin-Light-EUC-H findfont dup /WMode known {dup /WMode get 1 eq {[17 0 0 -17 0 0] makefont} if} if [20 0 0 -20 0 0] makefont setfont (\245\252\245\267\245\355\245\271\245\263\241\274\245\327) show grestore grestore
最近の2020のTEXはepsの扱いが苦手なので、うまくとりいれないと失敗する。 - 原則は, dvipdfmx を使う。
\usepackage[dvipdfmx]{graphicx}
dvipdfmxときちんとし指定しないとだめらしい。
原則はincludegraphicsでよみとる
それでも読み取れないときは、epsファイルのソースをみて1行目が
%!
しかない場合は、
%!PS-Adobe-3.0 EPSF-3.0
とか適当に書き加える。
参考
dvipdfmx での EPS 画像挿入が最近アレな話
https://zrbabbler.hatenablog.com/entry/2014012/1390313675
LaTeX+dvipdfmx でEPS画像がずれる場合の対策
https://qiita.com/zr_tex8r/items/089b56291588f7b05b02
cygwinのtgif導入にとまどったので、導入過程のメモです。ソースからいれる必要あり。
tar xvzf tgif-QPL-4.2.5.tar.gz rm Tgif.tmpl cp Tgif.tmpl-cygwin Tgif.tmpl
wget http://bourbon.usc.edu/tgif/ftp/tgif/patches/tgif-QPL-4.2-patch5a.gz wget http://bourbon.usc.edu/tgif/ftp/tgif/patches/tgif-QPL-4.2-patch5b.gz gzip -d tgif-QPL-4.2-patch5a.gz gzip -d tgif-QPL-4.2-patch5b.gz patch -b -p0 --verbose < ../tgif-QPL-4.2-patch5a patch -b -p0 --verbose < ../tgif-QPL-4.2-patch5b
SYS_LIBRARIES = -lm
に変える。
xmkmf make depend make install
./configure make make install
なんかエラーができがOKなはず。 tgif.exeができる。 -- xmkmf がない場合は、
apt-cyg install imake
-- ライブラリ -lmxu がないとコンパイルで怒られる場合は、
apt-cyg install libxmu-dev
Ryumin-Light-EUC-H
っていうモリサワフォントに現実にx11中にあるフォントを結びつけている。だから、ロジカルフォントに指定したものがx11の xfs に登録されていないとため。
そして、きちんと登録xrdb ~/.Xdefault
変更後の.Xdefaults は以下の通り。
Tgif.DoubleByteInputMethod: kinput2 Tgif.Lang: ja_JP.EUC Tgif.Modifiers: false Tgif.ConvSelection: _JAPANESE_CONVERSION Tgif.SquareDoubleByteFonts: \n\ -*-*-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,H,Ryumin-Light-EUC-H\n\ -*-*-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,H,Ryumin-Light-EUC-H\n\ -*-*-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,H,Ryumin-Light-EUC-H\n\ -*-*-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,H,Ryumin-Light-EUC-H\n\ \n\ -*-*-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,H,GothicBBB-Medium-EUC-H\n\ -*-*-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,H,GothicBBB-Medium-EUC-H\n\ -*-*-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,H,GothicBBB-Medium-EUC-H\n\ -*-*-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,H,GothicBBB-Medium-EUC-H\n\ \n\ -*-*-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,V,Ryumin-Light-EUC-V\n\ -*-*-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,V,Ryumin-Light-EUC-V\n\ -*-*-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,V,Ryumin-Light-EUC-V\n\ -*-*-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,V,Ryumin-Light-EUC-V\n\ \n\ -*-*-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,V,GothicBBB-Medium-EUC-V\n\ -*-*-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,V,Ryumin-Light-EUC-V\n\ -*-*-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,V,Ryumin-Light-EUC-V\n\ -*-*-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,V,Ryumin-Light-EUC-V\n\ \n\ -*-*-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,V,GothicBBB-Medium-EUC-V\n\ -*-*-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,V,GothicBBB-Medium-EUC-V\n\ -*-*-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,V,GothicBBB-Medium-EUC-V\n\ -*-*-medium-r-*--%d-*-*-*-*-*-jisx0208.1983-*,V,GothicBBB-Medium-EUC-V Tgif.RyuminShowFontChar: \244\242 Tgif.GothicBBBShowFontChar: \244\316
-- フォントの登録
実際にcygwinにはx11にはjisx0208 が登録されていなかったので、外からフォントをもらってくる。
1. とりあえずのfontをダウンロード
cygwin +x 日本語アプリケーション
http://www.eaflux.com/cygwin-xfree-jp-supplement/
のstartup.tgz
http://www.eaflux.com/cygwin-xfree-jp-supplement/binaries/startup.tgz
に日本語フォントがあるので、それをダウンロードして解凍する。
2. 日本語のフォントの登録(1)
http://www.okadajp.org/RWiki/?Windows%20%E3%81%AB%E3%82%88%E3%82%8B%20eps%20%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E7%B7%A8%E9%9B%86(ad*be%E3%82%BD%E3%83%95%E3%83%88%E3%81%AB%E9%A0%BC%E3%82%89%E3%81%AA%E3%81%84%E6%96%B9%E6%B3%95)
を参考にする。
フォントファイルを取り出してコピー。.ttfontsにコピー
mkdir ~/.fonts cp startup/fonts.alias ~/.fonts cp startup/fonts.dir ~/.fonts cp startup/fonts.scale ~/.fonts cd ~/.fonts ln -s `cygpath -u $WINDIR`/Fonts/ms*.ttc . ln -s `cygpath -u $WINDIR`/Fonts/arial*.ttf . ln -s `cygpath -u $WINDIR`/Fonts/times*.ttf .
フォントを登録する。
https://nmbr8.com/post/how_to_install_noto_sans_cjk_on_centos/
を参考にしつつ、
フォントディレクトリのキャッシュを再構築
fc-cache -f
これで、
fc-list fc-list | grep msgo
とすればフォント一覧がみられるので, MSゴシック等があることが確認できる。
3. 日本語のフォントの登録(2)
次に、xfs xファイルサーバーにフォントを登録する。
xfsにフォントパスを教える。
xset fp+ ~/.fonts xset fp rehash
これは永続的じゃないので、永続的にするには別の設定が必要。
一応フォントが登録されているかのチェック
xlsfonts xlsfonts | grep jis
参考 ryumin font をMSゴシックにおきかえる? http://www.elc.ees.saitama-u.ac.jp/LaTeX/dvipdfmx.html
http://www.kis-lab.com/serikashiki/Linux/Setting07.html http://bourbon.usc.edu/tgif/install.html
「EPS ファイルの中を見てみて Times-Roman-Ryumin-Light-EUC-H や Helvetica-GothicBBB-Medium-EUC-Hなどという名前が出てきたら 要注意」 http://www.tnlab.inf.uec.ac.jp/tips/postscript.html
https://motchy99.blog.fc2.com/blog-entry-74.html
cygwinに基本アプリをインストール https://uguisu.skr.jp/Windows/app.html
EPGstationの andoroid で リアルタイムをvlcプレイヤーで再生できるようにする。
config.json
の"mpegTsViewer": {
は以下のように変更
intend は外部アプリ実行。 ADRESSSはURLの受け渡しっぽい。
"android": "intent://ADDRESS#Intent;package=org.videolan.vlc;type=video;scheme=http;end"
mirakurunの設定の変更でいけるか?
/usr/local/etc/mirakurun/channels.yml
に以下のを加える
- name: テレビ東京携帯 type: GR channel: '23' serviceId: '1456'
mirakurun の再起動
sudo mirakurun restart
serviceIDは、 http://EPGStationアドレス;ポート/api/channels 等で取得可能 GUI の設定のconfig確認できる。 http://miraikurunIP:40772/
http://EPGStationアドレス;ポート/api/channels
からfirefoxでチャンネルリストをコピペしてtv.txt
として保存
653 cat tv.txt | grep name | awk -F"\t" '{print $2}' | awk '{print $1}' > tvname_all.txt 654 cat tvname_all.txt 655 cat tv.txt | grep id | awk -F"\t" '{print $2}' | grep 3 | awk '{print "http://EPGアドレスポート/api/streams/live/"$1"/mpegts?mode=2"}' > url_all.txt 656 cat url_all.txt 657 paste tvname_all.txt urlall.txt | awk -F"\t" 'BEGIN{print "\#EXTM3U"}{print "\#EXTINF: 0,"$1"\n"$2}' > oneseglist.m3u8 658 paste tvname_all.txt urlall.txt | awk -F"\t" 'BEGIN{print "\#EXTM3U"}{print "\#EXTINF: 0,"$1"\n"$2}' > oneseglist_all.m3u8
import json v=json.load(open("channels","r")) print("#EXTM3U") url1="http://URL:port/api/streams/live/" url2="/mpegts?mode=2" #url1b="http://URL2:port/api/streams/live/" for i in v: print("#EXTINF: 0,"+i["name"]) print(url1+str(i["id"])+url2) # print("#EXTINF: 0,vp:"+i["name"]) # print(url1b+str(i["id"])+url2)
こんなリスト
#EXTINF: 0,"テレビ東京携帯" http://EPGアドレスポート/api/streams/live/3274201456/mpegts?mode=2 #EXTINF: 0,"NHK総合1・東京" http://EPGアドレスポート/api/streams/live/3273601024/mpegts?mode=2 #EXTINF: 0,"NHK総合2・東京" http://EPGアドレスポート/api/streams/live/3273601025/mpegts?mode=2 #EXTINF: 0,"NHK携帯G・東京" http://EPGアドレスポート/api/streams/live/3273601408/mpegts?mode=2 #EXTINF: 0,"NHKEテレ1東京" http://EPGアドレスポート/api/streams/live/3273701032/mpegts?mode=2 #EXTINF: 0,"NHKEテレ2東京" http://EPGアドレスポート/api/streams/live/3273701033/mpegts?mode=2 #EXTINF: 0,"NHKEテレ3東京" http://EPGアドレスポート/api/streams/live/3273701034/mpegts?mode=2 #EXTINF: 0,"NHK携帯2" http://EPGアドレスポート/api/streams/live/3273701416/mpegts?mode=2 #EXTINF: 0,"日テレ1" http://EPGアドレスポート/api/streams/live/3273801040/mpegts?mode=2 …
pip install pdfminer.six pip install chardet
sixにしないと日本語が認識されないので注意
参考: https://techacademy.jp/magazine/22374
#coding: utf-8 import io import os from pdfminer.pdfparser import PDFParser # (from pdfminer.pdfparser import PDFParserみたいです) from pdfminer.pdfdocument import PDFDocument # (from pdfminer.pdfdocument import PDFDocumentみたいです) from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter from pdfminer.converter import TextConverter from pdfminer.pdfpage import PDFPage os.chdir("F:\\\\dir\\python_test") print(os.getcwd()) retstr = io.StringIO() parser = PDFParser(open("outfile/test2.pdf",'rb')) try: doc = PDFDocument(parser) except Exception as e: print('is not a readable pdf') parser.set_document(doc) rsrcmgr = PDFResourceManager() device = TextConverter(rsrcmgr, retstr) interpreter = PDFPageInterpreter(rsrcmgr, device) # doc.get_pages()はバージョンが古くて、PDFPage.create_pages(doc)とするべきみたいです。 for page in PDFPage.create_pages(doc): #for page in PDFPage.get_pages(doc): interpreter.process_page(page) device.close() str = retstr.getvalue() print(str) retstr.close() str
def ch_pdf2txt(input_filename="test2.pdf",output_filename="test2.txt",output_dir="outfile"): def find_textboxes_recursively(layout_obj): print(layout_obj) #""" #再帰的にテキストボックス(LTTextBox)を探して、テキストボックスのリストを取得する。 #""" # LTTextBoxを継承するオブジェクトの場合は1要素のリストを返す。 if isinstance(layout_obj, LTTextBox): #if isinstance(layout_obj, LTRect): return [layout_obj] # LTContainerを継承するオブジェクトは子要素を含むので、再帰的に探す。 if isinstance(layout_obj, LTContainer): boxes = [] for child in layout_obj: boxes.extend(find_textboxes_recursively(child)) return boxes return [] # その他の場合は空リストを返す。 # Layout Analysisのパラメーターを設定。縦書きの検出を無効にする。 # line_margin :行間幅が大きすぎて誤検出されたので小さくする。 laparams = LAParams(detect_vertical=False,line_margin=0.000000000,char_margin=0.2) # 共有のリソースを管理するリソースマネージャーを作成。 resource_manager = PDFResourceManager() # ページを集めるPageAggregatorオブジェクトを作成。 device = PDFPageAggregator(resource_manager, laparams=laparams) # Interpreterオブジェクトを作成。 interpreter = PDFPageInterpreter(resource_manager, device) # 出力用のテキストファイル #output_txt = open('outfile/output.txt', 'w') output_filename2="outfile\\"+output_filename output_txt = open(output_filename2, 'w') #入力用ファイル #input_pdf=sys.argv[1] #input_pdf="outfile/test2.pdf" input_pdf="outfile\\"+input_filename input_txt = open(input_pdf) def print_and_write(txt): print(txt,end="") #print(txt) output_txt.write(txt) #output_txt.write('\n') syasin_x=10000000000 hyouzu_x=10000000000 renban_x=10000000000 keisaibi_x=10000000000 wareki_x=10000000000 sisi_x=10000000000 page_x=10000000000 dansuu_x=10000000000 midasi_x=10000000000 syasin_flg=True hyouzu_flg=True syasin_flg=True hyouzu_flg=True renban_flg=True keisaibi_flg=True wareki_flg=True sisi_flg=True page_flg=True dansuu_flg=True midasi_flg=True kiji_title_flg=True header_flg=True header_flg2=False print(input_pdf) with open(input_pdf, 'rb') as f: # PDFPage.get_pages()にファイルオブジェクトを指定して、PDFPageオブジェクトを順に取得する。 # 時間がかかるファイルは、キーワード引数pagenosで処理するページ番号(0始まり)のリストを指定するとよい。 for page in PDFPage.get_pages(f): #print(f) print_and_write('\n====== ページ区切り ======\n') interpreter.process_page(page) # ページを処理する。 layout = device.get_result() # LTPageオブジェクトを取得。 print(layout) # ページ内のテキストボックスのリストを取得する。 boxes = find_textboxes_recursively(layout) print(boxes) # テキストボックスの左上の座標の順でテキストボックスをソートする。 # y1(Y座標の値)は上に行くほど大きくなるので、正負を反転させている。 boxes.sort(key=lambda b: (-b.y1, b.x0)) old_y=-100 #print(boxes) for box in boxes: #print(box.get_text()) #print_and_write('-' * 10) # 読みやすいよう区切り線を表示する。 #print_and_write(box.get_text().strip()) # テキストボックス内のテキストを表示する。 #print(box.y1) # print(type(box.get_text())) # print(type("写真")) # print(box) if round(1*box.y1)!=round(1*old_y): #print_and_write("aaa"+str(box.x0)+"aaa") print_and_write("\n") syasin_flg=True hyouzu_flg=True renban_flg=True keisaibi_flg=True wareki_flg=True sisi_flg=True page_flg=True dansuu_flg=True midasi_flg=True kiji_title_flg=True if header_flg2: header_flg=False if "連番" in str(box.get_text()): renban_x=box.x1 print_and_write(box.get_text().replace("\n","")) print_and_write(",") header_flg=True if header_flg: if "掲載日" in str(box.get_text()): keisaibi_x=box.x1 # keisaibi0_x=box.x0 print_and_write(box.get_text().replace("\n","")) print_and_write(",") if "和暦" in str(box.get_text()): wareki_x=box.x1 print_and_write(box.get_text().replace("\n","")) print_and_write(",") if "紙誌" in str(box.get_text()): sisi_x=box.x1 print_and_write(box.get_text().replace("\n","")) print_and_write(",") if "ページ" in str(box.get_text()): page_x=box.x1 print_and_write(box.get_text().replace("\n","")) print_and_write(",") if "段数" in str(box.get_text()): dansuu_x=box.x1 print_and_write(box.get_text().replace("\n","")) print_and_write(",") if "見出し" in str(box.get_text()): midasi_x=box.x1 print_and_write(box.get_text().replace("\n","")) print_and_write(",") if "写真" in str(box.get_text()): # print("syasin",str(box.x0),"syasin") syasin_x=box.x1 print_and_write(box.get_text().replace("\n","")) print_and_write(",") if "表図" in str(box.get_text()): # print("syasin",str(box.x0),"syasin") hyouzu_x=box.x1; print_and_write(box.get_text().replace("\n","")) print_and_write(",") if "記事タイトル" in str(box.get_text()): # print("syasin",str(box.x0),"syasin") kiji_title_x=box.x1; print_and_write(box.get_text().replace("\n","")) #print_and_write(",") header_flg2=True if not header_flg: if (1*box.x1)>=renban_x and int(renban_flg)<=2: #print_and_write("aaa"+str(box.x0)+"aaa") renban_flg=int(renban_flg)+1 if renban_flg == 3: print_and_write(",") if (1*box.x0)>=keisaibi_x and keisaibi_flg: #print_and_write("aaa"+str(box.x0)+"aaa") print_and_write(",") keisaibi_flg=False if (1*box.x0)>=wareki_x and wareki_flg: #print_and_write("aaa"+str(box.x0)+"aaa") print_and_write(",") wareki_flg=False if (1*box.x0)>=sisi_x and sisi_flg: #print_and_write("aaa"+str(box.x0)+"aaa") print_and_write(",") sisi_flg=False if (1*box.x0)>=page_x and page_flg: #print_and_write("aaa"+str(box.x0)+"aaa") print_and_write(",") page_flg=False if (1*box.x0)>=dansuu_x and dansuu_flg: #print_and_write("aaa"+str(box.x0)+"aaa") print_and_write(",") dansuu_flg=False if (1*box.x0)>=midasi_x and midasi_flg: #print_and_write("aaa"+str(box.x0)+"aaa") #print("\n midasi:"+box.get_text()+"\n") print_and_write(",") midasi_flg=False #print("syasin_flg"+str(syasin_flg)+"\n") if (1*box.x0)>=syasin_x and syasin_flg: #print_and_write("aaa"+str(box.x0)+"aaa") #print("test:"+box.get_text()) #print("\n syasin:"+box.get_text()+"\n") print_and_write(",") syasin_flg=False if (1*box.x0)>=hyouzu_x and hyouzu_flg: #print_and_write("aaa"+str(box.x0)+"aaa") #print("\n hyouzu:"+box.get_text()+"\n") print_and_write(",") hyouzu_flg=False if (1*box.x0)>=kiji_title_x and kiji_title_flg: #print_and_write("aaa"+str(box.x0)+"aaa") #print("\n kiji:"+box.get_text()+"\n") print_and_write(",") kiji_title_flg=False print_and_write(box.get_text().replace("\n","")) #print_and_write(",") #print_and_write(str((box.y1))+box.get_text().strip()) old_y=box.y1 output_txt.close() #ch_pdf2txt(input_filename="outfile\\test2.pdf",output_filename="outfile\\test2.txt")
pip3 install pyscreeze pip3 install opencv_python pip3 install pyautogui
anaconda でエラーした場合
python -m pip pyscreeze python -m pip opencv_python python -m pip pyautogui
参考サイトのコードそのまま。 もぐらたたきゲーム https://game.nifty.com/free/50 こんなのが4行でかける衝撃。。
import pyautogui #ずっと繰り返す while True: #特定の範囲から画像と一致する座標(左上の座標と画像の高さ)を全て返す for pos in pyautogui.locateAllOnScreen('head2.png', region=(100, 300, 1500, 800), grayscale=True, confidence=0.950): #座標の1点を取り出して画像の中心を取得する cpos = pyautogui.center(pos) #画像の中心をクリックする pyautogui.click(cpos) #マウスを移動させる(ハンマーでモグラが隠れるのを防ぐため) pyautogui.moveTo(100, 250)
コロンが日本語キーボード対応のバグで入力ができないため以下の修正が必要.
C:\ProgramData\Anaconda3\Lib\site-packages\pyautogui_pyautogui_win.py
def _keyDown(key): # 略 needsShift = pyautogui.isShiftCharacter(key) # 以下を追加 if key == '@': needsShift = False if key == '^': needsShift = False if key == ':': needsShift = False """ # OLD CODE: The new code relies on having all keys be loaded in keyboardMapping from the start. if key in keyboardMapping.keys(): …
import os import pyautogui import time import pyscreeze from pyscreeze import ImageNotFoundException for tryCount in range(100): try: if pyautogui.locateOnScreen("syturyoku.png"): break except ImageNotFoundException: time.sleep(0.1) x,y=pyautogui.locateCenterOnScreen("syturyoku.png") pyautogui.moveTo(x+90,y) pyautogui.click(x+90,y) pyautogui.hotkey('ctrl','a') #pyautogui.press('del',presses=10000) pyautogui.press('del') #time.sleep(0.3) output=r'C:\\Users\user1\Documents\python_test\outfile\test.pdf' print(output) pyautogui.write(output) time.sleep(0.1) pyautogui.press('enter')
ImageNotFoundExceptionは画面がでてくるまでの待ち等に使う。
import os import pyautogui import time import pyscreeze from pyscreeze import ImageNotFoundException def news_article_search(date1,type1,page1): x,y = pyautogui.locateCenterOnScreen("keisai.png") pyautogui.click(x,y) #From pyautogui.moveTo(x+80,y+40) pyautogui.click(x+80,y+40) pyautogui.press('del',presses=20) pyautogui.write(date1) #To pyautogui.moveTo(x+358,y+36) pyautogui.click(x+358,y+36) pyautogui.press('del',presses=20) pyautogui.write(date1) #発効形態 #朝刊 if type1 == 1: pyautogui.moveTo(x+88,y+91) pyautogui.click(x+88,y+91) #夕刊 if type1 == 2: pyautogui.moveTo(x+220,y+91) pyautogui.click(x+220,y+91) #付録 if type1 == 3: pyautogui.moveTo(x+300,y+91) pyautogui.click(x+300,y+91) #号外 if type1 == 4: pyautogui.moveTo(x+400,y+91) pyautogui.click(x+400,y+91) #ページ数 pyautogui.moveTo(x+20,y+160) pyautogui.click(x+12,y+160) pyautogui.press('del',presses=20) pyautogui.write(page1) #検索 pyautogui.moveTo(x+408,y+160) pyautogui.click(x+408,y+160) #検索結果の表示 time.sleep(0.4) for tryCount in range(100): try: if pyautogui.locateOnScreen("gamenmodoru.png"): break except ImageNotFoundException: time.sleep(0.4) try: x,y = pyautogui.locateCenterOnScreen("title.png") pyautogui.moveTo(x,y) pyautogui.click(x,y) except: print("no") x,y = pyautogui.locateCenterOnScreen("gamenmodoru.png") pyautogui.moveTo(x,y) pyautogui.click(x,y) def print_list(output_file_name="test.pdf"): for tryCount in range(100): try: if pyautogui.locateOnScreen("insatsu_list_small.png"): #if pyautogui.locateOnScreen("printamei2.png"): break except ImageNotFoundException: time.sleep(0.3) #x,y = pyautogui.locateCenterOnScreen("printamei2.png") x,y = pyautogui.locateCenterOnScreen("insatsu_list_small.png") pyautogui.moveTo(x+100,y) pyautogui.click(x+100,y) for tryCount in range(100): try: #if pyautogui.locateOnScreen("insatsu_cube.png"): if pyautogui.locateOnScreen("insatu_cubu_list.png"): break except ImageNotFoundException: time.sleep(0.1) #x,y=pyautogui.locateCenterOnScreen("insatsu_cube.png") x,y=pyautogui.locateCenterOnScreen("insatu_cubu_list.png") pyautogui.moveTo(x,y) pyautogui.click(x,y) pyautogui.hotkey('enter') for tryCount in range(100): try: #if pyautogui.locateOnScreen("syturyoku.png"): if pyautogui.locateOnScreen("cubepdf_logo.png"): break except ImageNotFoundException: time.sleep(0.1) x,y=pyautogui.locateCenterOnScreen("cubepdf_logo.png") #x,y=pyautogui.locateCenterOnScreen("syturyoku.png") pyautogui.moveTo(x+60,y+180) #pyautogui.click(x+90,y) pyautogui.click(x+60,y+180) pyautogui.hotkey('ctrl','a') #pyautogui.press('del',presses=10000) pyautogui.press('del') #time.sleep(0.3) output=r'C:\\Users\user1\Documents\python_test\outfile\test.pdf' output='C:\\\\Users\\user1\\Documents\\python_test\\outfile\\'+output_file_name print(output) pyautogui.write(output) time.sleep(0.1) pyautogui.press('enter') try: for tryCount in range(100): #if pyautogui.locateOnScreen("syturyoku.png"): if pyautogui.locateOnScreen("cubepdf_logo.png"): if pyautogui.locateOnScreen("uwagaki_small.png"): print("uwagaki") pyautogui.press('enter') print("hello") time.sleep(0.5) else: print("no") break except ImageNotFoundException: print("end") #break def print_article(output_file_name="test.pdf"): for tryCount in range(100): try: #if pyautogui.locateOnScreen("insatsu_list_small.png"): if pyautogui.locateOnScreen("printamei.png"): break except ImageNotFoundException: time.sleep(0.3) x,y = pyautogui.locateCenterOnScreen("printamei.png") #x,y = pyautogui.locateCenterOnScreen("insatsu_list_small.png") pyautogui.moveTo(x+100,y) pyautogui.click(x+100,y) for tryCount in range(100): try: if pyautogui.locateOnScreen("insatsu_cube.png"): #if pyautogui.locateOnScreen("insatu_cubu_list.png"): break except ImageNotFoundException: time.sleep(0.1) x,y=pyautogui.locateCenterOnScreen("insatsu_cube.png") #x,y=pyautogui.locateCenterOnScreen("insatu_cubu_list.png") pyautogui.moveTo(x,y) pyautogui.click(x,y) pyautogui.hotkey('enter') for tryCount in range(100): try: #if pyautogui.locateOnScreen("syturyoku.png"): if pyautogui.locateOnScreen("cubepdf_logo.png"): break except ImageNotFoundException: time.sleep(0.1) x,y=pyautogui.locateCenterOnScreen("cubepdf_logo.png") #x,y=pyautogui.locateCenterOnScreen("syturyoku.png") pyautogui.moveTo(x+60,y+180) #pyautogui.click(x+90,y) pyautogui.click(x+60,y+180) pyautogui.hotkey('ctrl','a') #pyautogui.press('del',presses=10000) pyautogui.press('del') #time.sleep(0.3) output=r'C:\\Users\user1\Documents\python_test\outfile\test.pdf' output='C:\\\\Users\\user1\\Documents\\python_test\\outfile\\'+output_file_name print(output) pyautogui.write(output) time.sleep(0.1) pyautogui.press('enter') time.sleep(0.1) #print("uwagaki0") #if pyautogui.locateOnScreen("uwagaki_small.png"): # print("uwagaki") # pyautogui.press('enter') try: for tryCount in range(100): #if pyautogui.locateOnScreen("syturyoku.png"): if pyautogui.locateOnScreen("cubepdf_logo.png"): if pyautogui.locateOnScreen("uwagaki_small.png"): print("uwagaki") pyautogui.press('enter') print("hello") time.sleep(0.5) else: print("no") break except ImageNotFoundException: print("end") #break #紙面表示 def print_paper(output_file_name="test.pdf"): #一覧が表示されるまで待つ for tryCount in range(100): try: if pyautogui.locateOnScreen("kensaku_keka_ha.png"): break except ImageNotFoundException: time.sleep(0.3) #List のprint pyautogui.hotkey('alt','f') pyautogui.hotkey('enter') print_list(output_file_name="test2.pdf"); #rewrewrew #紙面の表示 ##リストのactive 化 print("test2a") x,y=pyautogui.locateCenterOnScreen("kensaku_keka_ha.png") pyautogui.click(x,y) print("test2") ##紙面表示 pyautogui.hotkey('alt', 'V') pyautogui.hotkey('enter') #time.sleep(0.4) #紙面の表示まで待ち for tryCount in range(100): try: if pyautogui.locateOnScreen("title_simen.png"): break except ImageNotFoundException: time.sleep(0.3) #ピンの削除 pyautogui.hotkey('alt', 'D') pyautogui.hotkey('P') #印刷 pyautogui.hotkey('ctrl', 'p') print_article(output_file_name=output_file_name) #記事窓を閉じる pyautogui.hotkey('alt','f4') time.sleep(0.5) #リスト窓を閉じる x,y=pyautogui.locateCenterOnScreen("kensaku_keka_ha.png") pyautogui.click(x,y) pyautogui.hotkey('alt','f') #time.sleep(0.5) pyautogui.hotkey('c') news_article_search(date1="46/06/09",type1=2,page1="1") print_paper(output_file_name="out_460609"+"_"+"2"+"_"+"1"+".pdf")
x11 の設定ファイルが壊れていいるらしい。。
そこで、コンソールでログインする。
Ctrl+Alt+F2
もしくは、
Ctrl+Alt+F1
でコンソール画面がでるので。
そこでx11を修正すれば良い。
Ubuntuが黒い画面のまま動きません 今までも黒
https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q10159900740
Linuxをインストールしたのに画面が黒いままで起動しないときの対処例
https://www.garunimo.com/program/linux/column-linux3.php
Xクライアント、サーバの動かし方
https://qiita.com/hana_shin/items/4ccf9d53aecd290d2cbb
-Linuxでよく聞く「Xとは?」とX11のインストール方法 https://eng-entrance.com/linux-gui-x11