How do I wait for properties like color changes in WPF?



  • I want to check, whether a background that was grey turned into black. Usually I wait for changes of attributes like this:

    Aliases.MyApp.BtnCalculationType.WaitProperty("Enabled", "True", 9999999);
    

    Unfortunately

    Aliases.MyApp.BtnCalculationType.WaitProperty("Fill.Color.B", "0", 9999999);
    

    does not work. What to do instead?



  • Firstly, the Fill.Color.B property value is a number, not a string, so you need to remove quotes around 0:

    Aliases.MyApp.BtnCalculationType.WaitProperty("Fill.Color.B", 0, 9999999)
    

    Secondly, Fill.Color.B is the color's blue component. You may need to also check the red, green and alpha components. To do this, you need to use a custom comparison instead of WaitProperty (WaitProperty doesn't support checking multiple properties at once). For example:

    // JScript
    var btn = Aliases.MyApp.BtnCalculationType;
    while ((btn.Fill.Color.B != 0) || (btn.Fill.Color.R != 0) || (btn.Fill.Color.G != 0))
      Delay(500);
    

Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2