Detecting enable/disable status of button

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
tcoffma

Detecting enable/disable status of button

Post by tcoffma » Fri Sep 20, 2002 9:05 pm

Trying to figure out how wait for the status of a button to become disabled, so I can close down the window. Right now on my pc(development) it works, I try it on the prod pc, but the waitforcursorchange isn't working properly because on the slower pc it appears to flicker between normal and hourglass upon database activity.

I've been playing around with the WaitRectChange and WaitPixelColor without much success. They just sit in the wait state, even though my button is being enabled and disabled. I obtain the coords through the macro scheduler.

Any advise on this?

Thanks

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Sep 20, 2002 9:14 pm

There are a number of ways to tackle this. I would consider using WaitPixelColor and choose a pixel in the text of the button as it will be grey when disabled, and black when enabled.

One approach I have used in the past is simply to have a loop where I keep sending the keystroke for the button and then watch to see if the result of pressing the button when enabled occurs. If not I loop back and press again. e.g. if pressing the button causes a window to appear, keep trying until the window appears. If it doesn't the button must be disabled, so the loop continues. If it does then the button must have been enabled, so I just carry on. e.g. use WaitWindowOpen with a timeout value set ... and loop back if the result is negative.

Hope this gives you some ideas.

Marcus

tcoffma

Post by tcoffma » Fri Sep 20, 2002 9:43 pm

let>WW_TIMEOUT=60
label>my_loop
PushButton>Import Shipping History,&Close
IF>WW_RESULT=FALSE,my_loop,end
label>end
message>end

It drops to end on case of button being disabled or enabled unfortunatly.

If it's enabled, it closes window, and prints end.

If it's disabled, it prints end, but doesn't close window.

???

tcoffma

Post by tcoffma » Fri Sep 20, 2002 9:46 pm

nevermind, noticed something important i forgot.

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Sep 20, 2002 9:53 pm

You need the WaitWindowOpen - or whatever checks for the outcome from pressing the button, and I would also put a wait statement in there to make the loop less tight.

tcoffma

Post by tcoffma » Fri Sep 20, 2002 9:55 pm

That was a good idea thanks, it works. This chunk of macro will attempt to close the window every 60 seconds. Once it closes, the script keeps going.


let>WW_TIMEOUT=60
label>my_loop
PushButton>Import Shipping History,&Close
WaitWindowClosed>Import Shipping History
IF>WW_RESULT=FALSE,my_loop,end
label>end
message>end

is the solution.

Reason I forgot to have the WaitWindowClosed was because sometimes I go in and edit a script, hit the save icon, and it tells me to enter a name for the script. I hit ok and it closes, not saving my changes.

Thanks,

Tim

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Sep 20, 2002 10:20 pm

Glad you've got a solution.

Not seen the save issue before. Will check it out.

M.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts