Jump to content
TNC-TR
darendeli

çekiliş Programı

Recommended Posts

Çekiliş Programı Yapacagım  bir yerde tıkandım  Eklenen Kisilerin Listesinden Random olarak Diger listeye Akrarım saglamak istiyorum  Secilecek Sayı Yazan inputtaki Kisi Kadar...

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_Res_Language=1055
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****


#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <GUIEdit.au3>
#include <GuiListView.au3>
#Region ### START Koda GUI section ### Form=
$gui = GUICreate("Çekilis Pro", 615, 522, 192, 124)
$input = GUICtrlCreateInput("", 312, 24, 201, 21)
$Button2 = GUICtrlCreateButton("ÇEKİLİŞİ BAŞLAT", 16, 432, 587, 73)
$Input2 = GUICtrlCreateInput("", 552, 24, 49, 21)
$List2 = GUICtrlCreateList("", 312, 56, 289, 370)
$Button1 = GUICtrlCreateButton("KATILIMCI EKLE", 16, 2, 283, 23)
$Button3 = GUICtrlCreateButton("KATILIMCI Sil", 16, 25, 283, 23)
$Label1 = GUICtrlCreateLabel("Kullanıcı ismi", 380, 2, 283, 20)
$Label2 = GUICtrlCreateLabel("Seçilecek Sayı", 540, 2, 283, 20)
$list = _GUICtrlListView_Create($gui, "", 1, 50, 310, 379)
_GUICtrlListView_SetExtendedListViewStyle($list, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $WS_EX_CLIENTEDGE))
_GUICtrlListView_InsertColumn($list, 0, "SIRA")
_GUICtrlListView_InsertColumn($list, 1, "ÇEKİLİŞE KATILAN KİŞİLER")
If(FileExists(@ScriptDir & "\cekilis.ini")) Then
	$read_section = IniReadSectionNames(@ScriptDir & "\cekilis.ini")
	For $i = 1 To $read_section[0]
		$read = IniReadSection(@ScriptDir & "\cekilis.ini", $read_section[$i])
		_GUICtrlListView_AddItem($list, $i)
		_GUICtrlListView_AddSubItem($list, ($i -1), $read_section[$i], 1)
    For $i2 = 1 To $read[0][0]
			If($read[$i2][0] == "ÇEKİLİŞE KATILAN KİŞİLER") Then _GUICtrlListView_AddSubItem($list, ($i -1), $read[$i2][1], 2)
		Next
	Next
EndIf
_center_list($list)
_list_column_size($gui, $list)
GUISetState()
#EndRegion ### END Koda GUI section ###

While 1
	Switch GUIGetMsg()
		Case -3
			Exit
		Case $Button1
			IniWrite(@ScriptDir & "\filmler.ini", GUICtrlRead($input), "ÇEKİLİŞE KATILAN KİŞİLER", GUICtrlRead($input2))
			$count = _GUICtrlListView_GetItemCount($list)
			_GUICtrlListView_AddItem($list, $count+1)
			_GUICtrlListView_AddSubItem($list, $count, GUICtrlRead($input), 1)

			_list_column_size($gui, $list)
			GUICtrlSetData($input, "")

Case $Button3
                ConfigRemData()

	EndSwitch
WEnd


Func ConfigRemData()
	DeleteSelectedItems()
;~     _GUICtrlListView_DeleteItemsSelected($list)
EndFunc   ;==>ConfigRemData

Func DeleteSelectedItems()
	Local $SelectedItems = _GUICtrlListView_GetSelectedIndices($list,True)
	For $i = 1 To $SelectedItems[0]
		IniDelete(@ScriptDir & "\cekilis.ini",_GUICtrlListView_GetItemText($list,$SelectedItems[$i],1))
		_GUICtrlListView_DeleteItem($list,$SelectedItems[$i])
    Next
	Local $icerik = FileReadToArray(@ScriptDir & "\cekilis.ini")
	If @error Then;dosya boş olunca hata vereceği için bu kod bloğuna alıyorum
		FileDelete(@ScriptDir & "\cekilis.ini")
	EndIf
EndFunc

Func _center_list($list_handle)
	For $i = 0 To _GUICtrlListView_GetColumnCount($list_handle) - 1
		_GUICtrlListView_JustifyColumn($list_handle, $i, 2)
	Next
EndFunc   ;==>_center_list
Func _list_column_size($gui_handle, $list_handle)
	$iScroll_Allowance = 0
	_GUICtrlListView_EnsureVisible($list_handle, _GUICtrlListView_GetItemCount($list_handle))
	If _GUICtrlListView_GetTopIndex($list_handle) > 0 Then
		$iScroll_Allowance = 17
	EndIf
	_GUICtrlListView_EnsureVisible($list_handle, 0)
	$iLV_Width = $iScroll_Allowance
	For $i = 0 To _GUICtrlListView_GetColumnCount($list_handle) - 1
		_GUICtrlListView_SetColumnWidth($list_handle, $i, $LVSCW_AUTOSIZE_USEHEADER)
		$iHeader_Width = _GUICtrlListView_GetColumnWidth($list_handle, $i)
		_GUICtrlListView_SetColumnWidth($list_handle, $i, $LVSCW_AUTOSIZE)
		$iData_Width = _GUICtrlListView_GetColumnWidth($list_handle, $i)
		If $iHeader_Width > $iData_Width Then
			_GUICtrlListView_SetColumnWidth($list_handle, $i, $iHeader_Width)
			$iLV_Width += $iHeader_Width
		Else
			$iLV_Width += $iData_Width
		EndIf
	Next
	;ControlMove($gui_handle, "", $list_handle, Default, Default, $iLV_Width)
	;WinMove($gui_handle, "", Default, Default, $iLV_Width + 30)
EndFunc   ;==>_list_column_size

 

Share this post


Link to post
Share on other sites

İstediğin bölümü yaptım, fakat kodun genelinde düzeltilmesi gereken noktalar var, belirtmeden geçemicem.

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_Res_Language=1055
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****


#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <GUIEdit.au3>
#include <GuiListView.au3>
#Region ### START Koda GUI section ### Form=
$gui = GUICreate("Çekilis Pro", 615, 522, 192, 124)
$input = GUICtrlCreateInput("", 312, 24, 201, 21)
$Button2 = GUICtrlCreateButton("ÇEKİLİŞİ BAŞLAT", 16, 432, 587, 73)
$Input2 = GUICtrlCreateInput("", 552, 24, 49, 21,0x2000)
GUICtrlSetLimit(-1,1)
$List2 = GUICtrlCreateList("", 312, 56, 289, 370, BitOR($WS_BORDER, $WS_VSCROLL))
$Button1 = GUICtrlCreateButton("KATILIMCI EKLE", 16, 2, 283, 23)
$Button3 = GUICtrlCreateButton("KATILIMCI Sil", 16, 25, 283, 23)
$Label1 = GUICtrlCreateLabel("Kullanıcı ismi", 380, 2, 283, 20)
$Label2 = GUICtrlCreateLabel("Seçilecek Sayı", 540, 2, 283, 20)
$list = _GUICtrlListView_Create($gui, "", 1, 50, 310, 379)
_GUICtrlListView_SetExtendedListViewStyle($list, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $WS_EX_CLIENTEDGE))
_GUICtrlListView_InsertColumn($list, 0, "SIRA")
_GUICtrlListView_InsertColumn($list, 1, "ÇEKİLİŞE KATILAN KİŞİLER")
If(FileExists(@ScriptDir & "\cekilis.ini")) Then
	$read_section = IniReadSectionNames(@ScriptDir & "\cekilis.ini")
	For $i = 1 To $read_section[0]
		$read = IniReadSection(@ScriptDir & "\cekilis.ini", $read_section[$i])
		_GUICtrlListView_AddItem($list, $i)
		_GUICtrlListView_AddSubItem($list, ($i -1), $read_section[$i], 1)
    For $i2 = 1 To $read[0][0]
			If($read[$i2][0] == "ÇEKİLİŞE KATILAN KİŞİLER") Then _GUICtrlListView_AddSubItem($list, ($i -1), $read[$i2][1], 2)
		Next
	Next
EndIf
_center_list($list)
_list_column_size($gui, $list)
GUISetState()
#EndRegion ### END Koda GUI section ###

While 1
	Switch GUIGetMsg()
		Case -3
			Exit
		Case $Button1
			IniWrite(@ScriptDir & "\filmler.ini", GUICtrlRead($input), "ÇEKİLİŞE KATILAN KİŞİLER", GUICtrlRead($input2))
			$count = _GUICtrlListView_GetItemCount($list)
			_GUICtrlListView_AddItem($list, $count+1)
			_GUICtrlListView_AddSubItem($list, $count, GUICtrlRead($input), 1)
			_list_column_size($gui, $list)
			GUICtrlSetData($input, "")
		Case $Button3
            ConfigRemData()
		Case $Button2
			$katilimcisayisi = Number(_GUICtrlListView_GetItemCount($list))
			$secilecekkisisayisi = Number(GUICtrlRead($input2))
			if not ($secilecekkisisayisi > $katilimcisayisi) Then
				Local $secilenler[$secilecekkisisayisi+1] = [$secilecekkisisayisi]
				Local $secilenlerisim[$secilecekkisisayisi]
				for $i = 1 to $secilecekkisisayisi
					Do
						$simdisecilen = Random(1,$katilimcisayisi,1)
					Until _ArraySearch($secilenler,$simdisecilen) = -1
					$secilenler[$i] = $simdisecilen
					$secilenlerisim[$i-1] = _GUICtrlListView_GetItemText($list,$simdisecilen-1,1)
				Next
				GUICtrlSetData($List2,_ArrayToString($secilenlerisim))
			Else
				MsgBox(0,"Hata","Seçilecek kişi sayısı katılımcıdan fazla olmamalı.")
			endif
	EndSwitch
WEnd


Func ConfigRemData()
	DeleteSelectedItems()
;~     _GUICtrlListView_DeleteItemsSelected($list)
EndFunc   ;==>ConfigRemData

Func DeleteSelectedItems()
	Local $SelectedItems = _GUICtrlListView_GetSelectedIndices($list,True)
	For $i = 1 To $SelectedItems[0]
		IniDelete(@ScriptDir & "\cekilis.ini",_GUICtrlListView_GetItemText($list,$SelectedItems[$i],1))
		_GUICtrlListView_DeleteItem($list,$SelectedItems[$i])
    Next
	Local $icerik = FileReadToArray(@ScriptDir & "\cekilis.ini")
	If @error Then;dosya boş olunca hata vereceği için bu kod bloğuna alıyorum
		FileDelete(@ScriptDir & "\cekilis.ini")
	EndIf
EndFunc

Func _center_list($list_handle)
	For $i = 0 To _GUICtrlListView_GetColumnCount($list_handle) - 1
		_GUICtrlListView_JustifyColumn($list_handle, $i, 2)
	Next
EndFunc   ;==>_center_list
Func _list_column_size($gui_handle, $list_handle)
	$iScroll_Allowance = 0
	_GUICtrlListView_EnsureVisible($list_handle, _GUICtrlListView_GetItemCount($list_handle))
	If _GUICtrlListView_GetTopIndex($list_handle) > 0 Then
		$iScroll_Allowance = 17
	EndIf
	_GUICtrlListView_EnsureVisible($list_handle, 0)
	$iLV_Width = $iScroll_Allowance
	For $i = 0 To _GUICtrlListView_GetColumnCount($list_handle) - 1
		_GUICtrlListView_SetColumnWidth($list_handle, $i, $LVSCW_AUTOSIZE_USEHEADER)
		$iHeader_Width = _GUICtrlListView_GetColumnWidth($list_handle, $i)
		_GUICtrlListView_SetColumnWidth($list_handle, $i, $LVSCW_AUTOSIZE)
		$iData_Width = _GUICtrlListView_GetColumnWidth($list_handle, $i)
		If $iHeader_Width > $iData_Width Then
			_GUICtrlListView_SetColumnWidth($list_handle, $i, $iHeader_Width)
			$iLV_Width += $iHeader_Width
		Else
			$iLV_Width += $iData_Width
		EndIf
	Next
	;ControlMove($gui_handle, "", $list_handle, Default, Default, $iLV_Width)
	;WinMove($gui_handle, "", Default, Default, $iLV_Width + 30)
EndFunc   ;==>_list_column_size

 

  • Like 1

Share this post


Link to post
Share on other sites

Yaşlılıktan :)

 

			$katilimcisayisi = Number(_GUICtrlListView_GetItemCount($list))
			$secilecekkisisayisi = Number(GUICtrlRead($input2))
			if $secilecekkisisayisi > $katilimcisayisi Then
				MsgBox(0,"Hata","Seçilecek kişi sayısı katılımcıdan fazla olmamalı.")
			Else
				Local $secilenler[$secilecekkisisayisi+1]
				$secilenler[0] = ""
				Local $secilenlerisim[$secilecekkisisayisi]
				for $i = 1 to $secilecekkisisayisi
					Do
						$simdisecilen = Random(1,$katilimcisayisi,1)
					Until _ArraySearch($secilenler,$simdisecilen) = -1
					$secilenler[$i] = $simdisecilen
					$secilenlerisim[$i-1] = _GUICtrlListView_GetItemText($list,$simdisecilen-1,1)
				Next
				GUICtrlSetData($List2,_ArrayToString($secilenlerisim))
			endif

Case $Button2 yi bu kod ile değiştir.

  • Like 1

Share this post


Link to post
Share on other sites
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_Res_Language=1055
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****


#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <GUIEdit.au3>
#include <GuiListView.au3>
#Region ### START Koda GUI section ### Form=
$gui = GUICreate("Çekilis Pro", 615, 522, 192, 124)
$input = GUICtrlCreateInput("", 312, 24, 201, 21)
$Button2 = GUICtrlCreateButton("ÇEKİLİŞİ BAŞLAT", 16, 432, 587, 73)
$Input2 = GUICtrlCreateInput("", 552, 24, 49, 21,0x2000)
GUICtrlSetLimit(-1,1)
$List2 = GUICtrlCreateList("", 312, 56, 289, 370, BitOR($WS_BORDER, $WS_VSCROLL))
$Button1 = GUICtrlCreateButton("KATILIMCI EKLE", 16, 2, 283, 23)
$Button3 = GUICtrlCreateButton("KATILIMCI Sil", 16, 25, 283, 23)
$Label1 = GUICtrlCreateLabel("Kullanıcı ismi", 380, 2, 283, 20)
$Label2 = GUICtrlCreateLabel("Seçilecek Sayı", 540, 2, 283, 20)
$list = _GUICtrlListView_Create($gui, "", 1, 50, 310, 379)
_GUICtrlListView_SetExtendedListViewStyle($list, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $WS_EX_CLIENTEDGE))
_GUICtrlListView_InsertColumn($list, 0, "SIRA")
_GUICtrlListView_InsertColumn($list, 1, "ÇEKİLİŞE KATILAN KİŞİLER")
If(FileExists(@ScriptDir & "\cekilis.ini")) Then
	$read_section = IniReadSectionNames(@ScriptDir & "\cekilis.ini")
	For $i = 1 To $read_section[0]
		$read = IniReadSection(@ScriptDir & "\cekilis.ini", $read_section[$i])
		_GUICtrlListView_AddItem($list, $i)
		_GUICtrlListView_AddSubItem($list, ($i -1), $read_section[$i], 1)
    For $i2 = 1 To $read[0][0]
			If($read[$i2][0] == "ÇEKİLİŞE KATILAN KİŞİLER") Then _GUICtrlListView_AddSubItem($list, ($i -1), $read[$i2][1], 2)
		Next
	Next
EndIf
_center_list($list)
_list_column_size($gui, $list)

$KisiSil =GUICtrlCreateDummy()
$KisiEkle =GUICtrlCreateDummy()
Dim $EkleSil [2][2] = [["{DELETE}",$KisiSil],["{ENTER}",$KisiEkle]]
GUISetAccelerators($EkleSil)


GUISetState()
#EndRegion ### END Koda GUI section ###

While 1
	Switch GUIGetMsg()
		Case -3
			Exit
		Case $Button1,$KisiEkle
			IniWrite(@ScriptDir & "\cekilis.ini", GUICtrlRead($input), "ÇEKİLİŞE KATILAN KİŞİLER", GUICtrlRead($input2))
			$count = _GUICtrlListView_GetItemCount($list)
			_GUICtrlListView_AddItem($list, $count+1)
			_GUICtrlListView_AddSubItem($list, $count, GUICtrlRead($input), 1)
			_list_column_size($gui, $list)
			GUICtrlSetData($input, "")
		Case $Button3,$KisiSil
            ConfigRemData()
		Case $Button2
			GUICtrlSetData($List2,"")
			$katilimcisayisi = Number(_GUICtrlListView_GetItemCount($list))
			$secilecekkisisayisi = Number(GUICtrlRead($input2))
			if $secilecekkisisayisi > $katilimcisayisi Then
				MsgBox(0,"Hata","Seçilecek kişi sayısı katılımcıdan fazla olmamalı.")
			Else
				Local $secilenler[$secilecekkisisayisi+1]
				$secilenler[0] = ""
				Local $secilenlerisim[$secilecekkisisayisi]
				for $i = 1 to $secilecekkisisayisi
					Do
						$simdisecilen = Random(1,$katilimcisayisi,1)
					Until _ArraySearch($secilenler,$simdisecilen) = -1
					$secilenler[$i] = $simdisecilen
					$secilenlerisim[$i-1] = _GUICtrlListView_GetItemText($list,$simdisecilen-1,1)
				Next
				GUICtrlSetData($List2,_ArrayToString($secilenlerisim))
			EndIf
	EndSwitch
WEnd


Func ConfigRemData()
	DeleteSelectedItems()
;~     _GUICtrlListView_DeleteItemsSelected($list)
EndFunc   ;==>ConfigRemData

Func DeleteSelectedItems()
	Local $SelectedItems = _GUICtrlListView_GetSelectedIndices($list,True)
	For $i = 1 To $SelectedItems[0]
		IniDelete(@ScriptDir & "\cekilis.ini",_GUICtrlListView_GetItemText($list,$SelectedItems[$i],1))
		_GUICtrlListView_DeleteItem($list,$SelectedItems[$i])
    Next
	Local $icerik = FileReadToArray(@ScriptDir & "\cekilis.ini")
	If @error Then;dosya boş olunca hata vereceği için bu kod bloğuna alıyorum
		FileDelete(@ScriptDir & "\cekilis.ini")
	EndIf
EndFunc

Func _center_list($list_handle)
	For $i = 0 To _GUICtrlListView_GetColumnCount($list_handle) - 1
		_GUICtrlListView_JustifyColumn($list_handle, $i, 2)
	Next
EndFunc   ;==>_center_list
Func _list_column_size($gui_handle, $list_handle)
	$iScroll_Allowance = 0
	_GUICtrlListView_EnsureVisible($list_handle, _GUICtrlListView_GetItemCount($list_handle))
	If _GUICtrlListView_GetTopIndex($list_handle) > 0 Then
		$iScroll_Allowance = 17
	EndIf
	_GUICtrlListView_EnsureVisible($list_handle, 0)
	$iLV_Width = $iScroll_Allowance
	For $i = 0 To _GUICtrlListView_GetColumnCount($list_handle) - 1
		_GUICtrlListView_SetColumnWidth($list_handle, $i, $LVSCW_AUTOSIZE_USEHEADER)
		$iHeader_Width = _GUICtrlListView_GetColumnWidth($list_handle, $i)
		_GUICtrlListView_SetColumnWidth($list_handle, $i, $LVSCW_AUTOSIZE)
		$iData_Width = _GUICtrlListView_GetColumnWidth($list_handle, $i)
		If $iHeader_Width > $iData_Width Then
			_GUICtrlListView_SetColumnWidth($list_handle, $i, $iHeader_Width)
			$iLV_Width += $iHeader_Width
		Else
			$iLV_Width += $iData_Width
		EndIf
	Next
	;ControlMove($gui_handle, "", $list_handle, Default, Default, $iLV_Width)
	;WinMove($gui_handle, "", Default, Default, $iLV_Width + 30)
EndFunc   ;==>_list_column_size

Kodun Son Hali  Enter Ve Delete ile Ekleyip Silme Eklendi...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.

×