Closed ebertech closed 12 years ago
Thanks for the contribution. GetWindowText, as you point out, is the right way to go. Were you able to get the test suite to pass? I get several test failures in Windows XP on Ruby 1.8.7 after applying your commit.
Let me try it on my vm. I think it might have to do with the control text which you're supposed to do with WM_GETTEXT if it's not in your own process. I think it'd be safer to do GetWindowText if the target handle is a window and not a control. I'm still trying to find a way to differentiate the two, any ideas?
I just ran the specs on win7 and windows xp using the current code (without my changes) in this repo. On win7 I get 9 fails, on winxp I get 1. Do you want me to gist the results?
Ok, figured it out on XP. The error was a random clipboard error which went away the second (and subsequent times I ran it). All tests pass now. GetWindowText was already defined in Windows::Window so I got rid of that because it was giving a warning. I also added in is_control? which uses GetDlgCtrlID to get the ID of the control. If it's 0 then I assume it's a Window and I send it GetWindowText.
I ran the tests as well and all the main project test pass. Unfortunately, the included example project tests don't pass. At least half of the tests fail. I should add a rake task so the folks know the examples folder contains runnable specs. Would you mind having a look?
cd examples/quicknote
bundle install
bundle exec rake
Thanks!
definitely, lemme run those.
so I just ran it... everything passed.
Finished in 54.85 seconds 36 examples, 0 failures
OK! I just pulled this and pushed out version 0.5.2. The specs were too touchy on my XP VM so I added default timeouts and placed a few set_focus calls where needed. Everything passes in a repeatable manner now. I also gave the new update a workout on a really large legacy characterization suite the uses the code. No issues.
Thanks much for your help.
Hi
I've run into an issue where WM_GETTEXT would just hang everything. After some digging I found:
http://blogs.msdn.com/b/oldnewthing/archive/2003/08/21/54675.aspx
Switching out to GetWindowText fixed my instance of the freezing issue. It's not 100% guaranteed to work (as noted in the link above), but I think it's "safer."