Sign in to follow this  
Followers 0
Nemon

Pixelsearch no go :(

6 posts in this topic

Ok,

I have been lightly using auto it for very basic junk. I can get this to work if just use all mouseclick x,y with some sleep commands. I just wanted to try to use pixelsearch to get it done a little more automatic. The script below will select that correct window, but that's about it. All the tooltips work like they should. Just it does not seem that the pixelsearch works at all. Not sure what I am doing wrong. If you could look it over and offer any advice would be great. The old mouseclick script I used for everything else I did is getting old. Thanks in advance!!

; Declare Variables
$media = 0

; ToolTip displaying function keys
Tooltip("HOME = On/Off find media, F10 = Exit", 0, 0)


; List of command keys
If Not WinActive("MediaMonkey", "") Then WinActivate("MediaMonkey", "")
While WinWaitActive("MediaMonkey", "")
   HotKeySet("{HOME}", "Find media")
   HotKeySet("{F10}", "exitNow")
WEnd

; Click loop
While True
   If $media = 1 Then
      $size = WinGetClientSize("MediaMonkey", "")
      $coord = PixelSearch(0,0, $size[0], $size[1], 0xFECE56)
      ; If PixelSearch finds the pixel color at given coordinates, Then:
      If Not @error Then
         MouseClick("left", $coord[0], $coord[1], 1, 0)
      EndIf
   EndIf
   Sleep(500)
WEnd


; Functions
; On/Off find media():
Func media()
   If $media = 0 Then
      $media = 1
      Tooltip("Auto deleting on command (HOME to disable)", 0, 0)
   Else
      $media = 0
      Tooltip("HOME = On/Off Start deleting, F10 = Exit", 0, 0)
   EndIf
EndFunc

; Exit
Func exitNow()
   Exit
EndFunc

Share this post


Link to post
Share on other sites



Hi and Welcome to the forums!

Wait wait wait. Why are you searching from 0x0 to the windows width and height? What if the window isn't in the upper-left corner? You should fix that.

Oh and what is this supposed to be?

HotKeySet("{HOME}", "Find media")
Functions can't have spaces in them!

And remove that loop, it doesn't make any bloody sense at all.

Have a good day.

;)

Share this post


Link to post
Share on other sites

Hi and Welcome to the forums!

Wait wait wait. Why are you searching from 0x0 to the windows width and height? What if the window isn't in the upper-left corner? You should fix that.

Oh and what is this supposed to be?

HotKeySet("{HOME}", "Find media")
Functions can't have spaces in them!

And remove that loop, it doesn't make any bloody sense at all.

Have a good day.

;)

Fixed the space, not sure why I had that in there. As for the 0,0 search to the windows height, in the $size = WinGetClientSize("MediaMonkey", "")

$coord = PixelSearch(0,0, $size[0], $size[1], 0xFECE56) I thought that it will automatically grab the entire window called Media Monkey and search it. I was kind of cloudy on getting the correct pixels of the screens.

Share this post


Link to post
Share on other sites

using WinGetPos("MediaMonkey") will give you the windows current x,y coordinates (to use as your pixelsearch start) and the window size (for your search end)


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

Ok I changed it up a bit, took out the loop, put in cords to search. When execute the program the tool tip pops up, it make Media Monky the active window....and that is about it. It just sits there does not move to a color at all. Pixelsearch is kind of hard lol.

; ToolTip displaying function keys
Tooltip("F10 = Exit", 0, 0)

; List of command keys
If Not WinActive("MedaMonkey", "") Then WinActivate("MediaMonkey", "")
   HotKeySet("{F10}", "exitNow")

      $coord = PixelSearch(597, 154, 806, 628, 0x9C885C)
      ; If PixelSearch finds the pixel color at given coordinates, Then:
      If Not @error Then
         MouseClick("left", $coord[0], $coord[1], 1, 0)
      EndIf


; Exit
Func exitNow()
   Exit
EndFunc

Share this post


Link to post
Share on other sites

; ToolTip displaying function keys
Tooltip("F10 = Exit", 0, 0)

; List of command keys
If Not WinActive("MediaMonkey", "") Then WinActivate("MediaMonkey", "")
$medmonkey=WinGetPos("MediaMonkey")
   HotKeySet("{F10}", "exitNow")

      $coord = PixelSearch($medmonkey[0], $medmonkey[1], $medmonkey[0]+$medmonkey[3], $medmonkey[1]+$medmonkey[4], 0x9C885C)
      ; If PixelSearch finds the pixel color at given coordinates, Then:
      If Not @error Then
         MouseClick("left", $coord[0], $coord[1], 1, 0)
      EndIf


; Exit
Func exitNow()
   Exit
EndFunc

No matter where the window is, it will search there and the entire area of the window.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0