Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

GUI i Config - Trzy skromne pytania


Rekomendowane odpowiedzi

Opublikowano

Witam.


 


 Piszę dość obszerny jak dla mnie skrypt i prosiłbym was o pomoc, bo jestem z lekka zielony w AutoIt.


 


Wcześniej trochę tłumaczyliście mi z IniConfig, ale niestety nie ogarnąłem tego, dlatego teraz proszę was o zaprezentowanie tego na poniższym kodzie.


 


Podam wam najprostszy kod z KODY:


 




#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 525, 97, 302, 218)
$Combo1 = GUICtrlCreateCombo("Combo1", 16, 8, 145, 25)
GUICtrlSetData(-1, "Pozycja1|Pozycja2|Pozycja3|Pozycja4")
$Button1 = GUICtrlCreateButton("Button1", 48, 40, 75, 25, $WS_GROUP)
$Input1 = GUICtrlCreateInput("Input1", 192, 8, 161, 21)
$Button2 = GUICtrlCreateButton("Button2", 240, 40, 75, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("Button3", 376, 8, 131, 25, $WS_GROUP)
$Button4 = GUICtrlCreateButton("Button4", 376, 48, 131, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd



1. Jaki kod użyć na czynność: Jeśli zostanie wybrana w Combo1 - Pozycja np. 2, to wyświetli mi się MsgBox z tekstem "Tak", a jeśli np. pozycja 3, tekst "Nie".


 


2. Czy jest jakiś sposób na wyczytywanie konkretnej literki z InPuta ? Jeśli mi pomożecie w tym pytaniu, uzyskam oszczędność aż 220 Inputów i CheckBoxów.


 


Podam przykład.


 


W InPut mamy wpisane np. exaMple


 


Jaki kod zastosować, by np. przy wykryciu w tekscie inputa literki M (już nawet nie istotna jest wielkość litery), wyświetlał mi się Msgbox z napisem "Tak".


 


3. Najtrudniejsze pytanie, które może jakieś kilka miesięcy temu zadawałem, ale nadal nie mogę je rozwiązać.


 


Jaki kod zastosować, by wszystkie inputy, checkboxy i combo zapisywały swoją wartość przez jeden button, a przez drugi po ponownym włączeniu skryptu wczytywały te wartości. 


 


 


Jeśli mógłbym was prosić, pomóżcie mi i podawajcie mi odpowiedzi na podstawie mojego kodu, byłbym na prawdę bardzo wdzięczny, bo zaoszczędzicie wiele mojego czasu.


 


Z góry dziękuje, pozdrawiam.


579571423327107377857.png


Opublikowano

1.

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

EndSwitch
Switch GUICtrlRead($hCombo)
      Case "Tak"
        msgbox(0,'','Tak')
      Case "NIE"
   msgbox(0,'','Nie')
   EndSwitch
WEnd

2.

$tekst = "exaMple"
If stringinstr($tekst,"M") Then
msgbox(0,'','Tak')

3.

Odczytanie to poprostu

Global $input1 = IniRead('settings.cfg', 'Dane', 'Input1', "") ; odczytanie wartosci
Global $Input = GUICtrlCreateInput($input1, 845, 9, 75, 25)

Zapis to bedzie

 Iniwrite('settings.cfg', 'Dane', 'Input1', GUICtrlRead($input))
Opublikowano
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 147, 101, 283, 259)
$Input1 = GUICtrlCreateInput("Input1", 16, 16, 121, 21)
$Button1 = GUICtrlCreateButton("Button1", 40, 56, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $Button1
   $tekst = "GUICtrlRead($Input1)"
   If stringinstr($tekst,"M") Then
   msgbox(0,'','Tak')
EndSwitch
WEnd

Coś ze Switch jest.. nie ogarniam.

579571423327107377857.png


Opublikowano
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 147, 101, 283, 259)
$Input1 = GUICtrlCreateInput("Input1", 16, 16, 121, 21)
$Button1 = GUICtrlCreateButton("Button1", 40, 56, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $Button1
   $tekst = GUICtrlRead($Input1)
   If stringinstr($tekst,"M") Then
   msgbox(0,'','Tak')
Endif
EndSwitch
WEnd

Skompilowal ci sie wogole tamten kod?

Opublikowano

Ok a mam pytanie, czy da się zastosować kilka If'ów w sobie ? Podam przykład:

If GUICtrlRead($Checkbox1) == $GUI_CHECKED Then
     $input = GUICtrlRead($Input1)
     If stringinstr($input, "1") Then
        Msgbox(0.''.'Tak')
     ElseIf
        MouseClick("left")
     If stringinstr($input, "2") Then
        Msgbox(0,'','Tak')
     ElseIf
        MouseClick("left")
     EndIf
EndIf
 

579571423327107377857.png


Opublikowano

 

Ok a mam pytanie, czy da się zastosować kilka If'ów w sobie ? Podam przykład:

If GUICtrlRead($Checkbox1) == $GUI_CHECKED Then
     $input = GUICtrlRead($Input1)
     If stringinstr($input, "1") Then
        Msgbox(0.''.'Tak')
     ElseIf
        MouseClick("left")
     If stringinstr($input, "2") Then
        Msgbox(0,'','Tak')
     ElseIf
        MouseClick("left")
     EndIf
EndIf
 

Nie lepiej sprawdzić samemu? Odpowiedź byś miał od razu.

Opublikowano
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 300, 146, 302, 218)
$Input1 = GUICtrlCreateInput("Input1", 104, 32, 121, 21)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 112, 56, 97, 17)
$Button1 = GUICtrlCreateButton("Button1", 112, 72, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $Button1
   If GUICtrlRead($Checkbox1) == $GUI_CHECKED Then
     $input = GUICtrlRead($Input1)
     If stringinstr($input, "1") Then
        Msgbox(0,'','Tak')
     Else
        Msgbox(0,'','Nie')
     If stringinstr($input, "2") Then
        Msgbox(0,'','Tak')
     Else
        Msgbox(0,'','Nie')
   Endif
	EndSwitch
WEnd

Takie coś i tak nie działa.

579571423327107377857.png


Opublikowano

To powinno być tak: 

   If GUICtrlRead($Checkbox1) == $GUI_CHECKED Then
     $input = GUICtrlRead($Input1)
	 EndIf
     If stringinstr($input, "1") Then
        Msgbox(0,'','Tak')
     ElseIf StringInStr($input, "2") Then
        Msgbox(0,'','Tak')

	Else

		MsgBox(0,"","Nie")

   Endif

A teraz poproszę like  :D

linki w górę

Opublikowano

 

Tak to powinno wygladac.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 300, 146, 302, 218)
$Input1 = GUICtrlCreateInput("Input1", 104, 32, 121, 21)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 112, 56, 97, 17)
$Button1 = GUICtrlCreateButton("Button1", 112, 72, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $Button1
   If GUICtrlRead($Checkbox1) == $GUI_CHECKED Then
     $input = GUICtrlRead($Input1)
     If stringinstr($input, "1") Then
        Msgbox(0,'','Tak')
     Else
        Msgbox(0,'','Nie')
endif
     If stringinstr($input, "2") Then
        Msgbox(0,'','Tak')
     Else
        Msgbox(0,'','Nie')
   Endif
	EndSwitch
WEnd
Opublikowano

@IZZER4 nie ma to jak dać niekompilujący się kod z błędem i powiedzieć "Tak to powinno wygladac.". Prawidłowo jest tak:

 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 300, 146, 302, 218)
$Input1 = GUICtrlCreateInput("Input1", 104, 32, 121, 21)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 112, 56, 97, 17)
$Button1 = GUICtrlCreateButton("Button1", 112, 72, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $Button1

			If GUICtrlRead($Checkbox1) == $GUI_CHECKED Then
				$input = GUICtrlRead($Input1)

				If stringinstr($input, "1") Then
					Msgbox(0,'','Tak')
				Else
					Msgbox(0,'','Nie')
				EndIf

				If stringinstr($input, "2") Then
					Msgbox(0,'','Tak')
				Else
					Msgbox(0,'','Nie')
				Endif

			EndIf

	EndSwitch
WEnd

 

 

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...