Autoit ListView FileMove tekli ve çoklu seçim sorunu? - Çözüldü

Programlama ve Script dilleri konusunda bilgi paylaşım alanıdır.
Cevapla
anxious
Byte3
Byte3
Mesajlar: 114
Kayıt: 11 Mar 2015, 07:56
Teşekkür edildi: 1 kez

Autoit ListView FileMove tekli ve çoklu seçim sorunu? - Çözüldü

Mesaj gönderen anxious »

Arkadaşlar merhaba.
Case $ButtonListMove
Eğer $RadioTekli seçili ise seçili olan tek dosya $ListV1 den $ListV2'e taşınsın.
Else
yani $RadioCoklu ise seçilenler kadar taşınsın istiyorum.

Case $ButtonList2Sil
Eğer $RadioTekli seçili ise seçili olan tek dosya $ListV2 den silinsin.
Else
yani $RadioCoklu ise seçilenler kadar silinsin istiyorum

Sorunumun olduğu kod bloğu

Kod: Tümünü seç

Case $ButtonListMove
			If GUICtrlRead($RadioTekli) = 1 Then
				For $s = 0 To _GUICtrlListView_GetItemCount($ListV1) - 1
					If _GUICtrlListView_GetItemChecked($ListV1, $s) Then
						$SelectFile = _GUICtrlListView_GetItemText($ListV1, $s)
						FileMove(@ScriptDir & "\" & $SelectFile, @ScriptDir & "\" & "List2Klasorum", 1)

					EndIf
				Next
				pressedMove()
			Else
				ConsoleWrite("Çoklu seçim Yaptınız seçtiklerinizin tümü taşınacak" & @CRLF)
				pressedMove()
			EndIf
Kodlarımın tümü

Kod: Tümünü seç

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <FileConstants.au3>
#include <GuiListView.au3>
Global $fTypes = "bmp|gif|png|jpg"
$Form1 = GUICreate("Form1", 420, 253)
$ListV1 = GUICtrlCreateListView("ListView 1", 8, 64, 186, 134, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 80)
FindFiles()
$ButtonListMove = GUICtrlCreateButton("List bir aktar List 2e", 8, 216, 187, 25)
$ListV2 = GUICtrlCreateListView("ListView 2", 207, 65, 186, 134, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 80)

$RadioTekli = GUICtrlCreateRadio("Tekli Taşıma", 304, 8, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$RadioCoklu = GUICtrlCreateRadio("Çoklu Taşıma", 304, 32, 113, 17)
$ButtonList2Sil = GUICtrlCreateButton("List 2 den Sil", 320, 218, 75, 25)

GUISetState(@SW_SHOW)

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

		Case $ButtonListMove
			If GUICtrlRead($RadioTekli) = 1 Then
				For $s = 0 To _GUICtrlListView_GetItemCount($ListV1) - 1
					If _GUICtrlListView_GetItemChecked($ListV1, $s) Then
						$SelectFile = _GUICtrlListView_GetItemText($ListV1, $s)
						FileMove(@ScriptDir & "\" & $SelectFile, @ScriptDir & "\" & "List2Klasorum", 1)

					EndIf
				Next
				pressedMove()
			Else
				ConsoleWrite("Çoklu seçim Yaptınız seçtiklerinizin tümü taşınacak" & @CRLF)
				pressedMove()
			EndIf


	EndSwitch
WEnd

Func pressedMove()
	_GUICtrlListView_CopyItems($ListV1, $ListV2, 1)
EndFunc   ;==>pressedMove

Func FindFiles($sType = "All Types")
	_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListV1))
	Local $ext = "*." & $sType, $FL2A
	If $sType = "All Types" Then $ext = "*.*"
	$FL2A = _FileListToArray(@ScriptDir, $ext, 1)
	If Not @error Then
		For $i = 1 To $FL2A[0]
			If $sType = "All Types" Then
				Local $SST = StringSplit($fTypes, "|")
				For $j = 1 To $SST[0]
					If $SST[$j] = StringMid($FL2A[$i], StringInStr($FL2A[$i], ".", 0, -1) + 1) Then _
							GUICtrlCreateListViewItem($FL2A[$i], $ListV1)
				Next
			ElseIf $sType <> "All Types" Then
				If $sType = StringMid($FL2A[$i], StringInStr($FL2A[$i], ".", 0, -1) + 1) Then _
						GUICtrlCreateListViewItem($FL2A[$i], $ListV1)
			EndIf
		Next
		_GUICtrlListView_SetColumnWidth($ListV1, 0, $LVSCW_AUTOSIZE)
	EndIf
EndFunc   ;==>FindFiles
Kullanıcı avatarı
BlueLife
Kilobyte1
Kilobyte1
Mesajlar: 269
Kayıt: 29 Ağu 2014, 20:42
Teşekkür etti: 14 kez
Teşekkür edildi: 24 kez

Re: Autoit ListView FileMove tekli ve çoklu seçim sorunu?

Mesaj gönderen BlueLife »

@anxious

Basit bir ek yaptım, incelersin. Kolay gelsin...

Kod: Tümünü seç

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <FileConstants.au3>
#include <GuiListView.au3>

Global $ScriptDir = @ScriptDir
If StringRight($ScriptDir, 1) <> "\" Then $ScriptDir &= "\"
Global $List2Klasorum = $ScriptDir & "List2Klasorum\"

Global $fTypes = "bmp|gif|png|jpg"
$Form1 = GUICreate("Form1", 420, 253)
$ListV1 = GUICtrlCreateListView("ListView 1", 8, 64, 186, 134, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 80)
FindFiles()
$ButtonListMove = GUICtrlCreateButton("List bir aktar List 2e", 8, 216, 187, 25)
$ListV2 = GUICtrlCreateListView("ListView 2", 207, 65, 186, 134, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 80)

$RadioTekli = GUICtrlCreateRadio("Tekli Taşıma", 304, 8, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$RadioCoklu = GUICtrlCreateRadio("Çoklu Taşıma", 304, 32, 113, 17)
$ButtonList2Sil = GUICtrlCreateButton("List 2 den Sil", 320, 218, 75, 25)

GUISetState(@SW_SHOW)

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

		Case $ButtonListMove
			For $s = 0 To _GUICtrlListView_GetItemCount($ListV1) - 1
				If _GUICtrlListView_GetItemChecked($ListV1, $s) Then
					$SelectFile = _GUICtrlListView_GetItemText($ListV1, $s)

					_GUICtrlListView_DeleteItem($ListV1, $s)
					GUICtrlCreateListViewItem($SelectFile, $ListV2)

					If FileExists($List2Klasorum) = 0 Then DirCreate($List2Klasorum)
					FileMove($ScriptDir & $SelectFile, $List2Klasorum, 1)
					
					If GUICtrlRead($RadioTekli) = 1 Then ExitLoop ;Tekli seçim
					$s=-1
				EndIf
			Next
	EndSwitch
WEnd

Func pressedMove()
	_GUICtrlListView_CopyItems($ListV1, $ListV2, 1)
EndFunc   ;==>pressedMove

Func FindFiles($sType = "All Types")
	_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListV1))
	Local $ext = "*." & $sType, $FL2A
	If $sType = "All Types" Then $ext = "*.*"
	$FL2A = _FileListToArray(@ScriptDir, $ext, 1)
	If Not @error Then
		For $i = 1 To $FL2A[0]
			If $sType = "All Types" Then
				Local $SST = StringSplit($fTypes, "|")
				For $j = 1 To $SST[0]
					If $SST[$j] = StringMid($FL2A[$i], StringInStr($FL2A[$i], ".", 0, -1) + 1) Then _
							GUICtrlCreateListViewItem($FL2A[$i], $ListV1)
				Next
			ElseIf $sType <> "All Types" Then
				If $sType = StringMid($FL2A[$i], StringInStr($FL2A[$i], ".", 0, -1) + 1) Then _
						GUICtrlCreateListViewItem($FL2A[$i], $ListV1)
			EndIf
		Next
		_GUICtrlListView_SetColumnWidth($ListV1, 0, $LVSCW_AUTOSIZE)
	EndIf
EndFunc   ;==>FindFiles
anxious
Byte3
Byte3
Mesajlar: 114
Kayıt: 11 Mar 2015, 07:56
Teşekkür edildi: 1 kez

Re: Autoit ListView FileMove tekli ve çoklu seçim sorunu?

Mesaj gönderen anxious »

@BlueLife Teşekkürler iyi forumlar dilerim saolun.
Cevapla