Lỗi AutoIT , các bác giúp e vs nó khong chay code

Discussion in 'Computer Skills' started by lutuhu, Sep 10, 2017.

Moderators: thaikhanghn
  1. lutuhu

    lutuhu Member

    Joined:
    Oct 19, 2013
    Messages:
    2,842
    Likes Received:
    744
    Skype:
    Chat with me via Skype
    Google Plus:
    Follow me on Google Plus
    Lỗi AutoIT , các bác giúp e vs nó khong chay code
    1. chả là e dang thử auto click trên web , nhưng không hiểu sao nó ko hoạt động , nếu mà tìm ảnh trên màn hình máy tính thi vẫn chay ok

    2. còn 1 cái nữa là , em có 2 câu lệnh , Câu a chay ok . e tắt, mở câu lệnh khác là B,chay B xong , e chậy lại con A thi nó ko hoật đọng , vây
    có phải do e chỉnh thiếu gi ko a ( cây lệnh ở dưới lun)



    Local $x=0,$y=0

    $search=_imageSearch(@ScriptDir&'\vang.bmp',1,$x,$y,0)
    If $search=1 Then MouseMove($x,$y)
    MouseClick ("left")

    $search1=_imageSearch(@ScriptDir&'\xanhbien.bmp',1,$x,$y,0)
    If $search1=1 Then MouseMove($x,$y)
    MouseClick ("left")

    $search2=_imageSearch(@ScriptDir&'\xanhla.bmp',1,$x,$y,0)
    If $search2=1 Then MouseMove($x,$y)
    MouseClick ("left")

    $search3=_imageSearch(@ScriptDir&'\xanh.bmp',1,$x,$y,0)
    If $search3=1 Then MouseMove($x,$y)
    MouseClick ("left")


    Mong các bác giúp đỡ !
     
  2. lutuhu

    lutuhu Member

    Joined:
    Oct 19, 2013
    Messages:
    2,842
    Likes Received:
    744
    Skype:
    Chat with me via Skype
    Google Plus:
    Follow me on Google Plus
  3. emyeusss7

    emyeusss7 Trial Mod Staff Member Trader Verified Kindness Member

    Joined:
    Dec 26, 2010
    Messages:
    1,954
    Likes Received:
    1,233
    Insuree Balance:
    500
    Service Details:
    1|emyeusss7|Software, Tools
    Phone Number:
    Call me!
    Facebook:
    Follow me on Facebook
    Skype:
    Chat with me via Skype
    đổi thành If $search > 0
    tạo 2 function bỏ 2 cái A và B vào
    tạo 1 hàm while true, bỏ 2 cái function vào trong đó cho nó lập, vậy là đc
     
    lutuhu likes this.
  4. lutuhu

    lutuhu Member

    Joined:
    Oct 19, 2013
    Messages:
    2,842
    Likes Received:
    744
    Skype:
    Chat with me via Skype
    Google Plus:
    Follow me on Google Plus
    function la gi vay bac , e ms hoc dc 3 hom @@
     
  5. emyeusss7

    emyeusss7 Trial Mod Staff Member Trader Verified Kindness Member

    Joined:
    Dec 26, 2010
    Messages:
    1,954
    Likes Received:
    1,233
    Insuree Balance:
    500
    Service Details:
    1|emyeusss7|Software, Tools
    Phone Number:
    Call me!
    Facebook:
    Follow me on Facebook
    Skype:
    Chat with me via Skype
    While 1
    _Function_A()
    _Function_B()
    Sleep(10)
    WEnd
    Func _Function_A()
    if......
    EndFunc
    Func _Function_B()
    if......
    EndFunc
     
    lutuhu likes this.
  6. lutuhu

    lutuhu Member

    Joined:
    Oct 19, 2013
    Messages:
    2,842
    Likes Received:
    744
    Skype:
    Chat with me via Skype
    Google Plus:
    Follow me on Google Plus
    em cảm ơn bác :D
     
  7. tuan6956

    tuan6956 Member

    Joined:
    Nov 15, 2013
    Messages:
    1,263
    Likes Received:
    609
    function là hàm @@
     
  8. lutuhu

    lutuhu Member

    Joined:
    Oct 19, 2013
    Messages:
    2,842
    Likes Received:
    744
    Skype:
    Chat with me via Skype
    Google Plus:
    Follow me on Google Plus
    Local $x=0 , $y=0
    $a=_ImageSearch(@ScriptDir&'\test.bmp',1,$x,$y,0)
    $a0=_ImageSearch(@ScriptDir&'\test1.bmp',1,$x,$y,0)
    $a1=_ImageSearch(@ScriptDir&'\test2.bmp',1,$x,$y,0)
    While 1
    _Function_A($a0)
    Sleep(10000)
    _Function_B($a1)
    Sleep(10000)
    _FUnction_C($a)
    Sleep(10)
    WEnd
    Func _Function_A($a0)
    if $a0 = 1 then MouseMove($x,$y)
    Sleep(5000)
    EndFunc
    Func _Function_B($a1)
    if $a1 = 1 Then MouseMove($x,$y)
    EndFunc
    Func _Function_C($a)
    if $a = 1 Then MouseMove($x,$y)
    EndFunc
    bác giúp e với ạ
    tại sao thang search ảnh của e nó chỉ chạy lệnh cuối cùng vậy a
     
  9. rongbay

    rongbay Member

    Joined:
    May 17, 2011
    Messages:
    1,073
    Likes Received:
    492
    inbox full code mình xem thử cho
     
  10. lutuhu

    lutuhu Member

    Joined:
    Oct 19, 2013
    Messages:
    2,842
    Likes Received:
    744
    Skype:
    Chat with me via Skype
    Google Plus:
    Follow me on Google Plus
    Local $x=0 , $y=0
    $a=_ImageSearch(@ScriptDir&'\test.bmp',1,$x,$y,0)
    $a0=_ImageSearch(@ScriptDir&'\test1.bmp',1,$x,$y,0)
    $a1=_ImageSearch(@ScriptDir&'\test2.bmp',1,$x,$y,0)
    While 1
    _Function_A($a0)
    Sleep(10000)
    _Function_B($a1)
    Sleep(10000)
    _FUnction_C($a)
    Sleep(10)
    WEnd
    Func _Function_A($a0)
    if $a0 = 1 then MouseMove($x,$y)
    Sleep(5000)
    EndFunc
    Func _Function_B($a1)
    if $a1 = 1 Then MouseMove($x,$y)
    EndFunc
    Func _Function_C($a)
    if $a = 1 Then MouseMove($x,$y)
    EndFunc
    code day bac oi @@
     
  11. rongbay

    rongbay Member

    Joined:
    May 17, 2011
    Messages:
    1,073
    Likes Received:
    492
    $a=_ImageSearch(@ScriptDir&'\test.bmp',1,$x,$y,0)
    $a0=_ImageSearch(@ScriptDir&'\test1.bmp',1,$x,$y,0)
    $a1=_ImageSearch(@ScriptDir&'\test2.bmp',1,$x,$y,0)
    chỗ ở tren bạn thử khai báo $x0,$y0 cho hình $a0
    và $x1,$y1 cho hình $a1 thử xem sao
    và thay luôn trong 2 func cuối
     
    Last edited: Oct 11, 2017
  12. emyeusss7

    emyeusss7 Trial Mod Staff Member Trader Verified Kindness Member

    Joined:
    Dec 26, 2010
    Messages:
    1,954
    Likes Received:
    1,233
    Insuree Balance:
    500
    Service Details:
    1|emyeusss7|Software, Tools
    Phone Number:
    Call me!
    Facebook:
    Follow me on Facebook
    Skype:
    Chat with me via Skype

    While 1
    $x=0
    $y=0
    $a=_ImageSearch(@ScriptDir&'\test.bmp',1,$x,$y,0)
    If($x <> 0 Or $y <> 0)Then
    MouseMove($x,$y)
    $x=0
    $y=0
    EndIf
    $a0=_ImageSearch(@ScriptDir&'\test1.bmp',1,$x,$y,0)
    If($x <> 0 Or $y <> 0)Then
    MouseMove($x,$y)
    $x=0
    $y=0
    EndIf
    $a1=_ImageSearch(@ScriptDir&'\test2.bmp',1,$x,$y,0)
    If($x <> 0 Or $y <> 0)Then
    MouseMove($x,$y)
    $x=0
    $y=0
    EndIf
    Sleep(1000)
    WEnd


    Trong lập trình, thì có phân biệt chữ Hoa và chữ Thường
    khi code thì nhớ chú ý thật kỹ từng ký tự
    khi khai báo biến thì nên viết full chữ thường khi code chưa quen
    vì chỉ cần sai 1 ký tự Hoa hay Thường thì cũng dẫn đến việc bị lỗi code mà đi tìm thì loài coan mắt ko có ra @@
     
    lutuhu likes this.
  13. lutuhu

    lutuhu Member

    Joined:
    Oct 19, 2013
    Messages:
    2,842
    Likes Received:
    744
    Skype:
    Chat with me via Skype
    Google Plus:
    Follow me on Google Plus
    hehehe em cảm ơn bác
     
  14. Steve2018

    Steve2018 Member

    Joined:
    Feb 21, 2018
    Messages:
    37
    Likes Received:
    2
    Bác có ghể chỉ e autoit click trên ứng dung k?
     
  15. soibac

    soibac Member

    Joined:
    Oct 13, 2013
    Messages:
    733
    Likes Received:
    483
    Click thì dùng hàm thôi, mở autoit help ra đầy đủ hàm hết.
     
    Steve2018 likes this.
  16. Steve2018

    Steve2018 Member

    Joined:
    Feb 21, 2018
    Messages:
    37
    Likes Received:
    2
    E dùng mouseclick() thì nó chạy trên web và click chuột dc. Nhưng trên ứng dụng nó chỉ move chứ không click chuột và send() kí tư dc bác. Bác có cách nào k? E dùng cả controlclick cũng k dc. Thanks bác!
     
  17. emyeusss7

    emyeusss7 Trial Mod Staff Member Trader Verified Kindness Member

    Joined:
    Dec 26, 2010
    Messages:
    1,954
    Likes Received:
    1,233
    Insuree Balance:
    500
    Service Details:
    1|emyeusss7|Software, Tools
    Phone Number:
    Call me!
    Facebook:
    Follow me on Facebook
    Skype:
    Chat with me via Skype
    do thằng ứng dụng nó chặn click thôi
    sử dụng hàm _WinAPI_PostMessage or _WinAPI_Mouse_Event or _WinAPI_???? khác, có rất nhiều hàm API hổ trợ việc này
    bạn search google từ khóa "winapi mouse click autoit" rồi test code nhé
     
    Steve2018 likes this.
  18. Steve2018

    Steve2018 Member

    Joined:
    Feb 21, 2018
    Messages:
    37
    Likes Received:
    2
    Cám ơn bác nhiều... để e thử xem
     
  19. Steve2018

    Steve2018 Member

    Joined:
    Feb 21, 2018
    Messages:
    37
    Likes Received:
    2
    em muốn click double chuột trái tại tọa độ (200,50) mà sao nó không chạy,,,, các cao nhân chỉ giáo giúp e với :(((((


    #include <WinAPI.au3>

    #include <Windowsconstants.au3> ; Khai báo các hằng $WM_ ... bằng cách include thư viện



    Const $MK_LBUTTON = 0x1

    Const $MK_MBUTTON = 0x10

    Const $MK_RBUTTON = 0x2 ; Khai báo các giá trị hằng



    Global $Struct = DllStructCreate($tagPoint)

    $hwnd = _WinAPI_WindowFromPoint($Struct) ; Lấy handle destop



    pclick(200,50,'Left Double Click') ; Hàm click double chuột trái tại tọa độ (200,50)



    Func pclick($x=0,$y=0,$button='Left Click')

    $lParam = ($y * 65536) + ($x)

    Switch $button

    Case $button='Left Click'

    _WinAPI_PostMessage($hwnd, $WM_LBUTTONDOWN, $MK_LBUTTON,$lParam)

    _WinAPI_PostMessage($hwnd, $WM_LBUTTONUP, 0,$lParam)

    Case $button='Left Double Click'

    _WinAPI_PostMessage($hwnd, $WM_LBUTTONDOWN, $MK_LBUTTON,$lParam)

    _WinAPI_PostMessage($hwnd, $WM_LBUTTONUP, 0,$lParam)

    _WinAPI_PostMessage($hwnd, $WM_LBUTTONDBLCLK, $MK_LBUTTON,$lParam)

    _WinAPI_PostMessage($hwnd, $WM_LBUTTONUP, 0,$lParam)

    Case $button='Middle Click'

    _WinAPI_PostMessage($hwnd, $WM_MBUTTONDOWN, $MK_MBUTTON,$lParam)

    _WinAPI_PostMessage($hwnd, $WM_MBUTTONUP, 0,$lParam)

    Case $button='Middle Double Click'

    _WinAPI_PostMessage($hwnd, $WM_MBUTTONDOWN, $MK_MBUTTON,$lParam)

    _WinAPI_PostMessage($hwnd, $WM_MBUTTONUP, 0,$lParam)

    _WinAPI_PostMessage($hwnd, $WM_MBUTTONDBLCLK, $MK_MBUTTON,$lParam)

    _WinAPI_PostMessage($hwnd, $WM_MBUTTONUP, 0,$lParam)

    Case $button='Right Click'

    _WinAPI_PostMessage($hwnd, $WM_RBUTTONDOWN, $MK_RBUTTON,$lParam)

    _WinAPI_PostMessage($hwnd, $WM_RBUTTONUP, 0,$lParam)

    Case $button='Right Double Click'

    _WinAPI_PostMessage($hwnd, $WM_RBUTTONDOWN, $MK_RBUTTON,$lParam)

    _WinAPI_PostMessage($hwnd, $WM_RBUTTONUP, 0,$lParam)

    _WinAPI_PostMessage($hwnd, $WM_RBUTTONDBLCLK, $MK_RBUTTON,$lParam)

    _WinAPI_PostMessage($hwnd, $WM_RBUTTONUP, 0,$lParam)

    Case $button='Mouse Move'

    _WinAPI_PostMessage($hwnd, $WM_MOUSEMOVE, 0,$lParam)

    _WinAPI_PostMessage($hwnd, $WM_MOUSEMOVE, 0,$lParam)

    EndSwitch

    EndFunc
     
  20. HVDD

    HVDD Member

    Joined:
    Jun 8, 2015
    Messages:
    30
    Likes Received:
    29
    Facebook:
    Follow me on Facebook
    Skype:
    Chat with me via Skype
    Giờ mới biết diễn đàn cũng có share thông tin IT :D
     

Share This Page