2010年10月09日

画像自動クリック

UWSCを使ったスクリプト晒してみる。自動検索はやばそうなので、やめておく。

画像サイズを調べて、クリックしていくだけ。

動作中は他の作業は、ほぼ出来ないです。IEが開きまくるから┐(´-`)┌

一応、ポップしたIEは閉じるし、ダイアログもいくつかは閉じる。

表示待ちの処理が、なんかおかしいけどしらん。動くからよしw

他のサイトとかも、やってみるが、取りこぼし多い。

ほんとは、サイトデータ別ファイルから読み込むとかすればいいんだろうけど、よくわからないし、面倒なんで配列で。

HASHTBL hash = HASH_SORT

//csite[][] = クリックサイトurl, 画像横幅, 画像高さ, スキップ数,クリック数(0はmax)
dim csite[][4] = _
"http://www.chobirich.com/", 234, 60, 0, 4,_
"http://www.chobirich.com/", 120, 60, 0, 4,

// IE起動
IE = CreateOLEObj("InternetExplorer.Application")
IE.Visible = True
IE.ToolBar =  False

//クリック開始 -------------------------------------------------------

for ieroop = 0 to (RESIZE(csite) / 5) -1

//サイトデータ入力
curl = csite[ieroop][0]
cgx = csite[ieroop][1]
cgy = csite[ieroop][2]
cskip = csite[ieroop][3]
mck = csite[ieroop][4]
//カウント用クリア
ia = 0
ccg = 0

COM_ERR_IGN  //COMエラー無視

//指定HPを開く
print curl
IE.Navigate(curl)
BusyWait(IE)
MainAW = GETID("Internet Explorer") //アクティブウィンドウを名前を得る

for i = ia to IE.document.Images.length-1 // 画像枚数分ループ

  wkx = IE.document.Images[i].width //横幅 画像サイズ読み取り
  wky = IE.document.Images[i].height //高さ

       ifb cgx = wkx and cgy = wky then //サイズチェック
   ccg = ccg + 1  //サイズの合った画像カウント
   
   ifb ccg > cskip then  //スキップ数確認
   
    IE.Document.Images[i].Click() //画像クリック
    BusyWait(IE)  //表示待ち
    sleep(0.2)
    BCLOSE(MainAW)  //ポップしたIEを閉じる

    IE.Navigate(curl)  //HP開き直し
    BusyWait(IE)  //表示待ち

   endif

   ifb (ccg - cskip) > mck and mck > 0 then //最大クリック回数、越えたら終了
   break
   endif

   ifb COM_ERR_FLG
   print curl
       print "エラーが起こってるみたい" 
   sleep(2)
   COM_ERR_RET
       break
   endif

  ia = i + 1 //検索位置修正
  endif
next

sleep(0.5)
next

//終了-------------------------------
ifb MsgBox("終了しました。",BTN_OK) = BTN_OK
COM_ERR_RET  //エラー処理復帰
endif

//表示待ち- busywait ---------------------
Procedure BusyWait(ie)
  Sleep(0.5)  // Wait
  Const TIME_OUT = 90
  tm = Gettime()
  tmc = 0
repeat
dialog()
    Sleep(0.2)
    ifb Gettime() - tm > TIME_OUT
    IE.Refresh //再読み込み
    tmc = tmc +1
      ifb tmc  = 3 //3回失敗したらメッセージ表示
        //if MsgBox("Time Out:BusyWait",BTN_ABORT or BTN_IGNORE) = BTN_ABORT then ExitExit
        exit
      endif
    tm = 0
    endif
  until (! ie.busy) and (ie.readyState=4)
  Sleep(0.5)
Fend

//------
//ポップしたIEを閉じる
Procedure BCLOSE(MainAW)
wcount = 0
for ip =0 to GETALLWIN( ) -1
if POS("Internet Explorer",STATUS(ALL_WIN_ID[ip],ST_TITLE)) > 1 and ( ALL_WIN_ID[ip]  <> MainAW ) then CTRLWIN(ALL_WIN_ID[ip],CLOSE)
next
sleep(1)
FEND

//ダイアログ対処
Procedure dialog()
id = getid( "セキュリティ", "#32770")
if id > 0 then sckey( id, vk_n) //nキーを押す

id = getid( "Internet Expplorer Unhandled Exception", "#32770")
if id > 0 then sckey( id, vk_enter) //enterキーを押す

id = getid( "Internet Explorer スクリプト","#32770",0.1)
if id > 0 then sckey( id, vk_n) //nキーを押す
Fend

posted by みきの at 00:01 | Comment(0) | TrackBack(0) | ポイントサイト | このブログの読者になる | 更新情報をチェックする
この記事へのコメント
コメントを書く
お名前: [必須入力]

メールアドレス:

ホームページアドレス:

コメント: [必須入力]

認証コード: [必須入力]


※画像の中の文字を半角で入力してください。

この記事へのトラックバック