[pywin32-checkins] pywin32/win32/src win32apimodule.cpp, 1.103, 1.104
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2010-10-28 01:49:42
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv17116/win32/src Modified Files: win32apimodule.cpp Log Message: make VkKeyScan and VkKeyScanEx unicode friendly Index: win32apimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v retrieving revision 1.103 retrieving revision 1.104 diff -C2 -d -r1.103 -r1.104 *** win32apimodule.cpp 30 Aug 2010 02:44:17 -0000 1.103 --- win32apimodule.cpp 28 Oct 2010 01:49:32 -0000 1.104 *************** *** 1484,1500 **** } ! // @pymethod int|win32api|VkKeyScan|Translates a character to the corresponding virtual-key code and shift state. static PyObject * PyVkKeyScan(PyObject * self, PyObject * args) { ! char key; // @pyparm chr|char||Specifies a character ! if (!PyArg_ParseTuple(args, "c:VkKeyScan", &key)) return (NULL); int ret; ! PyW32_BEGIN_ALLOW_THREADS ! // @pyseeapi VkKeyScan ! ret = VkKeyScan(key); ! PyW32_END_ALLOW_THREADS return PyInt_FromLong(ret); } --- 1484,1521 ---- } ! // @pymethod int|win32api|VkKeyScan|Translates a character to the corresponding virtual-key code and shift state. ! // @pyparm string or unicode|char||A byte or unicode string of length 1. If a byte string is passed ! // VkKeyScanA will be called, otherwise VkKeyScanW will be called. static PyObject * PyVkKeyScan(PyObject * self, PyObject * args) { ! PyObject *obkey; // @pyparm chr|char||Specifies a character ! if (!PyArg_ParseTuple(args, "O:VkKeyScan", &obkey)) return (NULL); + int ret; ! if (PyString_Check(obkey)) { ! if (PyString_GET_SIZE(obkey) != 1) { ! PyErr_SetString(PyExc_TypeError, "must be a byte string of length 1"); ! return NULL; ! } ! PyW32_BEGIN_ALLOW_THREADS ! // @pyseeapi VkKeyScanA ! ret = VkKeyScanA(PyString_AS_STRING(obkey)[0]); ! PyW32_END_ALLOW_THREADS ! } else if (PyUnicode_Check(obkey)) { ! if (PyUnicode_GET_SIZE(obkey) != 1) { ! PyErr_SetString(PyExc_TypeError, "must be a unicode string of length 1"); ! return NULL; ! } ! PyW32_BEGIN_ALLOW_THREADS ! // @pyseeapi VkKeyScanW ! ret = VkKeyScanW(PyUnicode_AS_UNICODE(obkey)[0]); ! PyW32_END_ALLOW_THREADS ! } else { ! PyErr_SetString(PyExc_TypeError, "must be a unicode or byte string of length 1"); ! return NULL; ! } return PyInt_FromLong(ret); } *************** *** 1504,1521 **** PyVkKeyScanEx(PyObject * self, PyObject * args) { ! char key; HKL hkl; PyObject *obhkl; ! if (!PyArg_ParseTuple(args, "cO:VkKeyScanEx", ! &key, // @pyparm chr|char||Specifies a character &obhkl)) // @pyparm <o PyHANDLE>|hkl||Handle to a keyboard layout at returned by <om win32api.LoadKeyboardLayout> return (NULL); if (!PyWinObject_AsHANDLE(obhkl, (HANDLE *)&hkl)) return NULL; int ret; ! PyW32_BEGIN_ALLOW_THREADS ! // @pyseeapi VkKeyScanEx ! ret = VkKeyScanEx(key, hkl); ! PyW32_END_ALLOW_THREADS return PyInt_FromLong(ret); } --- 1525,1562 ---- PyVkKeyScanEx(PyObject * self, PyObject * args) { ! PyObject *obkey; HKL hkl; PyObject *obhkl; ! if (!PyArg_ParseTuple(args, "OO:VkKeyScanEx", ! &obkey, // @pyparm string or unicode|char||A byte or unicode string of length 1. If a byte string is passed ! // VkKeyScanExA will be called, otherwise VkKeyScanExW will be called. &obhkl)) // @pyparm <o PyHANDLE>|hkl||Handle to a keyboard layout at returned by <om win32api.LoadKeyboardLayout> return (NULL); if (!PyWinObject_AsHANDLE(obhkl, (HANDLE *)&hkl)) return NULL; + int ret; ! if (PyString_Check(obkey)) { ! if (PyString_GET_SIZE(obkey) != 1) { ! PyErr_SetString(PyExc_TypeError, "must be a byte string of length 1"); ! return NULL; ! } ! PyW32_BEGIN_ALLOW_THREADS ! // @pyseeapi VkKeyScanExA ! ret = VkKeyScanExA(PyString_AS_STRING(obkey)[0], hkl); ! PyW32_END_ALLOW_THREADS ! } else if (PyUnicode_Check(obkey)) { ! if (PyUnicode_GET_SIZE(obkey) != 1) { ! PyErr_SetString(PyExc_TypeError, "must be a unicode string of length 1"); ! return NULL; ! } ! PyW32_BEGIN_ALLOW_THREADS ! // @pyseeapi VkKeyScanExW ! ret = VkKeyScanExW(PyUnicode_AS_UNICODE(obkey)[0], hkl); ! PyW32_END_ALLOW_THREADS ! } else { ! PyErr_SetString(PyExc_TypeError, "must be a unicode or byte string of length 1"); ! return NULL; ! } return PyInt_FromLong(ret); } |