Jump to content

Butonla Input Temizleme


monika
 Share

Recommended Posts

@kadiraybar AutoIT bölümündeyiz.!

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 633, 447, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 88, 32, 169, 49, $WS_GROUP)
$Input1 = GUICtrlCreateInput("Input1", 96, 128, 273, 21)
GUISetState(@SW_SHOW)


While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Button1
			GUICtrlSetData($Input1, "")
	EndSwitch
WEnd

Link to comment
Share on other sites

Tam olarak ne demek istiyorsun. Inputtaki yazıyımı okuyup almak istiyorsun? Eğer öyleyse GUICtrlRead kullanacaksın...

Biraz daha net anlatmalısın...

$Form1 = GUICreate("Form1", 633, 447, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 88, 32, 169, 49)
$Input1 = GUICtrlCreateInput("Input1", 96, 128, 273, 21)
GUISetState(@SW_SHOW)
While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case -3
			Exit
		Case $Button1
			MsgBox(64,"",GUICtrlRead($Input1))
			GUICtrlSetData($Input1, "")
	EndSwitch
WEnd

Link to comment
Share on other sites

yok hepsini sadece 1 de siralayacak sonra ben o yaziyi silip baska bisi yazdigimda ekle dedigimde 2.ye yazacak

ornegin "boyle bir hata var" diye yazdim inputa ekle dedigimde

1 boyle bi hata var

yazacak "boyle bir hata var "yazsini inputtan silip 'baska bisi" yazdim ve ekle dedim bunuda

2 baska bisi

bu sekilde

Link to comment
Share on other sites

@monika

Aşağıdaki gibi bir şeymi istiyorsun? Pek bir şey anlamadım

Global $ListWiev_Items[1] = [0]
Global $Bl_Value

Global $Form1 = GUICreate("Form1", 633, 449)
Global $listview = GUICtrlCreateListView("Number|Text                             ", 0, 0, 250, 150)
Global $Input1 = GUICtrlCreateInput("Selam Millet", 8, 160, 241, 21)
Global $Button1 = GUICtrlCreateButton("Button1", 8, 192, 243, 25)
GUISetState(@SW_SHOW)

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case -3
			Exit
		Case $Button1
			$Bl_Value = GUICtrlRead($Input1)
			$ListWiev_Items[0] += 1
			ReDim $ListWiev_Items[$ListWiev_Items[0] +1]
			$ListWiev_Items[$ListWiev_Items[0]] = GUICtrlCreateListViewItem($ListWiev_Items[0] & "|" & $Bl_Value, $listview)
	EndSwitch
WEnd

Link to comment
Share on other sites

Global $i=1
Global $Bl_Value 
Global $Form1 = GUICreate("Form1", 633, 449) 
Global $Input1 = GUICtrlCreateInput("Selam Millet", 8, 160, 241, 21) 
Global $Button1 = GUICtrlCreateButton("Button1", 8, 192, 243, 25) 
GUISetState(@SW_SHOW) 
While 1    
$nMsg = GUIGetMsg() 	
Switch $nMsg 		
Case -3 		   
 Exit 		
Case $Button1 			
Msgbox(0,"başlık",$i & " " & GUICtrlRead($Input1))
$i += 1
EndSwitch 
WEnd 

Link to comment
Share on other sites

oncelikle cevaplariiz icin tesekur ederim

blue_life kardesim kodlar dogru ancak ListViewe eklediginde onlari bide txt olusuturup onun icine yapistiracak

yada sole soyleyeyim

bu form a bide olustur butonu koyacaz butona bastigimizda ListViewe eklediklerimizin hepsini bi metin belgesi olusturup icine yazacak.

Edited by monika
Link to comment
Share on other sites

Global $TextFile = @ScriptDir & "\Deneme_123.txt"
Global $ListWiev_Items[1] = [0]
Global $Bl_Value,$Bl_Value1,$File_Opt

Global $Form1 = GUICreate("Form1", 633, 449)
Global $listview = GUICtrlCreateListView("Number|Text                             ", 0, 0, 250, 150)
Global $Input1 = GUICtrlCreateInput("Selam Millet", 5, 160, 240, 21)
Global $Button1 = GUICtrlCreateButton("Button1", 5, 195, 120, 25)
Global $Button2 = GUICtrlCreateButton("Oluştur", 130, 195, 120, 25)
GUISetState(@SW_SHOW)

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case -3
			Exit
		Case $Button1
			$Bl_Value = GUICtrlRead($Input1)
			$ListWiev_Items[0] += 1
			ReDim $ListWiev_Items[$ListWiev_Items[0] +1]
			$ListWiev_Items[$ListWiev_Items[0]] = GUICtrlCreateListViewItem($ListWiev_Items[0] & "|" & $Bl_Value, $listview)
		Case $Button2
			$Bl_Value = ""
			For $I = 1 to $ListWiev_Items[0]
				$Bl_Value1 = GUICtrlRead($ListWiev_Items[$I])
				If StringRight($Bl_Value1,1) = "|" Then $Bl_Value1 = StringTrimRight($Bl_Value1,1)
				$Bl_Value1 = StringReplace($Bl_Value1,"|"," = ")
				$Bl_Value &= $Bl_Value1 & @CRLF
			Next
			$File_Opt = FileOpen($TextFile, 2)
			If $File_Opt <> -1 Then
				FileWrite($File_Opt,$Bl_Value)
				MsgBox(64,"Kayıt edildi!",$TextFile)
			Else
				MsgBox(16,"Kayıt edilemedi!",$TextFile)
			EndIf
			FileClose($File_Opt)
	EndSwitch
WEnd

Link to comment
Share on other sites

@monika

Anlamadım, aşağıdaki gibi mi demek istiyorsun?

Global $TextFile = @ScriptDir & "\Deneme_123.txt"
Global $ListWiev_Items[1] = [0]
Global $Bl_Value,$Bl_Value1,$File_Opt

Global $Form1 = GUICreate("Form1", 633, 449)
Global $listview = GUICtrlCreateListView("Number|Text                             ", 0, 0, 250, 150)
Global $Input1 = GUICtrlCreateInput("Selam", 5, 160, 115, 21)
Global $Input2 = GUICtrlCreateInput("Millet", 125, 160, 115, 21)
Global $Button1 = GUICtrlCreateButton("Button1", 5, 195, 120, 25)
Global $Button2 = GUICtrlCreateButton("Oluştur", 130, 195, 120, 25)
GUISetState(@SW_SHOW)

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case -3
			Exit
		Case $Button1
			$ListWiev_Items[0] += 2
			ReDim $ListWiev_Items[$ListWiev_Items[0] +1]
			$ListWiev_Items[$ListWiev_Items[0]-1] = GUICtrlCreateListViewItem(($ListWiev_Items[0] -1) & "|" & GUICtrlRead($Input1), $listview)
			$ListWiev_Items[$ListWiev_Items[0]] = GUICtrlCreateListViewItem($ListWiev_Items[0] & "|" & GUICtrlRead($Input2), $listview)

		Case $Button2
			$Bl_Value = ""
			For $I = 1 to $ListWiev_Items[0]
				$Bl_Value1 = GUICtrlRead($ListWiev_Items[$I])
				If StringRight($Bl_Value1,1) = "|" Then $Bl_Value1 = StringTrimRight($Bl_Value1,1)
				$Bl_Value1 = StringReplace($Bl_Value1,"|"," = ")
				$Bl_Value &= $Bl_Value1 & @CRLF
			Next
			$File_Opt = FileOpen($TextFile, 2)
			If $File_Opt <> -1 Then
				FileWrite($File_Opt,$Bl_Value)
				MsgBox(64,"Kayıt edildi!",$TextFile)
			Else
				MsgBox(16,"Kayıt edilemedi!",$TextFile)
			EndIf
			FileClose($File_Opt)
	EndSwitch
WEnd

Link to comment
Share on other sites

Sen inceleyip, kendine göre ayarla!

Global $TextFile = @ScriptDir & "\Deneme_123.txt"
Global $ListWiev_Items[1] = [0]
Global $Bl_Value,$Bl_Value1,$File_Opt

Global $Form1 = GUICreate("Form1", 633, 449)
Global $listview = GUICtrlCreateListView("Number|Text                             ", 0, 0, 250, 150)
Global $Input1 = GUICtrlCreateInput("Selam", 5, 160, 115, 21)
Global $Input2 = GUICtrlCreateInput("Millet", 125, 160, 115, 21)
Global $Button1 = GUICtrlCreateButton("Button1", 5, 195, 120, 25)
Global $Button2 = GUICtrlCreateButton("Oluştur", 130, 195, 120, 25)
GUISetState(@SW_SHOW)

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case -3
			Exit
		Case $Button1
			$Bl_Value = GUICtrlRead($Input1) & ' ' & GUICtrlRead($Input2)
			$ListWiev_Items[0] += 1
			ReDim $ListWiev_Items[$ListWiev_Items[0] +1]
			$ListWiev_Items[$ListWiev_Items[0]] = GUICtrlCreateListViewItem($ListWiev_Items[0] & "|" & $Bl_Value, $listview)
		Case $Button2
			$Bl_Value = ""
			For $I = 1 to $ListWiev_Items[0]
				$Bl_Value1 = GUICtrlRead($ListWiev_Items[$I])
				If StringRight($Bl_Value1,1) = "|" Then $Bl_Value1 = StringTrimRight($Bl_Value1,1)
				$Bl_Value1 = StringReplace($Bl_Value1,"|"," = ")
				$Bl_Value &= $Bl_Value1 & @CRLF
			Next
			$File_Opt = FileOpen($TextFile, 2)
			If $File_Opt <> -1 Then
				FileWrite($File_Opt,$Bl_Value)
				MsgBox(64,"Kayıt edildi!",$TextFile)
			Else
				MsgBox(16,"Kayıt edilemedi!",$TextFile)
			EndIf
			FileClose($File_Opt)
	EndSwitch
WEnd

Link to comment
Share on other sites

  • 1 yıl yıl...

Arkadaşlar ben bu listelemede anlamadığım bişi var.
tamam 1 den başlıyor sıralama fakat 10 ve 11 e gelince sıra karışıyor
1
10
11
2
olarak gözüküyor bunu nasıl düzenli sıra yapabilirim.

[codebox]Global $i = 1
Global $Bl_Value
Global $Form1 = GUICreate("Form1", 633, 449)
Global $Input1 = GUICtrlCreateInput("Selam Millet", 8, 160, 241, 21)
Global $Button1 = GUICtrlCreateButton("Button1", 8, 192, 243, 25)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Button1
MsgBox(0, "başlık", $i & " " & GUICtrlRead($Input1))
$i += 1
EndSwitch
WEnd[/codebox]

Edited by blue_life
Codebox alanı düzeltildi!
Link to comment
Share on other sites

@bmozdemir

Mesajını iki defa okudum ama ilgili kod ile bir alaka kuramadım. Ilgili kod her butona basışında rakamı bir arttırp sana mesaj olarak veriyor.
Herangi bir listeleme yok!

Konuyu biraz daha açarsan yardımcı olmaya çalışırız...

Link to comment
Share on other sites

@blue_life

işin aslı evet vermiş olduğum örnekte listview ekranı olmadığından haklısınız ama ben bunu listview ekranında denedim ve orada liste karıştığından bu mesajı atmıştım elimde o sırada aşağıda gönderdiğim ve yapmaya çalıştığım ve eklemede hata oluşan kod alttadır. Bu kodu editleyen kişide @blue_life'tır ona saygısızlık olmasın o yardımcı olmuştu. fazladan bişiler sormamak için kendim yapmaya çalıştım fakat bu hatayla karşılaştım.

Amacım Sıra yazan yere otomatik numaraları vermesi ve o numaralara göre sıralaması. Diğer seçeneklere göre değil yani tek baz alınacak satır sıra satırı olmalı diğer satırlara yazılanlar önemli olmamalı. Tam oldu dedğimde ise sıra karıştı :). Valla kusura bakmayın belki baya cahilce sorular olabilir bunlar ama yeni yeni deniyorum ve sizlerin yardımına ihtiyacım var. şimdiden sağolun.

[codebox]
#include <array.au3>
Global $ScriptDir = @ScriptDir
If StringRight($ScriptDir, 1) <> "\" Then $ScriptDir &= "\"
Global $INI_FILE = $ScriptDir & "InventoryData.ini"
Global $BLUE_ARRAY
Global $i=1
Global $MainForm = GUICreate("Form1", 623, 442)
Global $ListView1 = GUICtrlCreateListView("Sıra|Product Code|Make|Model|Current Stock|Date Modified", 16, 8, 586, 390)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
GUICtrlSendMsg(-1, 4126, 2, 100)
GUICtrlSendMsg(-1, 4126, 3, 82)
GUICtrlSendMsg(-1, 4126, 4, 80)
GUICtrlSendMsg(-1, 4126, 5, 120)

_Update_ListView() ;ListView Güncelle

Global $Button1 = GUICtrlCreateButton("Add A Product", 16, 408, 91, 25)
Global $Button2 = GUICtrlCreateButton("Edit A Product", 120, 408, 91, 25)
Global $Button3 = GUICtrlCreateButton("Delete A Product", 224, 408, 107, 25)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Button1
_Add_Edit_AProduct()
Case $Button2
_Add_Edit_AProduct("Edit")
Case $Button3
_DeleteItem()
EndSwitch
WEnd

Func _READ_INI()
Local $RETURN_ARRAY[25][7] ;GCID,Product Code,Make,Model,Current Stock,Date Modified=
$RAD_ISName = IniReadSectionNames($INI_FILE)
If Not @error Then
For $i = 1 To $RAD_ISName[0]
If StringLeft($RAD_ISName[$i], 0) <> "" Then ContinueLoop

$RETURN_ARRAY[0][0] += 1
If UBound($RETURN_ARRAY, 1) <= $RETURN_ARRAY[0][0] Then ReDim $RETURN_ARRAY[$RETURN_ARRAY[0][0] + 25][7]

$RETURN_ARRAY[$RETURN_ARRAY[0][0]][1] = IniRead($INI_FILE, $RAD_ISName[$i], "Sıra", "")
$RETURN_ARRAY[$RETURN_ARRAY[0][0]][2] = StringStripWS(IniRead($INI_FILE, $RAD_ISName[$i], "Product Code", ""), 3)
$RETURN_ARRAY[$RETURN_ARRAY[0][0]][3] = IniRead($INI_FILE, $RAD_ISName[$i], "Make", "")
$RETURN_ARRAY[$RETURN_ARRAY[0][0]][4] = IniRead($INI_FILE, $RAD_ISName[$i], "Model", "")
$RETURN_ARRAY[$RETURN_ARRAY[0][0]][5] = IniRead($INI_FILE, $RAD_ISName[$i], "Current Stock", "")
$RETURN_ARRAY[$RETURN_ARRAY[0][0]][6] = IniRead($INI_FILE, $RAD_ISName[$i], "Date Modified", "")
Next
EndIf
If UBound($RETURN_ARRAY, 1) <> ($RETURN_ARRAY[0][0] + 1) Then ReDim $RETURN_ARRAY[$RETURN_ARRAY[0][0] + 1][7]
Return $RETURN_ARRAY
EndFunc ;==>_READ_INI

Func _Update_ListView()
If IsArray($BLUE_ARRAY) = 0 Then
$BLUE_ARRAY = _READ_INI() ;Read_Ini_File
EndIf
_ArraySort($BLUE_ARRAY, 0, 1, 0, 1)

For $i = 1 To $BLUE_ARRAY[0][0]
If $BLUE_ARRAY[$i][0] = -1 Then ContinueLoop
If $BLUE_ARRAY[$i][0] > 0 Then GUICtrlDelete($BLUE_ARRAY[$i][0])

$BLUE_ARRAY[$i][0] = GUICtrlCreateListViewItem($BLUE_ARRAY[$i][1] & "|" & $BLUE_ARRAY[$i][2] & "|" & $BLUE_ARRAY[$i][3] & _
"|" & $BLUE_ARRAY[$i][4] & "|" & $BLUE_ARRAY[$i][5] & "|" & $BLUE_ARRAY[$i][6], $ListView1)
If Number($BLUE_ARRAY[$i][4]) < 100 Then
GUICtrlSetBkColor($BLUE_ARRAY[$i][0], 0xfff333)
EndIf
If Number($BLUE_ARRAY[$i][4]) < 10 Then
GUICtrlSetBkColor($BLUE_ARRAY[$i][0], 0xff0000)
EndIf
Next
EndFunc ;==>_Update_ListView

Func _Add_Edit_AProduct($AType = "Add")
Local $GuiRead
Local $No, $productCode, $make, $Deneme, $model, $currentStock, $dataModified = @MON & "/" & @MDAY & "/" & @YEAR

If $AType <> "Add" Then
$GuiRead = GUICtrlRead($ListView1)
If $GuiRead = 0 Then
MsgBox(48, "Error!", "Not select item!", 0, $MainForm)
SetError(1, 0, 0)
EndIf

If IsArray($BLUE_ARRAY) = 0 Or $GuiRead = 0 Then Return SetError(2, 0, 0)
$BLUE_ARRAY[0][1] = 0

For $i = 1 To $BLUE_ARRAY[0][0]
If $GuiRead = $BLUE_ARRAY[$i][0] Then
$BLUE_ARRAY[0][1] = $i
$No = $BLUE_ARRAY[$i][1]
$productCode = $BLUE_ARRAY[$i][2]
$make = $BLUE_ARRAY[$i][3]
$model = $BLUE_ARRAY[$i][4]
$currentStock = $BLUE_ARRAY[$i][5]
$dataModified = $BLUE_ARRAY[$i][6]
ExitLoop
EndIf
Next
If $BLUE_ARRAY[0][1] = 0 Then Return SetError(3, 0, 0)
EndIf

GUISetState(@SW_DISABLE, $MainForm)

Local $Form2 = GUICreate("Product Inventory", 336, 258, 302, 218)
Local $aInput1 = GUICtrlCreateInput($productCode, 16, 24, 193, 21)
Local $aInput2 = GUICtrlCreateInput($make, 16, 64, 193, 21)
Local $aInput3 = GUICtrlCreateInput($model, 16, 104, 193, 21)
Local $aInput4 = GUICtrlCreateInput($currentStock, 16, 144, 193, 21)
Local $aInput5 = GUICtrlCreateInput($dataModified, 16, 184, 193, 21)
GUICtrlCreateLabel("Product Code", 224, 24, 69, 17)
GUICtrlCreateLabel("Make", 224, 64, 31, 17)
GUICtrlCreateLabel("Model", 224, 104, 33, 17)
GUICtrlCreateLabel("Current Stock", 224, 144, 69, 17)
GUICtrlCreateLabel("Date Modified", 224, 184, 70, 17)
Local $cButton3 = GUICtrlCreateButton("Add Product", 120, 216, 91, 25)
If $AType <> "Add" Then GUICtrlSetData($cButton3, "Edit Product")

GUISetState(@SW_SHOW, $Form2)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
ExitLoop
Case $cButton3
$productCode = StringStripWS(GUICtrlRead($aInput1), 3)
If $productCode = "" Then
MsgBox(48, "Error!", "Enter product Code", 0, $Form2)
GUICtrlSetState($aInput1, 256)
ContinueCase
EndIf

$make = StringStripWS(GUICtrlRead($aInput2), 3)
If $make = "" Then
MsgBox(48, "Error!", "Enter make", 0, $Form2)
GUICtrlSetState($make, 256)
ContinueCase
EndIf


$model = StringStripWS(GUICtrlRead($aInput3), 3)
If $model = "" Then
MsgBox(48, "Error!", "Enter model", 0, $Form2)
GUICtrlSetState($model, 256)
ContinueCase
EndIf

$currentStock = StringStripWS(GUICtrlRead($aInput4), 3)
If $currentStock = "" Then
MsgBox(48, "Error!", "Enter current stock ", 0, $Form2)
GUICtrlSetState($currentStock, 256)
ContinueCase
EndIf

$dataModified = StringStripWS(GUICtrlRead($aInput5), 3)

; -------------------------------
If $AType = "Add" Then
For $i = 1 To $BLUE_ARRAY[0][0]
If $BLUE_ARRAY[$i][1] = $productCode Then
GUICtrlSetState($aInput1, 256)
MsgBox(0, "Error", "The product is already in the database")
ContinueCase
EndIf
Next
$BLUE_ARRAY[0][0] += 1
ReDim $BLUE_ARRAY[$BLUE_ARRAY[0][0] + 1][7]
$BLUE_ARRAY[0][1] = $BLUE_ARRAY[0][0]
EndIf

$BLUE_ARRAY[$BLUE_ARRAY[0][1]][1] = $i
$BLUE_ARRAY[$BLUE_ARRAY[0][1]][2] = $productCode
$BLUE_ARRAY[$BLUE_ARRAY[0][1]][3] = $make
$BLUE_ARRAY[$BLUE_ARRAY[0][1]][4] = $model
$BLUE_ARRAY[$BLUE_ARRAY[0][1]][5] = $currentStock
$BLUE_ARRAY[$BLUE_ARRAY[0][1]][6] = $dataModified

IniWrite($INI_FILE, "" & $productCode, "Sıra", $i)
$i += 1
IniWrite($INI_FILE, "" & $productCode, "Product Code", $productCode)
IniWrite($INI_FILE, "" & $productCode, "Make", $make)
IniWrite($INI_FILE, "" & $productCode, "Model", $model)
IniWrite($INI_FILE, "" & $productCode, "Current Stock", $currentStock)
IniWrite($INI_FILE, "" & $productCode, "Date Modified", $dataModified)
ExitLoop
EndSwitch
WEnd
_Update_ListView()
GUISwitch($MainForm)
GUISetState(@SW_ENABLE, $MainForm)
GUIDelete($Form2)
EndFunc ;==>_Add_Edit_AProduct

Func _DeleteItem()
Local $GuiRead = GUICtrlRead($ListView1), $GuiRead2, $SINSTR
If $GuiRead <> 0 Then
For $i = 1 To $BLUE_ARRAY[0][0]
If $GuiRead = $BLUE_ARRAY[$i][0] Then
GUICtrlDelete($BLUE_ARRAY[$i][0])
IniDelete("InventoryData.ini", "" & $BLUE_ARRAY[$i][1])
$BLUE_ARRAY[$i][0] = -1
ExitLoop
EndIf
Next
EndIf
EndFunc ;==>_DeleteItem
[/codebox]

Edited by bmozdemir
Link to comment
Share on other sites

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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...