Sign in to follow this  
Followers 0
SmOke_N

WinExists / Select Case / If Elseif

9 posts in this topic

#1 ·  Posted (edited)

I have a few questions before I get to my errors.

1. Does anyone face a pixelgetcolor problem with Windows XP vs. Windows 98 / 2000 / 2003?

2. I've tried to find a medium with PixelGetColor, XP view and XP client I've used WinGetPos [2] and [3]. Works well with xp view or client, but....

3. How does everyone/anyone cope with windows 98 (and above)?

Last (4): I have made a program that works for the specified actions (just simple mouseclicks), via xp view or classic view. But, If I exit the window before stoppin the script I get an AutoIt error, that Local $XC = $Pos[2] - $XpX (Local $XC = ^ ERROR) Basically saying that $Pos[2] or $window does not exist.

So is there a way to make sure NO errors show ever or what is wrong with my script?

; Included functions:  $primary and  _MouseClickPlus

Func _myfunc()
   
   While WinExists($window); error report has something to do with WinGetPos
      Sleep(500)
      Select
         Case WinExists($window)
            Local $XpX = 800
            Local $XpY = 580
            Local $Pos = WinGetPos($window)
            Local $XC = $Pos[2] - $XpX
            Local $YC = $Pos[3] - $XpY
            Local  $Loop = (Random(1, 10, 1)); end here
      Case Else
            Exit
      EndSelect
      
      Select; The error is not here
         Case $Loop <= 3
            $MiS = $M1 * 1000
            $MaS = $Mx1 * 1000
         Case $Loop = 4 Or $Loop = 5
            $MiS = $M2 * 1000
            $MaS = $Mx2 * 1000
         Case $Loop = 6 Or $Loop = 7
            $MiS = $M3 * 1000
            $MaS = $Mx3 * 1000
         Case $Loop = 8 Or $Loop = 9
            $MiS = $M4 * 1000
            $MaS = $Mx4 * 1000
         Case Else
            $MiS = $M5 * 1000
            $MaS = $Mx5 * 1000
      EndSelect
      
      $Monster1 = ControlGetText("Game Mode", "Mons1", 115); there error is not here
      If $Monster1 = "Mons1" Then
         Sleep(Random($MiS, $MaS))
         WinActivate($window)
         If (PixelGetColor(633 + $XC, 543 + $YC) == 0x7F3508)  Then
         _MouseClickPlus( $window, $primary, Random(425 + $XC, 714 + $XC, 1), Random(728 + $YC, 555 + $YC, 1), 1 )
         EndIf
      EndIf
      
      $Monster2 = ControlGetText("Game Mode", "Mons2", 115); there error is not here
      If $Monster2 = "Mons2" Then
         Sleep(Random($MiS, $MaS))
         If (PixelGetColor(633 + $XC, 543 + $YC) == 0x7F3508)  Then
         _MouseClickPlus( $window, $primary, Random(753 + $XC, 642 + $XC, 1), Random(728 + $YC, 555 + $YC, 1), 1 )
         EndIf
      EndIf
   WEnd
EndFunc ;==> _myfunc()

Hope I explained my question right...

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.

Share this post


Link to post
Share on other sites



Suggest putting an IsArray($Pos) check in right after the WinGetPos call, if it's not an array then the window no longer exists

As to other than XP and Classic view, themes seem to be a problem with a few controls and thier colors.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Thanks gafrost... but a quick question, Can I use just the IsArray($Pos) or should I use an If statement with it? I'll test it, but want to ask anyway for yours or anyones thoughts on it.

Also, I got my coords and pixel colors from XP view, did the WinGetPos subtraction and it works well with XP Classic with the themes, but not on any other windows system.

I guess it was a plea for help if anyone had figured out how to get the correct coords with WinGetPos and or if the Pixel Colours were different in the other window systems. From what I am reading from your post, the colour of the pixels are different, but I'd like a confirmation if that makes sense.

Thanks again,


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.

Share this post


Link to post
Share on other sites

Yes Thanks Gary, I figured that out:

Local $XpX = 800
      Local $XpY = 580
      Local $Pos = WinGetPos($window)
      If IsArray($Pos) Then
         Local $XC = $Pos[2] - $XpX
         Local $YC = $Pos[3] - $XpY
      Else
         Exit
      EndIf

Works well thank you again.... Any confimation on PixelColor change from the different windows?


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.

Share this post


Link to post
Share on other sites

I can't help you there at the moment, down to just XP machines, working on my 2000 pro server, drive on the fritz.

Gary


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

[...]

1.  Does anyone face a pixelgetcolor problem with Windows XP vs. Windows 98 / 2000 / 2003?

[...]

I have no issues with PixelGetColor() on Win2003 server.

Also for my game scripts i've done the following: (may or may not help you)

$PID=ProcessExists("game.exe")

If $PID Then

WinActivate("game-title", "")

EndIf

While ($PID)

....

WEnd

Edited by Ster

Share this post


Link to post
Share on other sites

I think there was a misunderstanding... I use PixelCoordMode / MouseCoordMode etc... Nothing is wrong with my script when it comes to the Pixel Colors.

I compiled my script that was made on Windows XP. I used the WinGetPos thinking that it would help find the correct pixels and coords for the different window types. It seems to only work on XP View and XP Classic, but not in the other Windows (98/2000/2003).

I don't have access to those 3 systems to test. So I was wondering how someone found the PixelColor they were looking for in Windows XP and then able to find it in the same coords less window size.

Or if the Pixel Colors are even the same in the other window versions.


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.

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