基礎迴圈+識圖

阿Q熊發表於2024-07-27
/* 按下指定按鍵執行操作 */
Do
    key = WaitKey()
    /* F2 */
    If key = 113 Then
        KeyDown "Ctrl" , 1
        Delay 30
        KeyPress "C" , 1
        Delay 30
        KeyUp "Ctrl" , 1
        Delay 30
    /* F4 */
    ElseIf key = 115 Then
        KeyDown "Ctrl" , 1
        Delay 30
        KeyPress "V" , 1
        Delay 30
        KeyUp "Ctrl" , 1
        Delay 30
    End If
Loop





/* 提示框找滑鼠鍵碼 */
last_click = WaitClick()
MessageBox "您按下了" & last_click

Do
    mouse = WaitClick()
    /* 按下滑鼠左鍵鍵碼 */
    If mouse = 32769 Then
        Do
            KeyPress "a" , 1
            /* 彈起滑鼠左鍵 */
            If GetLastClick() = 32770 Then
                Exit Do
            End If
        Loop
    End If
Loop

找圖:
設定參照物相對路徑:抓抓->框選圖片->另存為->把圖片加入附件中->
全部命令->顏色/圖形命令->FindPic找圖->插入->->->

/* 找到記事本並寫入4個a */
Do
    FindPic 0,0,1920,1080,"Attachment:\記事本.bmp",0.9,intX,intY
    If intX > -1 Then
        TracecPrint "圖片座標:" & intX & "," & intY
        /* 
            左上角座標
            相對座標(15,99)
        */
        IfColor intX + 15 , intY+99 , "FFFFFF" , 0 Then
            MoveTo 734, 267
            LeftClick 1
            Delay20
            key = WaitKey()
            /* 等待按A */
            If key = 65 Then
                KeyPress "A", 4
            End If
        End If
        Delay20
    End If
Loop

相關文章