Question about WinExist and Double-byte characters

Started by gauthierda, July 29, 2013, 09:51:26 AM

Previous topic - Next topic

gauthierda

Hi,

I am wondering if the WinExist function should support double byte characters.  I'm trying to build an package that searches for a Window with a Chinese title. 

Deana

Yes WinExist should support double-byte character sets.
Deana F.
Technical Support
Wilson WindowWare Inc.

gauthierda

Ok, Thanks.  Now the question, how would I enter it?

"重置Internet Explorer 设置"  is what I want to enter, but if I try to cut and paste it into WinBatch Studio, I wind up with "?? Internet Explorer ??"


td

Quote from: gauthierda on July 29, 2013, 09:51:26 AM
Hi,

I am wondering if the WinExist function should support double byte characters.  I'm trying to build an package that searches for a Window with a Chinese title.

Like most WinBatch functions WinExist converts string input to Unicode UTF-16 on all currently supported systems.  By default the conversion is performed using the current system ANSI code page.  If your system happens to be set to the correct Chinese ANSI code page, the conversion will work and any existing window should be found.  However, if your system's default code page is something other than a Chinese one, you will have difficulty finding the window. 

There are two workarounds you might want to consider, if you system is not defaulted to a Chinese code page. You could try telling WinBatch to temporarily use a Chinese code page like 950 or 936 by using the ChrGetCodePage and ChrSetCodePage functions for your call to WinExist.  These code pages would need to be available on your system for this approach to work.

The other approach would be to convert the window title to Unicode before passing it to WinExist.  There are several ways to do the conversion with both the ChrHexToUnicode or BinaryConvert functions coming to mind as possible approaches but there are other techniques.  ChrHexToUnicode is probably the easiest if you can assume your window name or names is or are not going to change frequently.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

Quote from: gauthierda on July 29, 2013, 10:51:44 AM
Ok, Thanks.  Now the question, how would I enter it?

"重置Internet Explorer 设置"  is what I want to enter, but if I try to cut and paste it into WinBatch Studio, I wind up with "?? Internet Explorer ??"

Right click in the WinBatch Studio window displaying your document and selection the  "Insert Unicode Text" menu option.  This will generate a call to ChrHexToUnicode for you.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

Deana

I should have clarified. WinBatch Studio is an Ascii editor. In order to use Unicode text in WinBatch Studio, you must call ChrHexToUnicode. WinBatch studio has simplified the process. WinBatch Studio has a completely configurable context menu accessed by clicking the right mouse button anywhere within an open file. In this instance you can use the Insert Unicode Text menu option. When prompted paste the Chinese characters into the dialog. The menu option will auto magically fill in the appropriate line of code. It will look something like this:"

Code (winbatch) Select
sChinese = ChrHexToUnicode("CD916E7F49006E007400650072006E006500740020004500780070006C006F007200650072002000BE8B6E7F")
ret = WinExist( sChinese )
if ret
   Pause('Notice','Window Exists')
else
   Pause('Notice','Window Does Not Exist')
endif
Deana F.
Technical Support
Wilson WindowWare Inc.

gauthierda

Thanks for the help!  That looks like it will do the trick!

Dan