×
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
- Newer: UWSCタグ一覧を予測変換候補に入れておくと便利
- Older: ログインスクリプトをUWSCで自動生成
UWSCやらなんやら
Home > > nameがsubmitだとsubmit出来ない件
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
Home > > nameがsubmitだとsubmit出来ない件
Home > 実用スクリプト > nameがsubmitだとsubmit出来ない件
FC2で先日UPした自動ログインスクリプトを作成しようと思ったら
完成した物がログインできない。
生成した物の中身を見ても誤りはなさげ
で調べてみたら
doc.forms(0).submit()
でsubmitきない場合もあるみたいね。
理由はnameタグの中身がsubmitだとそっちを優先してしまうみたい。
でそういうやつは
doc.forms(0).submit.click()
とかにしなければ通らないと言うことで
ifb !(doc.forms(get_form).elements(i).name="")
fput(fid,"doc.forms("+get_form+")."+doc.forms(get_form).elements(i).name+"clicke()")
else
fput(fid,"doc.forms("+get_form+").submit()")
endif
という風に変えてみた。
なんかUPしてから毎日修正してる気が・・
よく運用してからUPするべきであった。
15日追記:ゴミが2箇所残ってたので削除しましたorz
修正版
//---ユーザー設定(ブラウザを選択してください)
Public brow=1 //1:IE 2:Sleipnir
scr=1 //1:スクランブルを掛ける 2:掛けない
del_org=1 //1:orgファイル削除 2:削除しない
//---初期設定
ifb brow=1
browname="IE"
else
browname="pnir"
endif
dim get_form,submit_btn_flag,img_btn_flag,script_btn_flag,imgsrc[250]
Public aelem
//---ブラウザ別オブジェクト
ifb brow=2
pnir=CreateOleObj("Sleipnir.API")
IE=pnir.GetWebBrowserObject((pnir.GetDocumentID(pnir.ActiveIndex)))
ACW(HNDTOID(pnir.Handle))
else
IE=GetActiveOLEObj("InternetExplorer.Application")
ACW(HNDTOID(IE.hwnd))
endif
doc=IE.document
//---生成ファイル設定
fileLogIe=GET_CUR_DIR+"\"+repStrFNam(IE.LocationName)+browname+"_login"+".uws"
//---スクリプト生成
fid=fopen(fileLogIe,F_WRITE)
ifb brow=2 //ログインページオープンpnirの場合
fput(fid,temp1+pnir.URL+"<#DBL>,true)")
fput(fid,"BusyWaitpnir(pnir)")
fput(fid,"doc=pnir.GetWebBrowserObject((pnir.GetDocumentID(pnir.ActiveIndex))).document")
else //ログインページオープンIEの場合
fput(fid,temp0+IE.LocationURL+"<#DBL>)")
fput(fid,"BusyWait(IE)")
fput(fid,"doc=IE.document")
endif
fput(fid,"COM_ERR_IGN")
//---ID&pass挿入部分生成
COM_ERR_IGN
for i=0 to doc.forms.length-1
ifb doc.forms(i).method="post"
for ii=0 to doc.forms(i).elements.length-1
ifb (doc.forms(i).elements(ii).type="text" or doc.forms(i).elements(ii).type="password") and !(doc.forms(i).elements(ii).value="")
fput(fid,temp2+doc.forms(i).elements(ii).name+"<#DBL>")
fput(fid,temp3+doc.forms(i).elements(ii).value+"<#DBL>")
fput(fid,temp4)
get_form=i
endif
next
endif
ifb !(get_form="")
break
endif
next
COM_ERR_RET
ifb get_form=""
Msgbox("ID又はpassが見当りません")
exitexit
endif
//---ログイン部分生成(submitボタンがある場合)
for i=1 to doc.forms(get_form).elements.length-1
ifb doc.forms(get_form).elements(i).type="submit"
ifb !(doc.forms(get_form).elements(i).name="")
fput(fid,"doc.forms("+get_form+")."+doc.forms(get_form).elements(i).name+".click()")
else
fput(fid,"doc.forms("+get_form+").submit()")
endif
ifb brow=1
fput(fid,temp5)
else
fput(fid,temp6)
endif
submit_btn_flag=1
endif
next
ifb submit_btn_flag=0 //submitボタンが無い場合(画像ボタン又はjavascriptボタン探索)
//---画像ボタンのソースをimgsrcに格納
inplength=doc.all.tags("input").length
for i=0 to inplength-1
ifb doc.all.tags("input").item(i).type="image"
imgsrc[i]=doc.all.tags("input").item(i).src
img_btn_flag=1
endif
next
//---ボタンにonclikイベント生成
ifb img_btn_flag=1 //画像ボタンの場合のイベント
for i=0 to doc.all.tags("input").length-1
ifb doc.all.tags("input").item(i).type="image"
OleEvent(doc.all.tags("input").item(i), "HTMLButtonElementEvents", "onclick", "Eventsrc")
endif
Next
else //javascriptボタンの場合イベント
for i=0 to doc.all.tags("a").length-1
ifb pos("javascript",doc.all.tags("a").item(i).outerHTML)>0
OleEvent(doc.all.tags("a").item(i), "HTMLAnchorEvents", "onclick", "Eventsrc")
endif
Next
endif
//---onclikイベント発生待ち
While aelem=""
Fukidasi("調査しますログインボタンを押してください")
wend
//---クリックされたボタンのソースの照合
ifb img_btn_flag=1 //画像ボタンの場合
for i=0 to inplength-1
ifb imgsrc[i]=aelem.src //一致itemでスクリプト生成
fput(fid,"nowsrc=doc.all.tags(<#DBL>input<#DBL>).item("+i+").src")
fput(fid,"if !(nowsrc=<#DBL>"+aelem.src+"<#DBL>) then exitexit")
fput(fid,"doc.all.tags(<#DBL>input<#DBL>).item("+i+").click()")
ifb brow=1
fput(fid,temp5)
else
fput(fid,temp6)
endif
break
endif
Next
else //javascriptボタンの場合
for i=0 to doc.all.tags("a").length-1
ifb doc.all.tags("a").item(i).outerHTML=aelem.outerHTML //一致itemでスクリプト生成
fput(fid,"doc.all.tags(<#DBL>a<#DBL>).item("+i+").click()")
ifb brow=1
fput(fid,temp5)
else
fput(fid,temp6)
endif
script_btn_flag=1
break
endif
Next
endif
endif
//---作成出来なかった場合
ifb submit_btn_flag=0 and img_btn_flag=0 and script_btn_flag=0
Msgbox("ログインボタンが見当りません。<#CR>作成を中止します。")
exitexit
endif
//---生成ファイルをcloseして作成完了
fclose(fid)
Fukidasi("作成完了")
Sleep(2)
//--スクランブル処理
ifb scr=1
UPath = GET_UWSC_DIR + "\uwsc.exe "
exec(UPath + "/a <#dbl>" + fileLogIe + "<#dbl>")
ifb del_org=1 //オリジナルファイル削除
del_file = GET_CUR_DIR+"\"+"*_login.org"
DosCmd("del <#DBL>" + del_file + "<#DBL>")
endif
endif
//---テンプレ
TEXTBLOCK temp0
IE=GetActiveOLEObj("InternetExplorer.Application")
IE.Navigate("
ENDTEXTBLOCK
TEXTBLOCK temp1
pnir=CreateOleObj("Sleipnir.API")
pnir.NewWindow("
ENDTEXTBLOCK
TEXTBLOCK temp2
for i=0 to doc.forms.length-1
for ii=0 to doc.forms(i).elements.length-1
ifb doc.forms(i).elements(ii).name="
ENDTEXTBLOCK
TEXTBLOCK temp3
doc.forms(i).elements(ii).value="
ENDTEXTBLOCK
TEXTBLOCK temp4
endif
next
next
ENDTEXTBLOCK
TEXTBLOCK temp5
COM_ERR_RET
//------IE用wait処理
Procedure BusyWait(ie)
Sleep(0.5) // Wait
Const TIME_OUT = 90
tm = Gettime()
repeat
Sleep(0.2)
ifb Gettime() - tm > TIME_OUT
MsgBox("Time Out:BusyWait")
ExitExit
endif
until (! ie.busy) and (ie.readyState=4)
Sleep(0.5)
Fend
ENDTEXTBLOCK
TEXTBLOCK temp6
COM_ERR_RET
//------pnir用wait処理
Procedure BusyWaitpnir(pnir)
Sleep(0.5) // Wait
Const TIME_OUT = 90
tm = Gettime()
pid=pnir.GetDocumentID(pnir.ActiveIndex)
repeat
Sleep(0.2)
ifb Gettime() - tm > TIME_OUT
MsgBox("Time Out:BusyWait")
ExitExit
endif
until (! pnir.IsBusy(pid))
Sleep(0.5)
Fend
ENDTEXTBLOCK
//------ファイル名に使えない文字列の変換
//眠たい詩人様のHTMLStarkNaked.uwsから流用させてもらいました
//http://nem.symphonic-net.com/uwsct/0610uwsct.html
function repStrFNam(string1)
dim aryChr[]="/","[","]","\",":",";","*","?","#","<#CR>","<#DBL>","<#TAB>","<",">","|"," "," "
dim i
for i=0 to length(aryChr)-1
string1=chgmoj(trim(string1),aryChr[i],"_")
next
string1=chgmoj(chgmoj(chgmoj(string1,"__","_"),"_-","-"),"-_","-")
result=string1
fend
//------onclikイベント
Procedure Eventsrc
ifb brow=2
pnir=CreateOleObj("Sleipnir.API")
IE=pnir.GetWebBrowserObject((pnir.GetDocumentID(pnir.ActiveIndex)))
else
IE=GetactiveOLEObj("InternetExplorer.Application")
endif
doc=IE.document
aelem=doc.activeElement
Fend