How to send press hotkey to max?

I want to send press Ctrl+Backspace via maxscript but not works, please help.

--create test object
select (convertToPoly (sphere())); subobjectlevel=2
$.EditablePoly.SetSelection #Edge #{34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64}
 
--Function for send hotkey to max
fn SendKeys_fn sysKey = 
(
	desktopChildren = windows.getChildrenHWND (windows.getDesktopHWND())
	--for i in desktopChildren do format "%\n" i
	max_hwnd=for i in desktopChildren where (i[4] == "3DSMAX") do (exit with i[1])
	WM_ACTIVATE = 0x6
 	Windows.sendMessage max_hwnd WM_ACTIVATE max_hwnd 0
	SendKeys = dotNetClass "System.Windows.Forms.SendKeys"
	SendKeys.SendWait sysKey
)
SendKeys_fn "^{BACKSPACE}" -- send Ctrl+Backspace

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Nik's picture

Solution found!

 
fn sendkeys_CtrlRemove_fn=(
vbs_Fpath = (GetDir #scripts) + "\\sendkeys.vbs"
if not doesFileExist vbs_Fpath 
then (
	f = createFile vbs_Fpath
	format "'***************************************\n' wscript shell sendkeys\n' send.vbs\n'***************************************\nOption Explicit\nDim WshShell\nSet WshShell = WScript.CreateObject(\"WScript.Shell\")\nWshShell.SendKeys(\"^{BS}\")" to:f
	close f
	shellLaunch "explorer.exe" vbs_Fpath) 
else shellLaunch "explorer.exe" vbs_Fpath
)
fn CtrlRemove_fn=(
	--for i in desktopChildren do format "%\n" i
	max_hwnd=for i in (windows.getChildrenHWND (windows.getDesktopHWND())) where (i[4] == "3DSMAX") do (exit with i[1])
	WM_ACTIVATE = 0x6
 	Windows.sendMessage max_hwnd WM_ACTIVATE max_hwnd 0
	sendkeys_CtrlRemove_fn()
)
CtrlRemove_fn()

Source: http://scriptcoding.ru/2013/06/25/wscript-shell-sendkeys/

Nik's picture

Forums.cgsociety This

Forums.cgsociety This same problem

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.