Показать полную графическую версию : [решено] Не работает GUISetAccelerators
Centrinar
24-03-2011, 22:34
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region Main form
$hMain_GUI = GUICreate("Главное окно", 300, 200)
$nStngs_Btn = GUICtrlCreateButton("Настройки", 10, 170, 70, 20)
$nExit_Btn = GUICtrlCreateButton("Выход", 90, 170, 70, 20)
GUISetState(@SW_SHOW, $hMain_GUI)
#EndRegion Main form
#Region Settings form
$hStngs_GUI = GUICreate("Настройки", 400, 200)
$nStngs_Ok_Btn = GUICtrlCreateButton("ОК", 10, 170, 80, 25)
$nStngs_Close_Btn = GUICtrlCreateButton("Закрыть", 310, 170, 80, 25)
#EndRegion Settings form
Dim $AccelKeys[2][2]=[["{F5}", $nStngs_Btn], ["^n", $nStngs_Btn]]
GUISetAccelerators($AccelKeys)
While 1
$aMsg = GUIGetMsg(1) ;Расширенная обработка событий
Switch $aMsg[0]
Case $GUI_EVENT_CLOSE, $nExit_Btn, $nStngs_Close_Btn
Switch $aMsg[1]
Case $hMain_GUI ;Событие поступило от главного окна - завершаем работу скрипта
Exit
Case $hStngs_GUI ;Событие поступило от окна настроек - закрываем его
GUISetState(@SW_HIDE, $hStngs_GUI)
EndSwitch
Case $nStngs_Btn
GUISetState(@SW_SHOW, $hStngs_GUI)
EndSwitch
WEnd
Где ошибка?
madmasles
24-03-2011, 23:01
Centrinar,
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <GUIConstantsEx.au3>
#region Main form
$hMain_GUI = GUICreate (http://www.autoitscript.com/autoit3/docs/functions/GUICreate.htm)("Главное окно", 300, 200)
$nStngs_Btn = GUICtrlCreateButton (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateButton.htm)("Настройки", 10, 170, 70, 20)
$nExit_Btn = GUICtrlCreateButton (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateButton.htm)("Выход", 90, 170, 70, 20)
GUISetState (http://www.autoitscript.com/autoit3/docs/functions/GUISetState.htm)(@SW_SHOW (http://www.autoitscript.com/autoit3/docs/macros.htm#@sw_show), $hMain_GUI)
#endregion Main form
Dim (http://www.autoitscript.com/autoit3/docs/keywords.htm#Dim) $AccelKeys[3][2] = [["{F5}", $nStngs_Btn],["^n", $nStngs_Btn],['^т', $nStngs_Btn]]
GUISetAccelerators (http://www.autoitscript.com/autoit3/docs/functions/GUISetAccelerators.htm)($AccelKeys)
#region Settings form
$hStngs_GUI = GUICreate (http://www.autoitscript.com/autoit3/docs/functions/GUICreate.htm)("Настройки", 400, 200)
$nStngs_Ok_Btn = GUICtrlCreateButton (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateButton.htm)("ОК", 10, 170, 80, 25)
$nStngs_Close_Btn = GUICtrlCreateButton (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateButton.htm)("Закрыть", 310, 170, 80, 25)
#endregion Settings form
While (http://www.autoitscript.com/autoit3/docs/keywords.htm#While) 1
$aMsg = GUIGetMsg (http://www.autoitscript.com/autoit3/docs/functions/GUIGetMsg.htm)(1)
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $aMsg[1]
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $hMain_GUI
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $aMsg[0]
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $GUI_EVENT_CLOSE, $nExit_Btn
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $nStngs_Btn
GUISetState (http://www.autoitscript.com/autoit3/docs/functions/GUISetState.htm)(@SW_SHOW (http://www.autoitscript.com/autoit3/docs/macros.htm#@sw_show), $hStngs_GUI)
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $hStngs_GUI
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $aMsg[0]
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $GUI_EVENT_CLOSE, $nStngs_Close_Btn
GUISetState (http://www.autoitscript.com/autoit3/docs/functions/GUISetState.htm)(@SW_HIDE (http://www.autoitscript.com/autoit3/docs/macros.htm#@sw_hide), $hStngs_GUI)
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
WEnd (http://www.autoitscript.com/autoit3/docs/keywords.htm#WEnd)
Мда... у меня ушло минут 10 на то чтобы найти, что там исправлено в версий от madmasles :gigi:, а что уже говорить о новичках которые заглянут в эту тему.
Решение: указать второй параметр в функций GUISetAccelerators($AccelKeys, $hMain_GUI).
P.S
madmasles, если помните, решение проблемы с раскладкой клавиатуры есть тут (http://forum.ru-board.com/topic.cgi?forum=5&topic=33902&start=780#16) ;).
madmasles
25-03-2011, 06:42
Creat0R,
С учетом Ваших замечаний:#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <GUIConstantsEx.au3>
ConsoleWrite (http://www.autoitscript.com/autoit3/docs/functions/ConsoleWrite.htm)(_WinAPI_LoadKeyboardLayout_CreatoR(0x0409) & @CR (http://www.autoitscript.com/autoit3/docs/macros.htm#@cr))
#region Main form
$hMain_GUI = GUICreate (http://www.autoitscript.com/autoit3/docs/functions/GUICreate.htm)("Главное окно", 300, 200)
$nStngs_Btn = GUICtrlCreateButton (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateButton.htm)("Настройки", 10, 170, 70, 20)
$nExit_Btn = GUICtrlCreateButton (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateButton.htm)("Выход", 90, 170, 70, 20)
GUISetState (http://www.autoitscript.com/autoit3/docs/functions/GUISetState.htm)(@SW_SHOW (http://www.autoitscript.com/autoit3/docs/macros.htm#@sw_show), $hMain_GUI)
#endregion Main form
#region Settings form
$hStngs_GUI = GUICreate (http://www.autoitscript.com/autoit3/docs/functions/GUICreate.htm)("Настройки", 400, 200)
$nStngs_Ok_Btn = GUICtrlCreateButton (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateButton.htm)("ОК", 10, 170, 80, 25)
$nStngs_Close_Btn = GUICtrlCreateButton (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateButton.htm)("Закрыть", 310, 170, 80, 25)
#endregion Settings form
Dim (http://www.autoitscript.com/autoit3/docs/keywords.htm#Dim) $AccelKeys[2][2] = [["{F5}", $nStngs_Btn],["^n", $nStngs_Btn]]
GUISetAccelerators (http://www.autoitscript.com/autoit3/docs/functions/GUISetAccelerators.htm)($AccelKeys, $hMain_GUI)
While (http://www.autoitscript.com/autoit3/docs/keywords.htm#While) 1
$aMsg = GUIGetMsg (http://www.autoitscript.com/autoit3/docs/functions/GUIGetMsg.htm)(1)
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $aMsg[1]
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $hMain_GUI
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $aMsg[0]
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $GUI_EVENT_CLOSE, $nExit_Btn
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $nStngs_Btn
GUISetState (http://www.autoitscript.com/autoit3/docs/functions/GUISetState.htm)(@SW_SHOW (http://www.autoitscript.com/autoit3/docs/macros.htm#@sw_show), $hStngs_GUI)
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $hStngs_GUI
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $aMsg[0]
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $GUI_EVENT_CLOSE, $nStngs_Close_Btn
GUISetState (http://www.autoitscript.com/autoit3/docs/functions/GUISetState.htm)(@SW_HIDE (http://www.autoitscript.com/autoit3/docs/macros.htm#@sw_hide), $hStngs_GUI)
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
WEnd (http://www.autoitscript.com/autoit3/docs/keywords.htm#WEnd)
Func (http://www.autoitscript.com/autoit3/docs/keywords.htm#Func) _WinAPI_LoadKeyboardLayout_CreatoR($sLayoutID, $hWnd = 0)
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) Const (http://www.autoitscript.com/autoit3/docs/keywords.htm#Const) $WM_INPUTLANGCHANGEREQUEST = 0x50
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $aRet = DllCall (http://www.autoitscript.com/autoit3/docs/functions/DllCall.htm)("user32.dll", "long", "LoadKeyboardLayoutW", "wstr", Hex (http://www.autoitscript.com/autoit3/docs/functions/Hex.htm)($sLayoutID, 8), "int", 0)
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) Not (http://www.autoitscript.com/autoit3/docs/keywords.htm#Not) @error (http://www.autoitscript.com/autoit3/docs/macros.htm#@error) And (http://www.autoitscript.com/autoit3/docs/keywords.htm#And) $aRet[0] Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $hWnd = 0 Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
$hWnd = WinGetHandle (http://www.autoitscript.com/autoit3/docs/functions/WinGetHandle.htm)(AutoItWinGetTitle (http://www.autoitscript.com/autoit3/docs/functions/AutoItWinGetTitle.htm)())
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
DllCall (http://www.autoitscript.com/autoit3/docs/functions/DllCall.htm)("user32.dll", "ptr", "SendMessage", "hwnd", $hWnd, "int", $WM_INPUTLANGCHANGEREQUEST, "int", 1, "int", $aRet[0])
Return (http://www.autoitscript.com/autoit3/docs/keywords.htm#Return) 1
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
Return (http://www.autoitscript.com/autoit3/docs/keywords.htm#Return) SetError (http://www.autoitscript.com/autoit3/docs/functions/SetError.htm)(1)
EndFunc (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndFunc) ;==>_WinAPI_LoadKeyboardLayout_Creat0R
Мда... у меня ушло минут 10 на то чтобы найти, что там исправлено в версий от madmasles , а что уже говорить о новичках которые заглянут в эту тему. »
Creat0R, Вы WinMerge (http://ru.wikipedia.org/wiki/Winmerge) не пользуете для сравнения? Достаточно удобно. Или я совсем неправильно понял?
Вы WinMerge не пользуете для сравнения? Достаточно удобно. »
Я обычно использую Pspad, но тут мелочь, думал глазами найду. Но суть не в этом.
© OSzone.net 2001-2012
vBulletin v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.
Available in ZeroNet 1osznRoVratMCN3bFoFpR2pSV5c9z6sTC