using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using Vanara.InteropServices;
namespace Vanara.PInvoke
{
public static partial class MSCTF
{
private const string Lib_input = "input.dll";
/// The InputScope enumeration contains values that specify which input scopes are applied to a given field.
/// Whether a given input scope value is supported can vary across technologies.
// https://docs.microsoft.com/en-us/windows/win32/api/inputscope/ne-inputscope-inputscope typedef enum
// __MIDL___MIDL_itf_inputscope_0000_0000_0001 { IS_DEFAULT, IS_URL, IS_FILE_FULLFILEPATH, IS_FILE_FILENAME, IS_EMAIL_USERNAME,
// IS_EMAIL_SMTPEMAILADDRESS, IS_LOGINNAME, IS_PERSONALNAME_FULLNAME, IS_PERSONALNAME_PREFIX, IS_PERSONALNAME_GIVENNAME,
// IS_PERSONALNAME_MIDDLENAME, IS_PERSONALNAME_SURNAME, IS_PERSONALNAME_SUFFIX, IS_ADDRESS_FULLPOSTALADDRESS, IS_ADDRESS_POSTALCODE,
// IS_ADDRESS_STREET, IS_ADDRESS_STATEORPROVINCE, IS_ADDRESS_CITY, IS_ADDRESS_COUNTRYNAME, IS_ADDRESS_COUNTRYSHORTNAME,
// IS_CURRENCY_AMOUNTANDSYMBOL, IS_CURRENCY_AMOUNT, IS_DATE_FULLDATE, IS_DATE_MONTH, IS_DATE_DAY, IS_DATE_YEAR, IS_DATE_MONTHNAME,
// IS_DATE_DAYNAME, IS_DIGITS, IS_NUMBER, IS_ONECHAR, IS_PASSWORD, IS_TELEPHONE_FULLTELEPHONENUMBER, IS_TELEPHONE_COUNTRYCODE,
// IS_TELEPHONE_AREACODE, IS_TELEPHONE_LOCALNUMBER, IS_TIME_FULLTIME, IS_TIME_HOUR, IS_TIME_MINORSEC, IS_NUMBER_FULLWIDTH,
// IS_ALPHANUMERIC_HALFWIDTH, IS_ALPHANUMERIC_FULLWIDTH, IS_CURRENCY_CHINESE, IS_BOPOMOFO, IS_HIRAGANA, IS_KATAKANA_HALFWIDTH,
// IS_KATAKANA_FULLWIDTH, IS_HANJA, IS_HANGUL_HALFWIDTH, IS_HANGUL_FULLWIDTH, IS_SEARCH, IS_FORMULA, IS_SEARCH_INCREMENTAL,
// IS_CHINESE_HALFWIDTH, IS_CHINESE_FULLWIDTH, IS_NATIVE_SCRIPT, IS_YOMI, IS_TEXT, IS_CHAT, IS_NAME_OR_PHONENUMBER,
// IS_EMAILNAME_OR_ADDRESS, IS_PRIVATE, IS_MAPS, IS_NUMERIC_PASSWORD, IS_NUMERIC_PIN, IS_ALPHANUMERIC_PIN, IS_ALPHANUMERIC_PIN_SET,
// IS_FORMULA_NUMBER, IS_CHAT_WITHOUT_EMOJI, IS_PHRASELIST, IS_REGULAREXPRESSION, IS_SRGS, IS_XML, IS_ENUMSTRING } InputScope;
[PInvokeData("inputscope.h", MSDNShortId = "NE:inputscope.__MIDL___MIDL_itf_inputscope_0000_0000_0001")]
public enum InputScope : int
{
///
/// Indicates the standard recognition bias. Treated as default and uses the default lexicon. If combined with another input
/// scope, it does not force coercion on the other input scope.
///
IS_DEFAULT = 0,
/// Indicates a URL, File, or FTP format. Examples include the following.
IS_URL,
/// Indicates a file path. The following conditions are enforced.
IS_FILE_FULLFILEPATH,
/// Indicates a file name. The following conditions are enforced.
IS_FILE_FILENAME,
/// Indicates email user names. Examples include the following.
IS_EMAIL_USERNAME,
/// Indicates a complete SMTP email address, for example, someone@example.com.
IS_EMAIL_SMTPEMAILADDRESS,
/// Indicates a log-in name and domain. The following conditions are enforced.Examples include the following.
IS_LOGINNAME,
///
/// Indicates a combination of first, middle, and last names. Examples include the following, formatted for English (United States).
///
IS_PERSONALNAME_FULLNAME,
///
/// Indicates a honorific or title preceding a name. Examples include the following, formatted for English (United States).
///
IS_PERSONALNAME_PREFIX,
/// Indicates a first name or initial. Examples include the following, formatted for English (United States).
IS_PERSONALNAME_GIVENNAME,
/// Indicates a middle name or initial. Examples include the following.
IS_PERSONALNAME_MIDDLENAME,
/// Indicates a last name. Examples include the following, formatted for English (United States).
IS_PERSONALNAME_SURNAME,
/// Indicates a name suffix abbreviation or Roman numerals. Examples include the following.
IS_PERSONALNAME_SUFFIX,
/// Indicates a full address, including numbers. Examples include the following, formatted for English (United States).
IS_ADDRESS_FULLPOSTALADDRESS,
///
/// Indicates an alphanumeric postal code. The value is alphanumeric to support international zip codes. Examples include the
/// following, formatted for English (United States).
///
IS_ADDRESS_POSTALCODE,
///
/// Indicates a house number, street number, apartment name and number, and/or postal box. Examples include the following.
///
IS_ADDRESS_STREET,
///
/// Indicates a full name or abbreviation of state or province. Examples include the following, formatted for English (United States).
///
IS_ADDRESS_STATEORPROVINCE,
///
/// Indicates the name or abbreviation of a city. Examples include the following, formatted for English (United States).
///
IS_ADDRESS_CITY,
/// Indicates the name of a country/region. Examples include the following, formatted for English (United States).
IS_ADDRESS_COUNTRYNAME,
///
/// Indicates the abbreviation of the name of a country/region. Examples include the following, formatted for English (United States).
///
IS_ADDRESS_COUNTRYSHORTNAME,
/// Indicates currency symbols and numbers. Examples include the following, formatted for English (United States).
IS_CURRENCY_AMOUNTANDSYMBOL,
/// Indicates a numeric value for currency, excluding currency symbols. For example, 2,100.25.
IS_CURRENCY_AMOUNT,
///
/// Indicates a full date, in a variety of formats. Examples include the following, formatted for English (United States).
///
IS_DATE_FULLDATE,
/// Indicates a numeric representation of months, constrained to 1-12. Examples include the following.
IS_DATE_MONTH,
/// Indicates a numeric representation of days, constrained to 1-31. Examples include the following.
IS_DATE_DAY,
/// Indicates a numeric representation of years. Examples include the following.
IS_DATE_YEAR,
///
/// Indicates a character representation of months. Examples include the following, formatted for English (United States).
///
IS_DATE_MONTHNAME,
///
/// Indicates a character representation of days. Examples include the following, formatted for English (United States).
///
IS_DATE_DAYNAME,
/// Indicates positive whole numbers, constrained to 0-9.
IS_DIGITS,
///
/// Indicates numbers, including commas, negative sign, and decimal. For United States locations, the following conditions are enforced.
///
IS_NUMBER,
/// Indicates a single ANSI character, codepage 1252. For United States locations, this includes the following characters.ABCDEFGHIJKLMNOPQRSTUVWXYZabcdEfghijklmnopqrstuvwxyz0123456789!"#$%&'()*+,-./:;<=>?@[]^_`{
IS_ONECHAR,
/// Indicates a password. IS_PASSWORD is not supported and may be altered or unavailable in the future.
IS_PASSWORD,
///
/// Indicates a telephone number. Alphabetical input is not allowed. Examples include the following, formatted for English
/// (United States).
///
IS_TELEPHONE_FULLTELEPHONENUMBER,
/// Indicates telephone country codes. Examples include the following, formatted for English (United States).
IS_TELEPHONE_COUNTRYCODE,
/// Indicates telephone area codes. Examples include the following, formatted for English (United States).
IS_TELEPHONE_AREACODE,
///
/// Indicates a telephone number, excluding country or area code. Examples include the following, formatted for English (United States).
///
IS_TELEPHONE_LOCALNUMBER,
///
/// Indicates hours, minutes, seconds, and alphabetical time abbreviations. US English uses the 12 hour clock. Leading zeros are
/// optional for hours but required for minutes and seconds. Hours are constrained to 0-24; minutes and seconds are constrained
/// to 0-59. Examples include the following, formatted for English (United States).
///
IS_TIME_FULLTIME,
/// Indicates a numeric representation of hours, constrained to 0-24.
IS_TIME_HOUR,
/// Indicates a numeric representation of minutes or seconds, constrained to 0-59.
IS_TIME_MINORSEC,
/// Indicates full-width number, used for Japanese only. Constrained to full-width numbers and Kanji numbers.
IS_NUMBER_FULLWIDTH,
///
/// Indicates half-width alphanumeric characters for East-Asian languages, constrained to half-width alphabetical characters and numbers.
///
IS_ALPHANUMERIC_HALFWIDTH,
///
/// Indicates full-width alphanumeric characters for East-Asian languages, constrained to full-width alphabet characters and numbers.
///
IS_ALPHANUMERIC_FULLWIDTH,
/// Indicates Chinese currency.
IS_CURRENCY_CHINESE,
/// Indicates Bopomofo characters.
IS_BOPOMOFO,
/// Indicates Hiragana characters.
IS_HIRAGANA,
/// Indicates half-width Katakana characters.
IS_KATAKANA_HALFWIDTH,
/// Indicates full-width Katakana characters.
IS_KATAKANA_FULLWIDTH,
/// Indicates Hanja characters.
IS_HANJA,
/// Indicates half-width Hangul characters.
IS_HANGUL_HALFWIDTH,
/// Indicates full-width Hangul characters.
IS_HANGUL_FULLWIDTH,
/// Starting with Windows 8: Indicates a search string.
IS_SEARCH,
/// Starting with Windows 8: Indicates a formula control, for example, a spreadsheet field.
IS_FORMULA,
///
/// Starting with Windows 10: Indicates input scope is intended for search boxes where incremental results are displayed as the
/// user types.
///
IS_SEARCH_INCREMENTAL,
/// Starting with Windows 10: Indicates input scope is intended for Chinese half-width characters.
IS_CHINESE_HALFWIDTH,
/// Starting with Windows 10: Indicates input scope is intended for Chinese full-width characters.
IS_CHINESE_FULLWIDTH,
/// Starting with Windows 10: Indicates input scope is intended for native script.
IS_NATIVE_SCRIPT,
/// Starting with Windows 10: Indicates input scope is intended for Japanese names.
IS_YOMI,
/// Starting with Windows 10: Indicates input scope is intended for working with text.
IS_TEXT,
/// Starting with Windows 10: Indicates input scope is intended for chat strings.
IS_CHAT,
/// Starting with Windows 10: Indicates input scope is intended for working with a name or telephone number.
IS_NAME_OR_PHONENUMBER,
/// Starting with Windows 10: Indicates input scope is intended for working with an email name or full email address.
IS_EMAILNAME_OR_ADDRESS,
/// Starting with Windows 10: Indicates input scope is intended for working with private data.
IS_PRIVATE,
/// Starting with Windows 10: Indicates input scope is intended for working with a map location.
IS_MAPS,
/// Starting with Windows 10: Indicates expected input is a numeric password, or PIN.
IS_NUMERIC_PASSWORD,
/// Starting with Windows 10: Indicates expected input is a numeric PIN.
IS_NUMERIC_PIN,
/// Starting with Windows 10: Indicates expected input is an alphanumeric PIN.
IS_ALPHANUMERIC_PIN,
/// Starting with Windows 10: Indicates expected input is an alphanumeric PIN for lock screen.
IS_ALPHANUMERIC_PIN_SET,
/// Starting with Windows 10: Indicates expected input is a mathematical formula.
IS_FORMULA_NUMBER,
/// Starting with Windows 10: Indicates expected input does not include emoji.
IS_CHAT_WITHOUT_EMOJI,
/// Indicates a phrase list.
IS_PHRASELIST = -1,
/// Indicates a regular expression.
IS_REGULAREXPRESSION = -2,
///
/// Indicates an XML string that conforms to the Speech Recognition Grammar Specification (SRGS) standard. Information on SRGS
/// can be found at http://www.w3.org/TR/speech-grammar.
///
IS_SRGS = -3,
/// Indicates a custom xml string.
IS_XML = -4,
///
/// The scope contains the IEnumString interface pointer. The Text Input Processor (TIP) can call ITfInputScope2::EnumWordList
/// to retrieve it.
///
IS_ENUMSTRING = -5,
}
///
///
/// The ITfInputScope interface is used by the text input processors to get the InputScope value that represents a document
/// context associated with a window. The input scope provides rules to help speech and handwriting recognition. For instance, if a
/// text box on a form is used to enter an address, the input scope for that text box can be set to recognize and accept only those
/// characters that are valid for an address.
///
/// The interface ID is IID_ITfInputScope.
///
/// The document context is used by the speech and handwriting recognition engine and is set by a text input processor by calling
/// the SetInputScope method. A TSF-aware application does not call SetInputScope directly, but rather implements either
/// ITextStoreACP or ITfContextOwner to get a pointer to ITfInputScope.
///
///
/// To get the pointer to the ITfInputScope interface, the text input processor or TSF-aware application calls
/// ITfContext::GetAppProperty, passing in GUID_PROP_INPUTSCOPE and a pointer to the ITFReadOnlyProperty interface, as in the
/// following example.
///
///
/// extern const GUID GUID_PROP_INPUTSCOPE; // // The TIP can call this to get the input scope of the document mgr. // HRESULT GetInputScope(ITfContext *pic, ITfRange *pRange, TfEditCookie ec, ITfInutScope **ppiscope){ ITFReadOnlyProperty *prop; HRESULT hr; If (SUCCEEDED(hr = pic->GetAppProperty(GUID_PROP_INPUTSCOPE, &prop)) { VARIANT var; If (SUCCEEDED(hr = prop->GetValue(ec, pRange, &var))) { hr = var.punkVal->QueryInterface(IID_ITfInputScope, (void **)ppiscope); } prop->Release(); } return hr }
///
///
///
/// To use this interface with window-less controls, an application has two options.
///
/// -
///
/// Make the application TSF-aware: A TSF-aware application must implement either ITextStoreACP or ITfContextOwner to get a
/// pointer to ITfInputScope.
///
///
/// -
///
/// SetInputScopes This is not recommended, but if the application is not TSF-aware, there is no other way to maintain the
/// association between the input scope and the application. In this case, the application must call SetInputScopes whenever focus
/// changes among window-less controls.
///
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/inputscope/nn-inputscope-itfinputscope
[PInvokeData("inputscope.h", MSDNShortId = "NN:inputscope.ITfInputScope")]
[ComImport, Guid("FDE1EAEE-6924-4CDF-91E7-DA38CFF5559D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface ITfInputScope
{
/// Gets the input scopes that are associated with this context.
///
/// Pointer to an array of pointers to the input scopes. The calling function must call CoTaskMemFree() to free the buffer.
///
/// Pointer to the number of input scopes returned.
///
/// This method can return one of these values.
///
///
/// Value
/// Description
///
/// -
/// S_OK
/// The method was successful.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/inputscope/nf-inputscope-itfinputscope-getinputscopes HRESULT
// GetInputScopes( InputScope **pprgInputScopes, UINT *pcCount );
[PreserveSig]
HRESULT GetInputScopes(out SafeCoTaskMemHandle pprgInputScopes, out uint pcCount);
/// Gets the phrase list set to this context.
///
/// Pointer to an array of pointers to strings containing phrases. The calling function must call SystFreeString() to
/// free the memory allocated to the strings and CoTaskMemFree to free the buffer.
///
/// Pointer to the number of phrases returned.
///
/// This method can return one of these values.
///
///
/// Value
/// Description
///
/// -
/// S_OK
/// The method was successful.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/inputscope/nf-inputscope-itfinputscope-getphrase HRESULT GetPhrase( BSTR
// **ppbstrPhrases, UINT *pcCount );
[PreserveSig]
HRESULT GetPhrase(out SafeCoTaskMemHandle ppbstrPhrases, out uint pcCount);
/// Gets the regular expression string to be rssecognized.
///
/// Pointer to a string containing the regular expression. The calling function must call SystFreeString() to free the
/// memory allocated to the strings.
///
///
/// This method can return one of these values.
///
///
/// Value
/// Description
///
/// -
/// S_OK
/// The method was successful.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/inputscope/nf-inputscope-itfinputscope-getregularexpression HRESULT
// GetRegularExpression( BSTR *pbstrRegExp );
[PreserveSig]
HRESULT GetRegularExpression([Out, MarshalAs(UnmanagedType.BStr)] out string pbstrRegExp);
/// Gets the Speech Recognition Grammar Specification (SRGS) string to be recognized.
/// The xml string. The calling function must call SysFreeString() to free the buffer.
///
/// This method can return one of these values.
///
///
/// Value
/// Description
///
/// -
/// S_OK
/// The method was successful.
///
///
///
/// http://www.w3.org/TR/speech-grammar
// https://docs.microsoft.com/en-us/windows/win32/api/inputscope/nf-inputscope-itfinputscope-getsrgs HRESULT GetSRGS( BSTR
// *pbstrSRGS );
[PreserveSig]
HRESULT GetSRGS([Out, MarshalAs(UnmanagedType.BStr)] out string pbstrSRGS);
/// Gets the custom XML string to be recognized.
///
/// Pointer to a string containing the xml string. The calling function must call SysFreeString() to free the buffer.
///
///
/// This method can return one of these values.
///
///
/// Value
/// Description
///
/// -
/// S_OK
/// The method was successful.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/inputscope/nf-inputscope-itfinputscope-getxml HRESULT GetXML( BSTR
// *pbstrXML );
[PreserveSig]
HRESULT GetXML([Out, MarshalAs(UnmanagedType.BStr)] out string pbstrXML);
}
///
/// The ITfInputScope2 interface is used by the text input processors to get the IEnumString interface pointer and this
/// IEnumString interface enumerates the word list that the application specified for this context.
///
// https://docs.microsoft.com/en-us/windows/win32/api/inputscope/nn-inputscope-itfinputscope2
[PInvokeData("inputscope.h", MSDNShortId = "NN:inputscope.ITfInputScope2")]
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("5731EAA0-6BC2-4681-A532-92FBB74D7C41")]
public interface ITfInputScope2 : ITfInputScope
{
/// Gets the input scopes that are associated with this context.
///
/// Pointer to an array of pointers to the input scopes. The calling function must call CoTaskMemFree() to free the buffer.
///
/// Pointer to the number of input scopes returned.
///
/// This method can return one of these values.
///
///
/// Value
/// Description
///
/// -
/// S_OK
/// The method was successful.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/inputscope/nf-inputscope-itfinputscope-getinputscopes HRESULT
// GetInputScopes( InputScope **pprgInputScopes, UINT *pcCount );
[PreserveSig]
new HRESULT GetInputScopes(out SafeCoTaskMemHandle pprgInputScopes, out uint pcCount);
/// Gets the phrase list set to this context.
///
/// Pointer to an array of pointers to strings containing phrases. The calling function must call SystFreeString() to
/// free the memory allocated to the strings and CoTaskMemFree to free the buffer.
///
/// Pointer to the number of phrases returned.
///
/// This method can return one of these values.
///
///
/// Value
/// Description
///
/// -
/// S_OK
/// The method was successful.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/inputscope/nf-inputscope-itfinputscope-getphrase HRESULT GetPhrase( BSTR
// **ppbstrPhrases, UINT *pcCount );
[PreserveSig]
new HRESULT GetPhrase(out SafeCoTaskMemHandle ppbstrPhrases, out uint pcCount);
/// Gets the regular expression string to be rssecognized.
///
/// Pointer to a string containing the regular expression. The calling function must call SystFreeString() to free the
/// memory allocated to the strings.
///
///
/// This method can return one of these values.
///
///
/// Value
/// Description
///
/// -
/// S_OK
/// The method was successful.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/inputscope/nf-inputscope-itfinputscope-getregularexpression HRESULT
// GetRegularExpression( BSTR *pbstrRegExp );
[PreserveSig]
new HRESULT GetRegularExpression([Out, MarshalAs(UnmanagedType.BStr)] out string pbstrRegExp);
/// Gets the Speech Recognition Grammar Specification (SRGS) string to be recognized.
/// The xml string. The calling function must call SysFreeString() to free the buffer.
///
/// This method can return one of these values.
///
///
/// Value
/// Description
///
/// -
/// S_OK
/// The method was successful.
///
///
///
/// http://www.w3.org/TR/speech-grammar
// https://docs.microsoft.com/en-us/windows/win32/api/inputscope/nf-inputscope-itfinputscope-getsrgs HRESULT GetSRGS( BSTR
// *pbstrSRGS );
[PreserveSig]
new HRESULT GetSRGS([Out, MarshalAs(UnmanagedType.BStr)] out string pbstrSRGS);
/// Gets the custom XML string to be recognized.
///
/// Pointer to a string containing the xml string. The calling function must call SysFreeString() to free the buffer.
///
///
/// This method can return one of these values.
///
///
/// Value
/// Description
///
/// -
/// S_OK
/// The method was successful.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/inputscope/nf-inputscope-itfinputscope-getxml HRESULT GetXML( BSTR
// *pbstrXML );
[PreserveSig]
new HRESULT GetXML([Out, MarshalAs(UnmanagedType.BStr)] out string pbstrXML);
/// Return a pointer to obtain the IEnumString interface pointer.
/// A pointer to obtain the IEnumString interface pointer.
///
/// This method can return one of these values.
///
///
/// Value
/// Description
///
/// -
/// S_OK
/// The method was successful.
///
/// -
/// E_FAIL
/// An unspecified error occurred.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/inputscope/nf-inputscope-itfinputscope2-enumwordlist HRESULT EnumWordList(
// IEnumString **ppEnumString );
[PreserveSig]
HRESULT EnumWordList(out IEnumString ppEnumString);
}
/// Sets an input scope for the specified window.
/// The window to set the scope on.
///
/// The input scope to associate with the window. To remove the input scope association, pass IS_DEFAULT to this parameter.
///
///
///
///
/// Value
/// Meaning
///
/// -
/// S_OK
/// The method was successful.
///
///
///
///
/// Calling this method replaces whatever scope is associated with the window.
///
/// An application must call this method, passing in IS_DEFAULT to the hwnd parameter, to remove the input scope association before
/// the window is destroyed.
///
///
/// This API works only when the window (hwnd parameter) and the calling thread are in the same thread. If you call this API for a
/// different thread's window, it fails with E_INVALIDARG.
///
///
/// If you call this method on a window (hwnd parameter) that has not been associated with a Document Manager, then no text service
/// notifications are sent to interested clients (such as the touch keyboard) that may want to respond to the scope change.
///
/// Examples
/// [C++]
/// The following code illustrates how to set an input scope for a window.
///
/// SetInputScope(hwnd, IS_EMAIL_USERNAME);
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/inputscope/nf-inputscope-setinputscope HRESULT SetInputScope( HWND hwnd,
// InputScope inputscope );
[DllImport(Lib_Msctf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("inputscope.h", MSDNShortId = "NF:inputscope.SetInputScope")]
public static extern HRESULT SetInputScope(HWND hwnd, InputScope inputscope);
///
/// Sets a combination of one input scope, multiple input scopes, one phrase list, a regular expression, and/or Speech Recognition
/// Grammar Specification (SRGS) rules for the specified window.
///
/// The window to set the scope on.
///
/// Pointer to an array of input scopes. Can be NULL. If not NULL, all of the input scopes in the array are set as the
/// input scope of the window with equal weighting. Use IS_DEFAULT to accept all other input scopes as well.
///
///
/// The number of input scopes in the array pointed to by *pInputScopes. This value must be zero if the array is NULL.
///
/// Pointer to an array of pointers to NULL-terminated phrases. Can be NULL.
/// Number of pointers pointed to by **ppszPhraseList, which represents the number of phrases.
///
/// Pointer to a NULL-terminated string containing the regular expression to be recognized. Can be NULL.
///
///
/// Pointer to a NULL-terminated XML string that provides speech-specific hints and rules to aid in speech recognition. The
/// XML format conforms to the Speech Recognition Grammar Specification (SRGS) standard, outlined at
/// http://www.w3.org/TR/speech-grammar. Can be NULL. $
///
///
///
///
/// Value
/// Meaning
///
/// -
/// S_OK
/// The method was successful.
///
///
///
///
/// Calling this method replaces whatever scope is associated with the window.
///
/// This API works only when the window (hwnd parameter) and the calling thread are in the same thread. If you call this API for a
/// different thread's window, it fails with E_INVALIDARG.
///
///
/// If you call this method on a window (hwnd parameter) that has not been associated with a Document Manager, then no text service
/// notifications are sent to interested clients (such as the touch keyboard) that may want to respond to the scope change.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/inputscope/nf-inputscope-setinputscopes HRESULT SetInputScopes( HWND hwnd,
// const InputScope *pInputScopes, UINT cInputScopes, PWSTR *ppszPhraseList, UINT cPhrases, PWSTR pszRegExp, PWSTR pszSRGS );
[DllImport(Lib_Msctf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("inputscope.h", MSDNShortId = "NF:inputscope.SetInputScopes")]
public static extern HRESULT SetInputScopes(HWND hwnd, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] InputScope[] pInputScopes, uint cInputScopes,
[Optional, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 4)] string[] ppszPhraseList,
uint cPhrases, [Optional, MarshalAs(UnmanagedType.LPWStr)] string pszRegExp, [Optional, MarshalAs(UnmanagedType.LPWStr)] string pszSRGS);
///
/// The application must call SetInputScope with IS_DEFAULT before a window is destroyed to clear the reference of the interface.
///
/// The window to set the scope on. This call will replace whatever scope may have been on the hwnd before.
///
/// Pointer to an array of input scopes. May be NULL. If not NULL, all of the scopes contained within will be set as
/// the input scope of the hwnd with equal weighting. Use IS_DEFAULT to accept all other input as well (this is the "don’t coerce" option).
///
///
/// A count of the number of input scopes in pInputScopes. Must be zero if rgScopes is NULL, must be nonzero if pInputScopes
/// is non- NULL.
///
/// IenumString interface pointer of the phrase list.
///
/// Pointer to a NULL-terminated string describing the regular expression to be recognized. May be NULL.
///
///
/// Pointer to a NULL-terminated XML string that provides speech-specific hints and rules to aid in speech recognition. The
/// XML format conforms to the Speech Recognition Grammar Specification (SRGS) standard, outlined at
/// http://www.w3.org/TR/speech-grammar. Can be NULL. $
///
///
///
///
/// Value
/// Meaning
///
/// -
/// S_OK
/// The input scope set or cleared successfully.
///
///
///
///
/// The application must call SetInputScope with IS_DEFAULT before a window is destroyed to clear the reference of the interface.
///
/// If you call this method on a window (hwnd parameter) that has not been associated with a Document Manager, then no text service
/// notifications are sent to interested clients (such as the touch keyboard) that may want to respond to the scope change.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/inputscope/nf-inputscope-setinputscopes2 HRESULT SetInputScopes2( HWND hwnd,
// const InputScope *pInputScopes, UINT cInputScopes, IEnumString *pEnumString, PWSTR pszRegExp, PWSTR pszSRGS );
[DllImport(Lib_Msctf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("inputscope.h", MSDNShortId = "NF:inputscope.SetInputScopes2")]
public static extern HRESULT SetInputScopes2(HWND hwnd, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] InputScope[] pInputScopes, uint cInputScopes,
IEnumString pEnumString, [In, Optional, MarshalAs(UnmanagedType.LPWStr)] string pszRegExp, [In, Optional, MarshalAs(UnmanagedType.LPWStr)] string pszSRGS);
/// Do not use.
/// N/A
/// N/A
/// This function does not return a value.
// https://docs.microsoft.com/en-us/windows/win32/api/inputscope/nf-inputscope-setinputscopexml HRESULT SetInputScopeXML( HWND hwnd,
// PWSTR pszXML );
[DllImport(Lib_Msctf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("inputscope.h", MSDNShortId = "NF:inputscope.SetInputScopeXML")]
public static extern HRESULT SetInputScopeXML(HWND hwnd, [In, Optional, MarshalAs(UnmanagedType.LPWStr)] string pszXML);
}
}