Jump to content
Sign in to follow this  
Driveskull

Problem with pixel detection and selling script

Recommended Posts

Driveskull
Hello all can anyone help me with this script ?  
It has alot of problems , after selling 1 thing its resets , but in mind i had for it to sell everything and then take all from my auctions . If you want to look into it i will be very gratefull .
Code:
#include-once
; ------------------------------------------------------------------------------
;
; AutoIt Version: 3.0
; Language:       English
; Description:    Functions that assist with Image Search
;                 Require that the ImageSearchDLL.dll be loadable
;
; ------------------------------------------------------------------------------
 
;===============================================================================
;
; 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
 
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)
 
; 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
 
;===============================================================================
;
; 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
 
;===============================================================================
;
; 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
Mine image search 
and now the sell script
#AutoIt3Wrapper_usex64=n
#include <WinAPI.au3>
#include <ImageSearch.au3>
 
;============================================================================================================================;
;Global Settings for the pixelscripts                                                                                        ;
;============================================================================================================================;
 
;They key pressed for ANTI-AFK.
Global $ANTI_AFK_KEY = "w"
 
;The time in Minutes how long to wait before pressing an ANTI-AFK key.
Global $ANTI_AFK_SLEEP_MINUTES = "5"
 
;The time to wait between 2 fast actions aka. your average lag.
Global $LAG_AVG = 400
 
;Set this to "True" if you want your Script to undercut by 1c while selling Items
Global $SELL_ITEM_DO_UNDERCUT = True
 
 
;============================================================================================================================;
;Dont expect support if you change anything below this line                                                                  ;
;============================================================================================================================;
 
Global $WIN_TITLE = "Guild Wars 2"
Global $RES_X = 1280
Global $RES_Y = 960
Global $OLD_WINDOW_TITLE = ""
Global $SELL_ITEM_UNDERCUT_X_DEVASTATION = -20
Global $SELL_ITEM_X_DEVASTATION = 60
Global $SELL_ITEM_Y_DEVASTATION = -60
Global $SELL_ITEM_WAIT_TIME = 5000
Global $HISTORY_DROPDOWN_X_DEVASTATION = 10
Global $HISTORY_DROPDOWN_Y_DEVASTATION = 50
 
Func killSwitch()
   Exit(0)
EndFunc
 
HotKeySet("{F10}", "killSwitch") 
 
Func GameToForeground()
   $OLD_WINDOW_TITLE = WinGetTitle("")
   WinActivate("Guild Wars 2")
   Sleep($LAG_AVG * 5)
EndFunc
 
Func GameToBackground()
   WinActivate($OLD_WINDOW_TITLE)
   Sleep($LAG_AVG)
EndFunc
 
Func resize()
    WinMove($WIN_TITLE, "",0 ,0 , $RES_X, $RES_Y)
 EndFunc
  
Func antiAFK()
   GameToForeground()
   Sleep($LAG_AVG * 5)
   Send($ANTI_AFK_KEY)
   GameToBackground()
EndFunc
 
Func getImageDir()
   $s = @ScriptDir
   Return $s & "\Images\"
EndFunc
 
Func findAndClick($imageName)
   gameToForeground()
   Local $x
   Local $y
   $result = _ImageSearch( getImageDir() & $imageName,1,$x,$y,20)
   if $result == 1 Then
 MouseMove($x, $y)
 Sleep($LAG_AVG)
 MouseClick("left")
 Return True
   EndIf
   Return False
EndFunc
 
Func openAuctionHouse() 
   $result = findAndClick("BLACK_LION.PNG")
   if ($result == False) then
 Send("o")
   EndIf   
EndFunc
 
Func openSalesTab()
   openAuctionHouse()
   findAndClick("SALES.PNG")
   findAndClick("SALES_ACTIVE.PNG")
EndFunc
 
Func sellItems()
   While True
 openSalesTab()
 $x =  _WinAPI_GetMousePosX()
 $x = $x + $SELL_ITEM_X_DEVASTATION
 $y = _WinAPI_GetMousePosY()
 $y = $y + $SELL_ITEM_Y_DEVASTATION
 MouseMove($x, $y)
 Sleep($LAG_AVG)
 MouseClick("left")
 Sleep($LAG_AVG * 3)
 $res = findAndClick("SELL_MAXIMUM.PNG")
 $res = findAndClick("MATCH_LOWEST_SELLER.PNG")
 if ($SELL_ITEM_DO_UNDERCUT == True) Then
$res = findAndClick("COPPER.PNG")
$xUndercut = _WinAPI_GetMousePosX() + $SELL_ITEM_UNDERCUT_X_DEVASTATION
MouseMove($xUndercut, _WinAPI_GetMousePosY())
MouseClick("left")
Sleep($LAG_AVG)
Send("{DOWN}") 
 EndIf
 $res = findAndClick("SELL.PNG")
 if $res == False Then
$return = sellItems()
if ($return == True) Then
sellItems()
Else
Return False
EndIf 
 EndIf
 Sleep($SELL_ITEM_WAIT_TIME)
 MouseClick("left")
   WEnd
EndFunc
 
 
Func openHistoryTab()
   
   openAuctionHouse()
   findAndClick("HISTORY_ACTIVE.PNG")
   Sleep($LAG_AVG)
   findAndClick("HISTORY.PNG")
EndFunc
 
Func historyDropdownProceed()
   openHistoryTab()
   Sleep($LAG_AVG)
   findAndClick("HISTORY_DROPDOWN_ACTIVE.PNG")
   findAndClick("HISTORY_DROPDOWN.PNG")
   Sleep($LAG_AVG)
   $x =  _WinAPI_GetMousePosX()
   $x = $x + $HISTORY_DROPDOWN_X_DEVASTATION
   $y = _WinAPI_GetMousePosY()
   $y = $y + $HISTORY_DROPDOWN_Y_DEVASTATION
   MouseMove($x, $y)
   Sleep($LAG_AVG)
   MouseClick("left")
EndFunc
 
Func cancelOrders()
   historyDropdownProceed()
   Sleep($LAG_AVG)
   $res = findAndClick("REMOVE.PNG")
   $cancel = findAndClick("NO_RESULTS_FOUND.PNG")
   while ($cancel == False)
 $cancel = findAndClick("NO_RESULTS_FOUND.PNG")
 MouseClick("left")
 Sleep(100)
   WEnd
EndFunc

Share this post


Link to post
Share on other sites
FireFox

*sigh* pixel detection + new member = locked.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Driveskull

O.o Why ? 
So first i need to make some dump posts to not be new member and then after long time ask directly what i did wrong in MY OWN SCRIPT ? 

Share this post


Link to post
Share on other sites
Melba23

Driveskull,

Welcome to the AutoIt forum. :)

Unfortunately you appear to have missed the Forum rules on your way in. Please read them now (there is also a link at bottom right of each page) - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked. :naughty:

See you soon with a legitimate question I hope. :)

M23

Edited by Melba23
Typo

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×