Jump to content

Focus Problem


Recommended Posts

Well... i'm having a problem with focusing the Ryl:PotE Client... www.ryl.net ...heres the script

While 1

    local $pix = PixelSearch(0, 0, 90, 97, 0xEF8E00, 0, 1)

    if UBound($pix) > 0 then
      SoundPlay(@WindowsDir & "\media\Windows XP Battery Critical.wav",1)

    endif
Sleep(1000)
WEnd

Basically (as you can see) I'm searching the minimap for a certain pixel, in this case, a guild enemy. But the problem is, autoit seems to not want to focus on the Ryl Client when its maximized, but when i alt tab out it plays the sound.(example: http://www.rogue-games.net/pic.bmp ; http://www.rogue-games.net/pic2.bmp )

This will not work for me, since i need the sound to be real time (while i'm hunting, killing, etc in game.

Any ideas on how to fix this?

Thanks,

Dark

Link to comment
Share on other sites

  • Moderators

Opt(PixelCoordMode, 0)

While WinExist("Ryl Window Name")
    Sleep(500); or what ever speed you need
    
    If Not Winactive("Ryl Window Name") Then Winactivate("Ryl Window Name")

    Local $pix = PixelSearch(0, 0, 90, 97, 0xEF8E00, 0, 1)

    If Not @error Then; assuming you want it to play sound if found.
      SoundPlay(@WindowsDir & "\media\Windows XP Battery Critical.wav",1)

    endif
Sleep(1000)
WEnd

Edit: Took another 'gander' at it LOL.... 'gander' what a word! :)

Edited by ronsrules

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

You say 1/2 didn't work? What 1/2.. LOL

Opt(PixelCoordMode, 0) ; Makes sure Pixels are searched in Active window rather than your desktop

However you did mention the word "Client", so if you got your PixelSearch Coords from the Client option in AutoInfo Tool then you should do

Opt(PixelCoordMode, 2)

While WinExist("Ryl Window Name") ; This is your Game Window you want to Search

If Not Winactive("Ryl Window Name") Then Winactivate("Ryl Window Name") ; This makes sure that if your Game Window is not active then to activate it so that you can do a proper PixelSearch.

PixelSearch(0, 0, 90, 97, 0xEF8E00, 0, 1) ; can take this out of local mode if your not going to use it other than this one search, so that you can make sure it is not in error. PixelSearch returns your Mouse Coords where it found the correct pixel, so you need to see if it didn't. That's where:

If Not @error Then; The Not says, Ok the Correct Colour was found, now what do you want me to do?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

I'm laughing at myself a bit:

Opt("PixelCoordMode", 1)

Forgot the "" for PixelCoordMode

While WinExists()

Forgot the "s" on the end of Exist

Man!!

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Can you post the exact code your trying to use?

And what you want to do if you find the Pixel colour your looking for?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Opt("PixelCoordMode", 1) 

While 1

    WinExists("Risk Your Life")
    
    
    If Not Winactive("Risk Your Life") Then Winactivate("Risk Your Life")

    Local $pix = PixelSearch(0, 0, 90, 97, 0xEF8E00, 0, 1)

    If Not @error Then
      SoundPlay(@WindowsDir & "\media\Windows XP Battery Critical.wav",1)

    endif
Sleep(1000)
WEnd

a few minor edits to yours, but thats it

Edited by Darkcow
Link to comment
Share on other sites

  • Moderators

Either:

Opt("PixelCoordMode", 1)

While WinExists("Risk Your Life")
   Sleep(1000)
   
   If Not Winactive("Risk Your Life") Then Winactivate("Risk Your Life")
   
   PixelSearch(0, 0, 90, 97, 0xEF8E00, 0, 1)
   
   If Not @error Then
      SoundPlay(@WindowsDir & "\media\Windows XP Battery Critical.wav",1)
   EndIf
  
WEnd

Or

Opt("PixelCoordMode", 1)

While 1
   Sleep(1000)
   
   If WinExists("Risk Your Life") Then
      
      If Not Winactive("Risk Your Life") Then Winactivate("Risk Your Life")
      PixelSearch(0, 0, 90, 97, 0xEF8E00, 0, 1)

      If Not @error Then
         SoundPlay(@WindowsDir & "\media\Windows XP Battery Critical.wav",1)
      EndIf
   EndIf
WEnd

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Anyone else have any solutions to this problem? Or is this something that cannot be fixed?

<{POST_SNAPBACK}>

Well what I gave you should work. Couple of questions?

Q(1) - Are you sure the title "Risk Your Life" is the title of the window you want to search the Pixel for? You can use AutoInfo for exact title.

Q(2) - What does AIM have to do with the script?

Q(3) - Are your Coords Correct? Your searching the Top Left Corner to X-90, Y-97.

Q(4) - You used 0 shade variation, is it possible that the colour may show up as a differnt shade?

But before you answer these, If Answer's 1, 3, 4 are correct, then humor me just one more time and try this below. When I looked at your script earlier, I thought there was alot more to it, but if this is it thus far, try this:

Opt("PixelCoordMode", 1)
Opt("WinTitleMatchMode", 4); <<<< added this

While WinExists("Risk Your Life")
   Sleep(1000)
  
   If Not Winactive("Risk Your Life") Then Winactivate("Risk Your Life")
  
   PixelSearch(0, 0, 90, 97, 0xEF8E00, 0, 1)
  
   If Not @error Then
      SoundPlay(@WindowsDir & "\media\Windows XP Battery Critical.wav",1)
   Else
   ToolTip("Still haven't found that pixel for the coords your looking for", 0, 0); <<< added this for error check
   EndIf
  
WEnd

Edit: Added ToolTip so you can see what's going on a bit.

Edited by ronsrules

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Q(1) - Yes I am sure.

Q(2) - Nothing, i just switch to it because it only takes up a small portion of the screen, and the script finds the pixel after i switch to AIM.

Q(3) - Yes, I'm sure. Read above

Q(4) - I know its the right color. There is nothing else that is the same color, and it never changes colors.

And i tried that script, same result :)

Link to comment
Share on other sites

  • Moderators

Q(1) - Yes I am sure.

Q(2) - Nothing, i just switch to it because it only takes up a small portion of the screen, and the script finds the pixel after i switch to AIM.

Q(3) - Yes, I'm sure. Read above

Q(4) - I know its the right color. There is nothing else that is the same color, and it never changes colors.

And i tried that script, same result :)

<{POST_SNAPBACK}>

Ugh, you keep saying same result.

But if your Coords are correct, and the Pixel Colour is Correct, and The window Title is correct... Then simply it is not finding the color your requesting. I added a tooltip to the above function so you could see for yourself.

Now if you keep going to another window, the sleep function is only a second, so it will fight back and forth with you for focus on the Game window.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Are you saving this screen shot as a .bmp? If not then the colour is not going to be right.

If so, this is the last thing I can think of to help see if you are getting focus.

Opt("PixelCoordMode", 1)
Opt("WinTitleMatchMode", 4); <<<< added this

While WinExists("Risk Your Life")
   Sleep(1000)
   
   If Not Winactive("Risk Your Life") Then Winactivate("Risk Your Life")
   
   ControlGetFocus("Risk Your Life")
   
   If Not @error Then
      PixelSearch(0, 0, 90, 97, 0xEF8E00, 0, 1)
      
      If Not @error Then
         SoundPlay(@WindowsDir & "\media\Windows XP Battery Critical.wav",1)
      Else
         ToolTip("Still haven't found that pixel for the coords your looking for", 0, 0); <<< added this for error check
      EndIf
   Else
      ToolTip("No focus yet, please check the title of the screen, or get the (Class) name out of AutoInfo for more help"); <<< If not in focus
   EndIf
WEnd
Edited by ronsrules

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...