robertwahler / win32-autogui

A Ruby Win32 GUI testing framework packaged as a RubyGem
http://www.gearheadforhire.com/articles/ruby/win32-autogui/using-ruby-to-drive-windows-applications
MIT License
52 stars 6 forks source link

ArgumentError: invalid byte sequence in US-ASCII if the window contains non-English character #6

Open n5ken opened 12 years ago

n5ken commented 12 years ago
irb(main):013:0> calc.running?
ArgumentError: invalid byte sequence in US-ASCII
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/win32-autogui-0.5.2/lib/win32/autogui/application.rb:211:in `match'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/win32-autogui-0.5.2/lib/win32/autogui/application.rb:211:in `match'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/win32-autogui-0.5.2/lib/win32/autogui/application.rb:211:in `block (2 levels) in main_window'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/win32-autogui-0.5.2/lib/win32/autogui/window.rb:35:in `block (2 levels) in find'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/win32-autogui-0.5.2/lib/win32/autogui/window.rb:51:in `each'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/win32-autogui-0.5.2/lib/win32/autogui/window.rb:35:in `block in find'
        from C:/Ruby192/lib/ruby/1.9.1/timeout.rb:44:in `timeout'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/win32-autogui-0.5.2/lib/win32/autogui/window.rb:33:in `find'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/win32-autogui-0.5.2/lib/win32/autogui/application.rb:210:in `block in main_window'
        from C:/Ruby192/lib/ruby/1.9.1/timeout.rb:58:in `timeout'
        from C:/Ruby192/lib/ruby/1.9.1/timeout.rb:89:in `timeout'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/win32-autogui-0.5.2/lib/win32/autogui/application.rb:207:in `main_window'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/win32-autogui-0.5.2/lib/win32/autogui/application.rb:242:in `running?'
        from (irb):13
        from C:/Ruby192/bin/irb:12:in `<main>'

I think here should compatible with the title that contain UTF-8.

robertwahler commented 12 years ago

Thanks for the report. This is an issue with several of the Win32 API calls using the ANSI version instead of the Wide version. I don't currently have client work that requires Windows testing so I'll leave this issue open for now and put it on my TODO list. Eventually, I'd like the code base to move to FFI for the API calls.

evgeniy-khatko commented 11 years ago

Hi! Have you got a chance to look through this issue?

robertwahler commented 11 years ago

Sorry, still I don't have time to devote to this issue. I would be happy to accept a pull request though. There is probably enough coverage in the test suite to just swap out the ANSI API calls.

evgeniy-khatko commented 11 years ago

Hello, I could theoretically look through this, if you'd give some hints. I'm not familiar with win32 API (

We'd like to use win32-autogui to test our win-forms application. TIA, Evgeniy

2013/2/12 Robert Wahler notifications@github.com

Sorry, still I don't have time to devote to this issue. I would be happy to accept a pull request though. There is probably enough coverage in the test suite to just swap out the ANSI API calls.

Reply to this email directly or view it on GitHubhttps://github.com/robertwahler/win32-autogui/issues/6#issuecomment-13431906.

ó Õ×ÁÖÅÎÉÅÍ, èÁÔØËÏ å×ÇÅÎÉÊ

robertwahler commented 11 years ago

The first thing that needs to be done is add some failing tests to the test suite.

I'd clone the repository and then:

bundle install
bundle exec rake spec

I'd assume the test suite fails driving the calculator depending on your regional settings. A better test would be to use the notepad to save a file with non-ASCII character in the file name and then write a spec that looks for the filename, it should fail with errors.

Then I'd swap out all the API functions for the Unicode versions, there are three or four, like SendMessageA should be SendMessageW. I can have a look next week if you need help.

robertwahler commented 11 years ago

One more thing, you will most likely need to add API signatures for the new functions, see

lib/win32/autogui/windows/window.rb

The gems that autogui is using should be updated but that is a big task, so I'd keep the gemspec locked down.

evgeniy-khatko commented 11 years ago

Hi, I've been playing with Rautomation gem recently. It's useful, but does not satisfy all our needs.

Tomorrow i'm going to test win32-autogui with our application in english locale. If it fits, I will do the pull request to get it working in another locales!

Best Regards, Evgeniy

2013/2/13 Robert Wahler notifications@github.com

One more thing, you will most likely need to add API signatures for the new functions, see

lib/win32/autogui/windows/window.rb

The gems that autogui is using should be updated but that is a big task, so I'd keep the gemspec locked down.

Reply to this email directly or view it on GitHubhttps://github.com/robertwahler/win32-autogui/issues/6#issuecomment-13463037.

ó Õ×ÁÖÅÎÉÅÍ, èÁÔØËÏ å×ÇÅÎÉÊ