Jump to content

Recommended Posts

Posted

Hi everybody,

should anyone help me converting this vb code to vlisp?

 
Public Declare Function LoadKeyboardLayout Lib "user32" Alias "LoadKeyboardLayoutA" (ByVal pwszKLID As String, ByVal Flags As Long) As Long
  LoadKeyboardLayout "00000409", 1
End Function

 

any help is greatly appreciated

Posted

This appears to set a specific keyboard layout current, perhaps for use of specifying a language (Arabic?). From MSDN:

 

 

Loads a new input locale identifier (formerly called the keyboard layout) into the system. Several input locale identifiers can be loaded at a time, but only one per process is active at a time. Loading multiple input locale identifiers makes it possible to rapidly switch between them.

 

...

 

Source: http://msdn.microsoft.com/en-us/library/windows/desktop/ms646305%28v=vs.85%29.aspx

 

HTH

Posted (edited)

Thank you RenderMan for your offer,

but I want to invoke this VB command inside my Visual Lisp code and don't know which external object should be invoked:cry::?:

Edited by Ahankhah
Posted

Finally, I find out the syntax :D:

(vl-load-com)
(defun C:English ()
(vlax-invoke
 (vlax-create-object "WScript.Shell")
 "run"
 "rundll32.exe user32.dll,LoadKeyboardLayout 00000409 1"
)
)
(defun C:Persian ()
(vlax-invoke
 (vlax-create-object "WScript.Shell")
 "run"
 "rundll32.exe user32.dll,LoadKeyboardLayout 00000429 1"
)
)

 

But, althogh there is no error messages , windows does nothing. :shock:

 

Who knows why? :?

Posted

Ahankhah - One must vlax-release-object when accessing external objects in order to prevent catastrophic, sometimes even fatal, errors. Perhaps this is just my preference, but I also choose to use vlax-get-or-create-object instead, so as to obtain the existing object (if one exists) rather than always creating a new instance of said object.

 

Should there be a space after "user32.dll,"...? :unsure:

Posted (edited)
Ahankhah - One must vlax-release-object when accessing external objects in order to prevent catastrophic, sometimes even fatal, errors. Perhaps this is just my preference, but I also choose to use vlax-get-or-create-object instead, so as to obtain the existing object (if one exists) rather than always creating a new instance of said object.

 

RenderMan, you are right and I thank you for your hint :D.

So the code should be replaced by this one:

(vl-load-com)
(defun ChangeLanguage (lang / shell)
(setq shell (vlax-get-or-create-object "WScript.Shell"))
(vlax-invoke
 shell
 "run"
 (strcat "rundll32.exe user32.dll, LoadKeyboardLayout " lang " 1")
)
(vlax-release-object shell)
)
(defun C:Persian ()
(ChangeLanguage "00000429")
)
(defun C:English ()
(ChangeLanguage "00000409")
)

Should there be a space after "user32.dll,"...? :unsure:

Unfortunately not any result yet :cry:.

Edited by Ahankhah
Edited code according to Renderman's error trapping
Posted

The shell string runs for me (without the space)... but it causes an error in the "Multi-user USER DLL ..." which cannot be good. :(

Posted

Renderman,

1- I edited the code to cover your correction.

2- I ran it in AutoCAD and get the error message showing:

An exception occured while trying to run "rundll32.exe user32.dll, LoadKeyboardLayout 00000429 1"

while when issuing the following in the Window's Run edit box (Start->Run...) this way:

rundll32.exe user32.dll LoadKeyboardLayout "00000409" 1

there is no error message, and also not any desired result...:x

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...