bild erkennen

  • kann man autoit sagen, dass er auf dem bildschrim (vllt auch in einem bestimmten bereich) ein bild suchen soll?
    in meinem fall soll er (anhang) bild suchen und ein doppelklick drauf machen... ist des möglich?^^
    falls es euch interessiert, das bild ist unten in der taskleiste in dem bereich wo die uhr steht

    2 Mal editiert, zuletzt von chriser (21. Juli 2008 um 21:13)

  • so da script:

    Spoiler anzeigen
    [autoit]


    #include <ButtonConstants.au3> ;gui
    #include <EditConstants.au3> ;$ES_PASSWORD
    #include <GUIConstantsEx.au3> ;gui
    #include <StaticConstants.au3> ;gui
    #include <String.au3> ;_StringEncrypt
    #include <ImageSearch1.au3> ;für bot finden

    [/autoit] [autoit][/autoit] [autoit]

    $x1=0
    $y1=0
    $result = _ImageSearch("bild.bmp",1,$x1,$y1,0)
    HotKeySet("{F9}", "_start") ;Hot key für noch mal starten und prog beenden
    HotKeySet("{ESC}","_exit")
    If FileExists(@scriptdir & "\setting.ini") = 0 Then ;wenn setting.ini nicht da, dann
    MsgBox(0,"Sro Login Bot", "Please fill in the settings") ;MSG box und gui:
    #Region ### START Koda GUI section ### Form=
    $settings = GUICreate("Sro Login Bot", 307, 217, 195, 127)
    $Input1 = GUICtrlCreateInput("", 128, 16, 121, 21)
    $Label1 = GUICtrlCreateLabel("Username", 8, 16, 100, 17)
    $Label2 = GUICtrlCreateLabel("Password", 8, 56, 108, 17)
    $Input2 = GUICtrlCreateInput("", 128, 56, 121, 21,$ES_PASSWORD)
    $Button1 = GUICtrlCreateButton("Start", 24, 184, 75, 25, 0)
    $Button2 = GUICtrlCreateButton("Abbrchen", 128, 184, 75, 25, 0)
    $Radio1 = GUICtrlCreateRadio("mit Loader", 8, 128, 81, 17)
    $Radio2 = GUICtrlCreateRadio("ohne Loader", 96, 128, 89, 17)
    $Label3 = GUICtrlCreateLabel("Pfad", 9, 96, 108, 17)
    $Input3 = GUICtrlCreateInput("nur Ordner!", 128, 96, 121, 21)
    $Radio3 = GUICtrlCreateRadio("mit Bot", 192, 128, 89, 17)
    $Label4 = GUICtrlCreateLabel("Bot Pfad", 8, 152, 108, 17)
    $Input4 = GUICtrlCreateInput("", 128, 152, 121, 21)
    GUISetState(@SW_SHOW)
    GUISetState(@SW_SHOW,$Settings) ;GUI ende
    $loginname = GUICtrlRead($Input1);loginname
    $password = GUICtrlRead($Input2);passwort
    #EndRegion ### END Koda GUI section ###
    Else
    $loginname = IniRead(@ScriptDir & "\setting.ini","Login Details","User","") ;liest dateien aus setting.ini und setzt die variablen
    $password = IniRead(@ScriptDir & "\setting.ini","Login Details","Pass","") ;auf die keys in der ini datei
    $pfad = IniRead(@ScriptDir & "\setting.ini","Login Details","Path","")
    $pfad2 = IniRead(@ScriptDir & "\setting.ini","Login Details","Path2","")
    _decrypt()
    #Region ### START Koda GUI section ### Form=
    $settings = GUICreate("Sro Login Bot", 307, 217, 195, 127)
    $Input1 = GUICtrlCreateInput($loginname, 128, 16, 121, 21)
    $Label1 = GUICtrlCreateLabel("Username", 8, 16, 100, 17)
    $Label2 = GUICtrlCreateLabel("Password", 8, 56, 108, 17)
    $Input2 = GUICtrlCreateInput($password, 128, 56, 121, 21,$ES_PASSWORD)
    $Button1 = GUICtrlCreateButton("Start", 24, 184, 75, 25, 0)
    $Button2 = GUICtrlCreateButton("Abbrchen", 128, 184, 75, 25, 0)
    $Radio1 = GUICtrlCreateRadio("mit Loader", 8, 128, 81, 17)
    $Radio2 = GUICtrlCreateRadio("ohne Loader", 96, 128, 89, 17)
    $Label3 = GUICtrlCreateLabel("Pfad", 9, 96, 108, 17)
    $Input3 = GUICtrlCreateInput($pfad, 128, 96, 121, 21)
    $Radio3 = GUICtrlCreateRadio("mit Bot", 192, 128, 89, 17)
    $Label4 = GUICtrlCreateLabel("Bot Pfad", 8, 152, 108, 17)
    $Input4 = GUICtrlCreateInput($pfad2, 128, 152, 121, 21)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW) ;GUI ende
    #EndRegion ### END Koda GUI section ###

    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $farbe = 0x000000 ; farbe für PixelGetColor

    [/autoit] [autoit][/autoit] [autoit]

    While 1 ;GUI mode, erkennt was gedrückt wurde
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $Button1
    _start()
    Case $Button2
    _Exit()
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd ;Ende gui mode

    [/autoit] [autoit][/autoit] [autoit]

    #Region ####### FUNKTIONEN #######

    [/autoit] [autoit][/autoit] [autoit]

    Func _start() ;func start
    $pfad2 = GUICtrlRead($Input4);pfad vom bot ordner
    $pfad = GUICtrlRead($Input3);pfad vom silkroad ordner
    $loginname = GUICtrlRead($Input1);loginname
    $password = GUICtrlRead($Input2);passwort
    $password = _StringEncrypt(1,$password,"lolig");verschlüsselt das pw
    IniWrite(@ScriptDir & "\setting.ini","Login Details","User",$loginname) ;schreibt die daten in ini datei
    IniWrite(@ScriptDir & "\setting.ini","Login Details","Pass",$password)
    IniWrite(@ScriptDir & "\setting.ini","login Details","Path",$pfad)
    IniWrite(@ScriptDir & "\setting.ini","login Details","Path2",$pfad2)
    _decrypt()
    if BitAND(GUICtrlRead($Radio1), $GUI_CHECKED) then ; wenn Loader angeklickt wurde dann
    Run($pfad & "\Loader.exe") ;Loader starten
    elseif BitAND(GUICtrlRead($Radio3), $GUI_CHECKED) then ; wenn bot angeklickt wurde dann
    run($pfad2 & "\srobot.exe")
    _BotSearch()
    Else ;sonst
    Run($pfad & "\sro_client.exe") ;sro client starten
    EndIf
    GUISetState(@SW_HIDE,$Settings)

    [/autoit] [autoit][/autoit] [autoit]

    while 1
    if $farbe = PixelGetColor(233, 719) Then ;wenn ein bestimmter pixel $farbe wird dann
    sleep(3000) ; kurz warten
    MouseClick("left",551,429,2,2) ;login fenster sichtbar machen und draufklicken
    send($loginname) ;loginname schreiben
    MouseClick("left",544,460,1,2);auf pw klicken
    send($password) ;passwort schreiben
    MouseClick("left", 462,564,1,2) ;auf login klicken
    ExitLoop ;while-schleife verlassen
    EndIf
    WEnd

    EndFunc


    Func _exit() ;func exit
    Exit ;beendet das programm
    Endfunc

    Func _decrypt() ;func _decrypt
    $password = _StringEncrypt(0,$password,"lolig") ; entschlüsslet das pw wieder, zum eingeben in sro_client
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _BotSearch()
    if $result=1 then
    MouseClick("left",$x1,$y1,2,1)
    endif
    endfunc

    [/autoit] [autoit][/autoit] [autoit]

    #EndRegion ####### FUNKTIONEN ########

    [/autoit]


    und da is die func imagesearch:

    Spoiler anzeigen
    [autoit]

    #include-once
    ; ------------------------------------------------------------------------------
    ;
    ; AutoIt Version: 3.0
    ; Language: English
    ; Description: Functions that assist with Image Search
    ; Require that the ImageSearchDLL.dll be loadable
    ;
    ; ------------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Description: Find the position of an image on the desktop
    ; Syntax: _ImageSearchArea, _ImageSearch
    ; Parameter(s):
    ; $findImage - the image to locate on the desktop
    ; $tolerance - 0 for no tolerance (0-255). Needed when colors of
    ; image differ from desktop. e.g GIF
    ; $resultPosition - Set where the returned x,y location of the image is.
    ; 1 for centre of image, 0 for top left of image
    ; $x $y - Return the x and y location of the image
    ;
    ; Return Value(s): On Success - Returns 1
    ; On Failure - Returns 0
    ;
    ; Note: Use _ImageSearch to search the entire desktop, _ImageSearchArea to specify
    ; a desktop region to search
    ;
    ;===============================================================================
    Func _ImageSearch($findImage,$resultPosition,ByRef $x, ByRef $y,$tolerance)
    return _ImageSearchArea($findImage,$resultPosition,0,0,@DesktopWidth,@DesktopHeight,$x,$y,$tolerance)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _ImageSearchArea($findImage,$resultPosition,$x1,$y1,$right,$bottom,ByRef $x, ByRef $y, $tolerance)
    ;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom)
    if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage
    $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage)

    [/autoit] [autoit][/autoit] [autoit]

    ; If error exit
    if $result[0]="0" then return 0

    ; Otherwise get the x,y location of the match and the size of the image to
    ; compute the centre of search
    $array = StringSplit($result[0],"|")

    $x=Int(Number($array[2]))
    $y=Int(Number($array[3]))
    if $resultPosition=1 then
    $x=$x + Int(Number($array[4])/2)
    $y=$y + Int(Number($array[5])/2)
    endif
    return 1
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Description: Wait for a specified number of seconds for an image to appear
    ;
    ; Syntax: _WaitForImageSearch, _WaitForImagesSearch
    ; Parameter(s):
    ; $waitSecs - seconds to try and find the image
    ; $findImage - the image to locate on the desktop
    ; $tolerance - 0 for no tolerance (0-255). Needed when colors of
    ; image differ from desktop. e.g GIF
    ; $resultPosition - Set where the returned x,y location of the image is.
    ; 1 for centre of image, 0 for top left of image
    ; $x $y - Return the x and y location of the image
    ;
    ; Return Value(s): On Success - Returns 1
    ; On Failure - Returns 0
    ;
    ;
    ;===============================================================================
    Func _WaitForImageSearch($findImage,$waitSecs,$resultPosition,ByRef $x, ByRef $y,$tolerance)
    $waitSecs = $waitSecs * 1000
    $startTime=TimerInit()
    While TimerDiff($startTime) < $waitSecs
    sleep(100)
    $result=_ImageSearch($findImage,$resultPosition,$x, $y,$tolerance)
    if $result > 0 Then
    return 1
    EndIf
    WEnd
    return 0
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Description: Wait for a specified number of seconds for any of a set of
    ; images to appear
    ;
    ; Syntax: _WaitForImagesSearch
    ; Parameter(s):
    ; $waitSecs - seconds to try and find the image
    ; $findImage - the ARRAY of images to locate on the desktop
    ; - ARRAY[0] is set to the number of images to loop through
    ; ARRAY[1] is the first image
    ; $tolerance - 0 for no tolerance (0-255). Needed when colors of
    ; image differ from desktop. e.g GIF
    ; $resultPosition - Set where the returned x,y location of the image is.
    ; 1 for centre of image, 0 for top left of image
    ; $x $y - Return the x and y location of the image
    ;
    ; Return Value(s): On Success - Returns the index of the successful find
    ; On Failure - Returns 0
    ;
    ;
    ;===============================================================================
    Func _WaitForImagesSearch($findImage,$waitSecs,$resultPosition,ByRef $x, ByRef $y,$tolerance)
    $waitSecs = $waitSecs * 1000
    $startTime=TimerInit()
    While TimerDiff($startTime) < $waitSecs
    for $i = 1 to $findImage[0]
    sleep(100)
    $result=_ImageSearch($findImage[$i],$resultPosition,$x, $y,$tolerance)
    if $result > 0 Then
    return $i
    EndIf
    Next
    WEnd
    return 0
    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit]


    so muss jez ins bett, aba postet die lösung bitte, ich schaus mir morgen nach der schule an^^

  • ich glaube der fehler kommt wenn das bild nicht gefunden wird.
    dann gibt imagesearch -1 oder so aus was ja kein array ist.

  • achso vergessen zu ändern, ich hab bei dem imagesearch script die zeile 40 umgeändert in

    [autoit]

    if $result(ohne das [0])="0" then return 0

    [/autoit]


    udn die datei hab ich dann imageserch1 genannt, deswegen.... bei der zeile kommt bei mir nämlich ein fehler

    edit: wäre möglich ich probiers mal aus mit nem genauerem pic
    edit2:ne, ändert nix....
    edit3:kann man autoit auch sagen dass er ein symbol in der taskleiste anklicken soll auch ohne image search? weil er soll bei mir 2 mal auf dieses symbol klicken, das in der taskleiste bei der uhr ist, egal wo es sich dort befindet.

    2 Mal editiert, zuletzt von chriser (22. Juli 2008 um 13:55)

  • Hi,
    mit ImageSearch klappt es 100% ich weis nur ned was du für Probleme hast??

    Wann kommt der Fehler?
    Und warum?
    Was soll er überhaupt machen?

    Du erwartest von uns das wir dir irgendwie helfen, aber ich hab keine Ahnung was du willst...

  • also, bei mir soll er ein bild in der taskleiste finden, wo er 2 mal draufklicken soll... bloß bekomm ich wenn in dem script die variable

    [autoit]

    $result = _ImageSearch("bild.bmp",1,$x1,$y1,0)

    [/autoit]

    benütze, kommt in dem script ImageSearch in zeile 40

    [autoit]

    if $result[0]=0 then return 0

    [/autoit]

    dieser fehler:

    Code
    I:\AutoIt3\Include\ImageSearch.au3 (40) : ==> Subscript used with non-Array variable.:
    if $result[0]=0 then return 0
    if $result^ ERROR
    >Exit code: 1	Time: 0.504


    tja, da bin ich jez ratlos, ich habs mit der beta und der stable versucht, geht beides nicht

  • Hi,
    wahrscheinlich hast du da irgendwas rumgeändert.

    Die Originale Zeile 40 sihet nämlich so aus:

    [autoit]

    if $result[0]="0" then return 0

    [/autoit]

    Laad dir auf der Seite einfach nur die Datei herunter, entpacke sie und kopiere die ImageSearch.au3 in das Include-Verzeichnis. Nix umbenennen, und auch nix rumbastel. Dann benutz einfach noch die Befehle, dann klappt das schon ...
    /Edit: und kopier die ImageSearch.dll noch in System32

  • ok mach ich mal^^ =)=)=)=)
    edit: FUUNZT!!!!!! lag ws daran dass ich die imagedll nich in sys32 hatte =) hab konto mit engeschränken rechten... und hate keine lust benutzer zu wechseln -> autoit

    [autoit]

    #RequireAdmin
    FileMove(=))

    [/autoit]


    edit2: wenn der jez noch des bild finden würde wärs toll^^

    2 Mal editiert, zuletzt von chriser (22. Juli 2008 um 16:33)