Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Programmatically control a pop up calendar
#1
The application I am trying to automate has a popup Calendar control. I need to be able to take today's date, do some math to it, and select it on a calendar control. I found some code on this site that feels like it should work, but I must be missing something.

I'm very new to QM and this may just be somthing simple.

Code:
Copy      Help
def MCM_FIRST 0x1000
def MCM_SETCURSEL (MCM_FIRST + 2)

DATE d="10/5/2007"
d.tosystemtime(+share)

int mc=win("" "SysMonthCal32")
SendMessage mc MCM_SETCURSEL 0 share(mc)

When I run this, I get an error "window not found", the control really is "Sysmonthcal32". I have tried some other entries for the win() function, but with no luck. The window that contains the control also has an ""OK" and "Cancel" buttons.

How can I specify the control directly?
This was from an old post, QM has changed, Operating systems have changed, is this the problem? (running XP sp2)
Is there an easier way? the only keystrokes I could find that it responds to are home, end, Pgup, Pgdn.


Thanks to Gintaras for the code snipit
#2
The code works well on XP. I tested in scheduled task properties.

The calendar must be displayed. Otherwise it does not exist.

Or maybe you forgot to delete

act "Form"
key LR

, and get error in act "Form" line?

Or maybe it is child window. When mouse pointer is in the calendar, you see +SysMonthCal32 in QM status bar. Is it in first line? If it is in second line, the calendar is child window, and therefore must be used function child instead of win.
#3
It was a child window!

Thanks for your help. Unfortunately I am having the same problem that the person in the original post had. I had hoped that because they had a different control, without an OK button I would have better luck.

It will highlight the the date I send to it, but when I press OK, the date is unchanged. I tried a few keystrokes (left/right, Pgup/Pgdn) , but it really needs a mouse click to take hold. My only thoughts are:

1. Try some more sendmessages. now that I can "talk" to the control, maybe there is another message that will get it to stick.

2. Now that the correct date is highlighted and visible, it should be fairly easy to do a pixel search to click on it. I don't know how to do that, but it shouldn't be that hard.

Any other thoughts?

Thanks again for your help, I have a fairly complex program all set up to exercise an application for performance testing, store the results in a database, and an excel sheet to read in the data and graph it. The only part I need to put it all together is this one step.
#4
key LR usually works. I also tried to send messages but it did not work.
#5
1. I used an image search to find the just left side of the highlight. Worked like a charm. for some reason I had to click the wrong day, then the correct day to get to stick. I don't understand why, but it was easy to do.

2. Now that I'm past the part that had me stuck I've been coding away. Love the program, Love the documentation, love the built-in editor, love the examples, and love the built-in windows spy++. Much easier than any of the tools I started with.

3. Just registered.

Thanks for your help! I've been stuck on this for 3 days.


Forum Jump:


Users browsing this thread: 1 Guest(s)