diff --git a/NatlinkSource/DragonCode.cpp b/NatlinkSource/DragonCode.cpp index 90827fb..a06feeb 100644 --- a/NatlinkSource/DragonCode.cpp +++ b/NatlinkSource/DragonCode.cpp @@ -2003,40 +2003,19 @@ BOOL CDragonCode::playString( const char * pszKeys, DWORD dwFlags ) // OutputDebugStringA("ignoring input, just sending out `naïve'"); - int const inputCodePage = CP_UTF8; - int const outputCodePage = 1252; - - - //get a wide unicode string from the unicode string. Be better to change pytwrap to just give us - //unicode strings. - int size_needed = 10+ ::MultiByteToWideChar( inputCodePage, 0, pszKeys, -1, NULL, 0 ); - BSTR pszKeysW = new TCHAR[ size_needed ]; - memset(pszKeysW,0,(sizeof pszKeysW[0]*size_needed)); - - std::unique_ptr pdzKesWMem(pszKeysW); - - ::MultiByteToWideChar( inputCodePage, MB_PRECOMPOSED, pszKeys, -1, pszKeysW, size_needed ); - - //now convert to to single byte code page for windows - int mbSizeNeeded = 10+WideCharToMultiByte(outputCodePage,0,pszKeysW,-1,0,0,0,0); - char * mbString = new char[mbSizeNeeded]; - memset(mbString,0,sizeof mbString[0]*mbSizeNeeded); - std::unique_ptr mbPtr(mbString); - WideCharToMultiByte(outputCodePage,0,pszKeysW,-1,mbString,mbSizeNeeded,0,0); - - std::string msg1("Windows String: "); - msg1.append(mbString); - OutputDebugStringA(msg1.c_str()); - - // use the interface that takes char strings, not wide strings. - rc = m_pIDgnSSvcOutputEventA->PlayString( - mbString, // string to send + pszKeys, // string to send dwFlags, // flags 0xFFFFFFFF, // delay (-1 for app specific delay) dwClientCode, // to identify which WM_PLAYBACK is ours &dwNumUndo ); + int const inputCodePage = CP_UTF8; + int const outputCodePage = 1252; + + + + #else rc = m_pIDgnSSvcOutputEvent->PlayString( pszKeys, // string to send diff --git a/NatlinkSource/__init__.py b/NatlinkSource/__init__.py index 53cf690..fa5f5f1 100644 --- a/NatlinkSource/__init__.py +++ b/NatlinkSource/__init__.py @@ -10,18 +10,12 @@ def lmap(fn,iter): return list(map(fn,iter)) def playString(a): - print(f"wrapped playString {a}") - _playString(a) - print("returned from playString") + return _playString(toWindowsEncoding(a)) def execScript(script,args=[]): #only encode the script. can't find a single case of anyone using the args - script_w=toWindowsEncoding(script) - - print(f"Exec Scripts {script} args {args} windows encodings script {script_w} ") - _execScript(script_w,args) - print(f"returned from exec ") + return _execScript(script_w,args) def toWindowsEncoding(str_to_encode): return str_to_encode.encode('Windows-1252') diff --git a/NatlinkSource/pythwrap.cpp b/NatlinkSource/pythwrap.cpp index 68f2fa0..57178e4 100644 --- a/NatlinkSource/pythwrap.cpp +++ b/NatlinkSource/pythwrap.cpp @@ -382,9 +382,10 @@ natlink_waitForSpeech( PyObject *self, PyObject *args ) extern "C" static PyObject * natlink_playString( PyObject *self, PyObject *args ) { - char *pKeys; + char *pKeys=0; + int pkeysLen=0; DWORD dwFlags = 0; - if( !PyArg_ParseTuple( args, "s|i:playString", &pKeys, &dwFlags ) ) + if( !PyArg_ParseTuple( args, "s#|i:playString", &pKeys, &pkeysLen, &dwFlags ) ) { return NULL; } diff --git a/NatlinkSource/samples_for_interactive_debugging/displayText.py b/NatlinkSource/samples_for_interactive_debugging/displayText.py new file mode 100644 index 0000000..b1b614e --- /dev/null +++ b/NatlinkSource/samples_for_interactive_debugging/displayText.py @@ -0,0 +1,11 @@ +import natlink as n + +n.natConnect() +dis=n.natDisconnect +def bye(): + n.natDisconnect() + quit() + +d=n.displayText + +d("naïve brachialis",True,True) \ No newline at end of file diff --git a/NatlinkSource/samples_for_interactive_debugging/execScript.py b/NatlinkSource/samples_for_interactive_debugging/execScript.py index 9a2548c..1a9f8a9 100644 --- a/NatlinkSource/samples_for_interactive_debugging/execScript.py +++ b/NatlinkSource/samples_for_interactive_debugging/execScript.py @@ -7,5 +7,4 @@ def bye(): quit() e=n.execScript - e('SendKeys "naïve brachialis"') \ No newline at end of file diff --git a/NatlinkSource/samples_for_interactive_debugging/playString.py b/NatlinkSource/samples_for_interactive_debugging/playString.py index d22513f..ec4d96d 100644 --- a/NatlinkSource/samples_for_interactive_debugging/playString.py +++ b/NatlinkSource/samples_for_interactive_debugging/playString.py @@ -1,5 +1,9 @@ import natlink as n n.natConnect() -dis=n.natDisconnect +dis=n.natDisconnect +def bye(): + n.natDisconnect() + quit() p=n.playString + n.playString("naïve brachialis") \ No newline at end of file