Что нового

Ошибки в расширенном использовании GUIGetMsg

lexaSF

Новичок
Сообщения
182
Репутация
3
помогите сколько не пробовал все равно выдает ошибку
Код:
#include <GUIConstants.au3>
#region
#AutoIt3Wrapper_Icon=C:\Users\Lexa\Desktop\im.ico
#AutoIt3Wrapper_res_icon_add=C:\Users\Lexa\Desktop\zhek.ico
#endregion

#Region ### START Koda GUI section ### Form=c:\users\lexa\desktop\avtostartbot.kxf
$Form1_1 = GUICreate("AvtoStart Accounts", 253, 156, 694, 553)
GUISetIcon("C:\Users\Lexa\Desktop\im.ico")
$ListBox1 = GUICtrlCreateList("", 24, 16, 113, 97)
GUICtrlSetData(-1, "Item1|Item2|Item3|Item4|Item5")
$Button5 = GUICtrlCreateButton("&Add", 152, 15, 75, 25, 0)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
$Button1 = GUICtrlCreateButton("&Edit", 152, 51, 75, 25, 0)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
$Button2 = GUICtrlCreateButton("&Delete", 152, 89, 75, 25, 0)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
$Button3 = GUICtrlCreateButton("&START!", 85, 125, 75, 25, 0)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
$Group1 = GUICtrlCreateGroup("", 10, 0, 233, 121)
GUICtrlSetFont(-1, 8, 800, 0, "Palatino Linotype")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label11 = GUICtrlCreateLabel("Create ToSTeP", 183, 140, 70, 18)
GUICtrlSetFont(-1, 7, 800, 0, "Palatino Linotype")
$Label1 = GUICtrlCreateLabel("Zhyk.ru", 32, 141, 42, 20)
GUICtrlSetFont(-1, 8, 800, 0, "Palatino Linotype")
$Icon1 = GUICtrlCreateIcon("", 0, 5, 128, 24, 24)
GUICtrlSetImage($Icon1, @ScriptFullPath, 201)
GUISetState(@SW_SHOW)
$tray = TraySetIcon("")
GUICtrlSetImage($tray, @ScriptFullPath, 201)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg(1)
Select
	Case $nMsg[0] = $Button5
	$Form2 = GUICreate("Choosen Dialog", 230, 117, 714, 491)
$Group_2_1 = GUICtrlCreateGroup("", 18, 16, 193, 65)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
$Radio_2_1 = GUICtrlCreateRadio("Input on SID", 26, 32, 169, 17)
$Radio_2_2 = GUICtrlCreateRadio("Input on Login", 26, 56, 169, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label_2_1 = GUICtrlCreateLabel("Choose your type of start", 24, 0, 155, 22)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
$Button2_1 = GUICtrlCreateButton("OK", 64, 88, 97, 25, 0)
GUISetState(@SW_SHOW)
Case $nMsg[0] = $GUI_EVENT_CLOSE
	If $nMsg[1] = $Form1_1 Then
		Exit
	ElseIf $nMsg[1] = $Form2 Then
		GUISwitch($Form2)
		GUIDelete()
	EndIf
EndSelect
$Exist = WinExists('Choosen Dialog','')
Switch $Exist
Case 1
	Select
	Case $nMsg[0] = $Button2_1
	GUISwitch($Form2)
	GUIDelete()
EndSelect
EndSwitch
WEnd
 

Viktor217

Осваивающий
Сообщения
233
Репутация
31
Re: ошибка в коде

Тебе явно табличку выдадут...
Ты хотябы текст ошибки выложи под тегом "код"
 

Yashied

Модератор
Команда форума
Глобальный модератор
Сообщения
5,379
Репутация
2,724
Re: ошибка в коде

{TopicNameWarn.SModer}
 

CreatoR

Must AutoIt!
Команда форума
Администратор
Сообщения
8,673
Репутация
2,486
Re: ошибка в коде

OffTopic:
Yashied
Я думаю предупреждений уже было предостаточно, пора применять меры :whistle:.
 

Yashied

Модератор
Команда форума
Глобальный модератор
Сообщения
5,379
Репутация
2,724
Re: ошибка в коде

OffTopic:
CreatoR

Пусть это будет последнее из последних. Затем бан по методу Random()...

:smile:
 
Автор
L

lexaSF

Новичок
Сообщения
182
Репутация
3
попробовал по другому, но теперь WinExist всегда выдает 1, даже если окна нет
Код:
#include <GUIConstants.au3>
#region
#AutoIt3Wrapper_Icon=C:\Users\Lexa\Desktop\im.ico
#AutoIt3Wrapper_res_icon_add=C:\Users\Lexa\Desktop\zhek.ico
#endregion

#Region ### START Koda GUI section ### Form=c:\users\lexa\desktop\avtostartbot.kxf
$Form1_1 = GUICreate("AvtoStart Accounts", 253, 156, 694, 553)
GUISetIcon("C:\Users\Lexa\Desktop\im.ico")
$ListBox1 = GUICtrlCreateList("", 24, 16, 113, 97)
GUICtrlSetData(-1, "Item1|Item2|Item3|Item4|Item5")
$Button5 = GUICtrlCreateButton("&Add", 152, 15, 75, 25, 0)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
$Button1 = GUICtrlCreateButton("&Edit", 152, 51, 75, 25, 0)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
$Button2 = GUICtrlCreateButton("&Delete", 152, 89, 75, 25, 0)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
$Button3 = GUICtrlCreateButton("&START!", 85, 125, 75, 25, 0)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
$Group1 = GUICtrlCreateGroup("", 10, 0, 233, 121)
GUICtrlSetFont(-1, 8, 800, 0, "Palatino Linotype")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label11 = GUICtrlCreateLabel("Create ToSTeP", 183, 140, 70, 18)
GUICtrlSetFont(-1, 7, 800, 0, "Palatino Linotype")
$Label1 = GUICtrlCreateLabel("Zhyk.ru", 32, 141, 42, 20)
GUICtrlSetFont(-1, 8, 800, 0, "Palatino Linotype")
$Icon1 = GUICtrlCreateIcon("", 0, 5, 128, 24, 24)
GUICtrlSetImage($Icon1, @ScriptFullPath, 201)
GUISetState(@SW_SHOW)
$tray = TraySetIcon("")
GUICtrlSetImage($tray, @ScriptFullPath, 201)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg(1)
Select
	Case $nMsg[0] = $Button5
$Form2 = GUICreate("Choosen Dialog", 230, 117, 272, 186)
$Group_2_2 = GUICtrlCreateGroup("", 18, 16, 193, 65)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
$Radio_2_1 = GUICtrlCreateRadio("Input on SID", 26, 32, 169, 17)
$Radio_2_2 = GUICtrlCreateRadio("Input on Login", 26, 56, 169, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label_2_1 = GUICtrlCreateLabel("Choose your type of start", 24, 0, 155, 22)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
$Button_2_1 = GUICtrlCreateButton("Cancel", 123, 88, 89, 25, 0)
GUICtrlSetFont(-1, 8, 800, 0, "Palatino Linotype")
$Button_2_2 = GUICtrlCreateButton("OK", 16, 88, 89, 25, 0)
GUICtrlSetFont(-1, 8, 800, 0, "Palatino Linotype")
GUISetState(@SW_SHOW)
Case $nMsg[0] = $GUI_EVENT_CLOSE
	If $nMsg[1] = $Form1_1 Then
		Exit
	ElseIf $nMsg[1] = $Form2 Then
		GUISwitch($Form2)
		GUIDelete()
	EndIf
EndSelect
Opt('WinTitleMatchMode',3)
$Exist = WinExists('Choosen Dialog','Choose your type of start')
MsgBox(0,'',$Exist)
If $Exist = 1 Then
$nMsg = GUIGetMsg()
MsgBox(0,'',$Exist)
	Switch $nMsg
	Case $Button_2_2
		MsgBox(0,'','rr')
		If GUICtrlRead($Radio_2_1) = $GUI_UNCHECKED And GUICtrlRead($Radio_2_2) = $GUI_UNCHECKED Then
			MsgBox(0,'ERROR','Choose your start type!')
		Else
	        GUISwitch($Form2)
	        GUIDelete()
		EndIf
	Case $Button_2_1
			GUISwitch($Form2)
	        GUIDelete()
		EndSwitch
	EndIf
WEnd
 

Yashied

Модератор
Команда форума
Глобальный модератор
Сообщения
5,379
Репутация
2,724
Если нет необходимости одновременной работы двух GUI, то второе GUI нужно оформлять в виде отдельной функции.

Код:
#Region
#AutoIt3Wrapper_Icon=C:\Users\Lexa\Desktop\im.ico
#AutoIt3Wrapper_Res_Icon_Add=C:\Users\Lexa\Desktop\zhek.ico
#EndRegion

#NoTrayIcon

#Include <GUIConstantsEx.au3>

$Form1_1 = GUICreate("AvtoStart Accounts", 253, 156, 694, 553)
$ListBox1 = GUICtrlCreateList("", 24, 16, 113, 97)
GUICtrlSetData(-1, "Item1|Item2|Item3|Item4|Item5")
$Button5 = GUICtrlCreateButton("&Add", 152, 15, 75, 25, 0)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
$Button1 = GUICtrlCreateButton("&Edit", 152, 51, 75, 25, 0)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
$Button2 = GUICtrlCreateButton("&Delete", 152, 89, 75, 25, 0)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
$Button3 = GUICtrlCreateButton("&START!", 85, 125, 75, 25, 0)
GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
$Group1 = GUICtrlCreateGroup("", 10, 0, 233, 121)
GUICtrlSetFont(-1, 8, 800, 0, "Palatino Linotype")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label11 = GUICtrlCreateLabel("Create ToSTeP", 183, 140, 70, 18)
GUICtrlSetFont(-1, 7, 800, 0, "Palatino Linotype")
$Label1 = GUICtrlCreateLabel("Zhyk.ru", 32, 141, 42, 20)
GUICtrlSetFont(-1, 8, 800, 0, "Palatino Linotype")
$Icon1 = GUICtrlCreateIcon(@ScriptFullPath, -5, 5, 128, 24, 24)
TraySetIcon(@ScriptFullPath, -5)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete($Form1_1)
            Exit
        Case $Button5
            Switch _ChoosenDlg($Form1_1)
				Case 0
					MsgBox(0, "Result: 0", "You close the Choosen Dialog window.", 0, $Form1_1)
				Case 1
					MsgBox(0, "Result: 1", "You have chosen a SID.", 0, $Form1_1)
				Case 2
					MsgBox(0, "Result: 2", "You have chosen a Login.", 0, $Form1_1)
			EndSwitch
    EndSwitch
WEnd

Func _ChoosenDlg($hParent = 0)

    Local $Form2, $Button_2_1, $Button_2_2, $Group_2_2, $Label_2_1, $Radio_2_1, $Radio_2_2
    Local $Result = 0

    GUISetState(@SW_DISABLE, $hParent)

    $Form2 = GUICreate("Choosen Dialog", 230, 117, 272, 186, -1, -1, $hParent)
    $Group_2_2 = GUICtrlCreateGroup("", 18, 16, 193, 65)
    GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
    $Radio_2_1 = GUICtrlCreateRadio("Input on SID", 26, 32, 169, 17)
    GUICtrlSetState(-1, $GUI_CHECKED)
    $Radio_2_2 = GUICtrlCreateRadio("Input on Login", 26, 56, 169, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Label_2_1 = GUICtrlCreateLabel("Choose your type of start", 24, 0, 155, 22)
    GUICtrlSetFont(-1, 10, 800, 0, "Palatino Linotype")
    $Button_2_1 = GUICtrlCreateButton("Cancel", 123, 88, 89, 25, 0)
    GUICtrlSetFont(-1, 8, 800, 0, "Palatino Linotype")
    $Button_2_2 = GUICtrlCreateButton("OK", 16, 88, 89, 25, 0)
    GUICtrlSetFont(-1, 8, 800, 0, "Palatino Linotype")
    GUISetState()

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $Button_2_1
                ExitLoop
            Case $Button_2_2
                If GUICtrlRead($Radio_2_1) = $GUI_CHECKED Then
                    $Result = 1
                Else
                    $Result = 2
                EndIf
                ExitLoop
        EndSwitch
    WEnd

    GUISetState(@SW_ENABLE, $hParent)
    GUIDelete($Form2)

    Return $Result
EndFunc   ;==>_ChoosenDlg
 
Верх