Jump to content

Wait isn't this waiting?


Recommended Posts

Why doesn't this work? code right below and a description of what I am seeing below that.

If PixelGetColor(569,260) = 0x008100 then

Send("4")

while PixelGetColor(836,733) = 0x110E11

Sleep(100)

WEnd

Endif

If PixelGetColor(569,260) = 0x008100 then

Send("2")

while PixelGetColor(836,733) = 0x110E11

Sleep(100)

WEnd

Endif

Sending the number keys places a temporary box down on the screen at 836,733 that has the color 0x110E11. Why isn't the script pausing at the sleep until it not longer equals 0x110E11?

Right now if I run the script the computer processes the keypress 4 and then a minimal time lalater it processes the keypress 2. The box that stays up is variable time sometimes as much as 5 minutes sometimes as little as 30 seconds depending on the job running. This is why I went with a small wait and while in it figuring that it will cycle through sleeps until the color changes when the box disappears.

I have the same thing earlier -

while PixelGetColor(570,247) <> 0xD30000

send("{TAB}")

Sleep(100)

WEnd

that does cycle through the tab buttons until it gets the color it should but its not nested in an If/then. Can the problem be rooted in the fact I have the whiles nested in the If/Then? If not how can I circumvent this?

Ultimately I want a keypress then to wait a variable timeframe until the box disappears to then do another keypress and another variable wait and it will continue this way for about 20 times or so.

Link to comment
Share on other sites

Try this:

While 1

If PixelGetColor(836,733)=0x110E11 & PixelGetColor(569,260)=0x008100 then

Send("4")

Endif

WEnd

While 1

If PixelGetColor(836,733)=0x110E11 & PixelGetColor(569,260)=0x008100 then

Send("2")

Endif

Wend

Are you trying to make a window active? You can use WinActivate for that.

Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

No its a window within the window that I am using this is why I am using pixelgetcolor if I had something as simple as another window opening I could actually just check against the processes running or something much easier.

When I do what you suggested it does not work it just tries to cycle through the first number over and over again without going along to the next number

E.G.

While 1

If PixelGetColor(836,733)=0x110E11 & PixelGetColor(569,260)=0x008100 then

Send("4")

Endif

WEnd

While 1

If PixelGetColor(836,733)=0x110E11 & PixelGetColor(569,260)=0x008100 then

Send("2")

Endif

Wend

results in 444444444444 not in 4 wait 2

Edited by StumpedTechy
Link to comment
Share on other sites

Oh and BTW I did try this -

If PixelGetColor(836,733)<>0x110E11 & PixelGetColor(569,260)=0x008100 then

because I did need it to do this after the box has disappeared if I do PixelGetColor(836,733)=0x110E11 it will try and hit this while its got the window up no?

Link to comment
Share on other sites

I am having a hard time understanding what you want the program to do. If you want the program to cycle through the 2 numbers, 4 and 2, and then 4 and 2 again and again for say 20 times then I would do something like:

$x = 0

Func Cycles()

While 1

If PixelGetColor(836,733)=0x110E11 & PixelGetColor(569,260)=0x008100 then

Send("4")

Sleep(100)

EndIf

If PixelGetColor(836,733)=0x110E11 & PixelGetColor(569,260)=0x008100 then

Send("2")

Sleep(100)

$x = ++1

EndIf

If $x < 20 Then ; sets the script to cycle 19 times

$Cycles()

Endif

Wend

EndFunc

Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

Maybe the whole script will help out with what I am doing -

#region --- ScriptWriter generated code Start ---

Opt("WinWaitDelay",100)

Opt("WinTitleMatchMode",4)

Opt("WinDetectHiddenText",1)

Opt("MouseCoordMode",0)

WinWait("JobMon","")

If Not WinActive("JobMon","") Then WinActivate("JobMon","")

WinWaitActive("JobMon","")

While 1=1

;keep pressing tab until the job runs

while PixelGetColor(570,247) <> 0xD30000

send("{TAB}")

Sleep(100)

WEnd

;wait to do anything until status changes - if it does not call Helpdesk for them to restart job.

while PixelGetColor(423,793) = 0xFF1A1A

Sleep(100)

WEnd

;Once status changes send the corresponding keys necessarry to manipulate file.

If PixelGetColor(570,247) = 0xD30000 then

Send("1")

Sleep(300000)

Endif

If PixelGetColor(569,260) = 0x008100 then

Send("2")

Sleep(300000)

Endif

If PixelGetColor(569,260) = 0x008100 then

Send("3")

Sleep(300000)

Endif

If PixelGetColor(569,260) = 0x008100 then

Send("4")

Sleep(300000)

Endif

If PixelGetColor(569,260) = 0x008100 then

Send("2")

Sleep(300000)

Endif

If PixelGetColor(569,260) = 0x008100 then

Send("2")

Sleep(300000)

Endif

If PixelGetColor(569,260) = 0x008100 then

Send("5")

Sleep(30000)

Endif

If PixelGetColor(569,260) = 0x008100 then

Send("4")

Sleep(30000)

Endif

If PixelGetColor(569,260) = 0x008100 then

Send("2")

Sleep(30000)

Endif

If PixelGetColor(569,260) = 0x008100 then

Send("2")

Sleep(30000)

Endif

If PixelGetColor(569,260) = 0x008100 then

Send("5")

Sleep(30000)

Endif

If PixelGetColor(569,260) = 0x008100 then

Send("4")

Sleep(30000)

Endif

If PixelGetColor(569,260) = 0x008100 then

Send("2")

Sleep(3000)

Endif

If PixelGetColor(569,260) = 0x008100 then

Send("2")

Sleep(30000)

Endif

;verify status changes successfully

While PixelGetColor(523,259) <> 0x00D400

Sleep(100)

WEnd

;verify next job is ready to run

While PixelGetColor(522,269) <> 0x000097

Sleep(100)

WEnd

;repeat for next job

WEnd

As you can see I took the max wait time we knew about and placed it between each if statement the problem with this is 1) some of the waits aren't nearly that long. 2) with a hardcoded number if it has any kind of window freezeup over this "max" I put in there it will puke and not work. 3)We have to have the pixel search because some jobs finish after the 7th - 8th line down (say press button 1 then 2, then 3, then 4, then 2, then 2, then 5 but not need to press any more). But in the above script all of the PixelGetColor works and does as it should.

When I take the

While 1

If PixelGetColor(836,733)=0x110E11 & PixelGetColor(569,260)=0x008100 then

Send("2")

Endif

Wend

While 1

If PixelGetColor(836,733)=0x110E11 & PixelGetColor(569,260)=0x008100 then

Send("3")

Endif

Wend

or

While 1

If PixelGetColor(836,733)<>0x110E11 & PixelGetColor(569,260)=0x008100 then

Send("2")

Endif

Wend

While 1

If PixelGetColor(836,733)<>0x110E11 & PixelGetColor(569,260)=0x008100 then

Send("3")

Endif

Wend

or

while PixelGetColor(836,733)<>0x110E11 and PixelGetColor(569,260) = 0x008100

Send("2")

Sleep(100)

WEnd

while PixelGetColor(836,733)<>0x110E11 and PixelGetColor(569,260) = 0x008100

Send("3")

Sleep(100)

WEnd

it will send the first number 1 (since that is not modified because there never is a window for the first processing) but then after that it will keep trying 2 and not go to 3. Its almost like this script does not like 2 PixelGetColors in one line can that be a problem? As you can see the cycle is more than just 2 numbers and has been known to change so I need something in script form easily modifiable by a non scripter.

Edited by StumpedTechy
Link to comment
Share on other sites

No its a window within the window that I am using this is why I am using pixelgetcolor if I had something as simple as another window opening I could actually just check against the processes running or something much easier.

Maybe the whole script will help out with what I am doing -

#region --- ScriptWriter generated code Start ---

Opt("WinWaitDelay",100)

Opt("WinTitleMatchMode",4)

Opt("WinDetectHiddenText",1)

Opt("MouseCoordMode",0)

WinWait("JobMon","")

What kind of application is "JobMon"? A standard windows app? A browser based app? A java app?

If a standard windows app, then I would think the "window within the window" that you're monitoring should be identifiable as some sort of control.

Have you checked it with the Au3Info tool?

Link to comment
Share on other sites

No its not a standard window within a window or any typ of vb box. This is a windows app only in the sense it runs on a windows box. This is an informational popup only and its not a window its within the app. All tools Ihave tried to use say the same thing the developer told me from back when it was developed years ago. This was some hokey app developed for us a long time ago in order for our files to get processed once they come out from the as400 creation que for the night. I have been trying to get rid of it but until we do I have to do it this way I have to work with it.

Link to comment
Share on other sites

Why doesn't this work? code right below and a description of what I am seeing below that.

If PixelGetColor(569,260) = 0x008100 then

Send("4")

while PixelGetColor(836,733) = 0x110E11

Sleep(100)

WEnd

Endif

If PixelGetColor(569,260) = 0x008100 then

Send("2")

while PixelGetColor(836,733) = 0x110E11

Sleep(100)

WEnd

Endif

Maybe your code is getting the pixel color a split second before the message box arrives?

Try waiting for the box to arrive, before waiting for it to disappear? Maybe put this after the Send("4")

if PixelGetColor(836,733) <> 0x110E11 then

while PixelGetColor(836,733) <> 0x110E11

Sleep(100)

WEnd

endif

Link to comment
Share on other sites

Thats it! It works like a champ now -

Changing each -

If PixelGetColor(569,260) = 0x008100 then

Send("2")

Sleep(30000)

Endif

to

If PixelGetColor(569,260) = 0x008100 then

Send("2")

If PixelGetColor(836,733) = 0x110E11 then

while PixelGetColor(836,733) = 0x110E11

Sleep(100)

WEnd

endif

endif

Works like a champ. Now it will send the key and as long as the window is showing it will not process the next keystroke. Then when the window is gone it does as it hsould.

I still think this may have to do with trying to proess 2 Pixelgetcolors on the same line (I may be wrong) but breaking it up this way I can now process a single one and have the funcationality I need.

Thanks for all your help guys.

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...