تعديل بسيط وهذا الناتج ...

a2a448917f63c5300d4eefaecd9134a9.png


:hh:

السموحة منكم ...

مالذي تشعر به .. :hh:
دامك فاضي تفلسف شوي علينا بكم كود ..
وإذا عندك إستفسار اسأل عادي .. :d:
 

توقيع : Bo.SaQeR
مالذي تشعر به .. :hh:
دامك فاضي تفلسف شوي علينا بكم كود ..
وإذا عندك إستفسار اسأل عادي .. :d:

حياك اخوي ...

والله ماجبت شيء من عندي الكود جاهز .. قمت بتعريب القيم فقط وهذا الناتج

وانت ماعاد نشوفك بالدورة .. عسى ماشر :d:
 
توقيع : موريادي
والله لـ للحين محد فاهمني :(

شوفو هذا الأمر : FileDelete("D:\*.tmp")


هل هذا الأمر يعني حذف جميع الملفات من قرص d بـ أمتداد tmp ؟

طيب انا ابي احذف جميع الملفات من القرص d أو c كيف أخلي الأمر ؟
 
تم التطوير والجديد هو :
1) لا حاجة لأي شئ قبل التشغيل

2) إضافة خاصية إصلاح قاعدة البيانات

3) إضافة خاصية قابلية الحذف
4) إضافة الذكاء الإصطناعي بشكل مبسط على الأداة


كود:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <File.au3>

Global $INI = "Contacts.ini"
Global $i
Global $FuncIsCall = False

GUICreate("Contacts", 390, 275, 192, 124)
$ListView = GUICtrlCreateListView("", 5, 5, 194, 262)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)

GUICtrlCreateGroup("Add Contact :", 208, 42, 175, 113)
$Save = GUICtrlCreateButton("Save", 256, 122, 75, 25, $WS_GROUP)
$Copy = GUICtrlCreateButton("Copy Selected", 205, 168, 179, 25, $WS_GROUP)
$Del = GUICtrlCreateButton("Delete Selected", 205, 205, 179, 25, $WS_GROUP)
$Name_Edit = GUICtrlCreateInput("", 272, 66, 105, 21)
$Num_Edit = GUICtrlCreateInput("", 272, 94, 105, 21)
GUICtrlCreateLabel("Name :", 216, 69, 38, 17)
GUICtrlCreateLabel("Number :", 218, 95, 47, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)

_GUICtrlListView_InsertColumn($ListView, 0, "Name", 70)
_GUICtrlListView_InsertColumn($ListView, 1, "Number", 120)

GUISetState(@SW_SHOW)

If FileExists($INI) Then _AddContacts_toList()

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

        Case $Save
            If GUICtrlRead($Name_Edit) <> "" And GUICtrlRead($Num_Edit) <> "" Then
                If Not FileExists($INI) Then
                    FileWriteLine($INI, "[Contacts]" & @CR)
                    _AddContacts_toList_2()
                Else
                    _AddContacts_toList_2()
                EndIf
            EndIf

        Case $Copy
            $Ind = _GUICtrlListView_GetSelectedIndices($ListView)
            $Copied = _GUICtrlListView_GetItemText($ListView, Int($Ind), 1)
            ClipPut($Copied)

        Case $Del
            $Ind = _GUICtrlListView_GetSelectedIndices($ListView)
            _ReplaceStringInFile($INI, _GUICtrlListView_GetItemText($ListView, Int($Ind)) & " = " & _GUICtrlListView_GetItemText($ListView, Int($Ind), 1), "", 1)
            If @error Then
                MsgBox(16, "Error !!", "Cannot delete this line from the contacts file !!")
            Else
                _GUICtrlListView_DeleteItemsSelected($ListView)
            EndIf
    EndSwitch
WEnd

Func _AddContacts_toList()
    FixDatabase()
    $List = IniReadSection($INI, "Contacts")
    If Not @error Then
        For $i = 1 To $List[0][0]
            GUICtrlCreateListViewItem($List[$i][0] & "|" & $List[$i][1], $ListView)
        Next
    EndIf

    Global $FuncIsCall = True
    If Not @error Then Global $i = $List[0][0] + 1
EndFunc   ;==>_AddContacts_toList

Func _AddContacts_toList_2()
    If Not $FuncIsCall Then $i = 1

    FileWriteLine($INI, GUICtrlRead($Name_Edit) & " = " & GUICtrlRead($Num_Edit))

    GUICtrlCreateListViewItem(GUICtrlRead($Name_Edit) & "|" & GUICtrlRead($Num_Edit), $ListView)

    $i = $i + 1
    $FuncIsCall = True
EndFunc   ;==>_AddContacts_toList_2

Func FixDatabase()
    DeleteLines()

    If FileRead($INI, 11) <> "[Contacts]" & @CR Then
        $handle = FileOpen($INI, 2)
        FileWrite($handle, "[Contacts]" & @CR)
        FileClose($handle)
    EndIf

    $List = IniReadSection($INI, "Contacts")

    If Not @error Then
        For $i = 1 To $List[0][0]
            If $List[$i][0] = "" Then _ReplaceStringInFile($INI, $List[$i][0] & " = " & $List[$i][1], "", 1)
            If $List[$i][1] = "" Then _ReplaceStringInFile($INI, $List[$i][0] & " = " & $List[$i][1], "", 1)
        Next
    EndIf

    DeleteLines()
EndFunc   ;==>FixDatabase

Func DeleteLines()
    $handle = FileOpen($INI)
    $Text = StringReplace(FileRead($handle), Hex("5D") & @CRLF & @CRLF, @CR, 0)
    $Text = StringReplace($Text, @CRLF & @CRLF, "", 0)
    $handle = FileOpen($INI, 2)
    FileWrite($handle, $Text)
    FileClose($handle)
EndFunc   ;==>DeleteLines

 
توقيع : Alzri2
والله لـ للحين محد فاهمني :(

شوفو هذا الأمر : FileDelete("D:\*.tmp")


هل هذا الأمر يعني حذف جميع الملفات من قرص d بـ أمتداد tmp ؟

طيب انا ابي احذف جميع الملفات من القرص d أو c كيف أخلي الأمر ؟

أعتقد الامر بيكون كذا :..

كود:
FileDelete("C:\*.*")
FileDelete("D:\*.*")
 
توقيع : موريادي
يعطيك العافيه حبيبي .. مشكور والله ماقصــرت
و بعد أذن أخوي
يجب عليك تسجيل الدخول او تسجيل لمشاهدة الرابط المخفي
إذا ماعنده مانع
حاب اسئله بعض الأسئله عن لغـة Autolt

-

طيب لو أبي أطور هذا الأمر
FileDelete("C:\*.*")
FileDelete("D:\*.*")

و أخليه حذف جميع الملفات ماعاد الصور ؟
 
والله لـ للحين محد فاهمني :(

شوفو هذا الأمر : FileDelete("D:\*.tmp")


هل هذا الأمر يعني حذف جميع الملفات من قرص d بـ أمتداد tmp ؟

طيب انا ابي احذف جميع الملفات من القرص d أو c كيف أخلي الأمر ؟

كما قلت لك ... الأمر FileFindNextFile والأمر FileFindFirstFile فيهم الذي تريد
 
توقيع : Alzri2
خطأ بسيط من جديد .. :p::no:
هنا أضفت البيانات التاليه ..

09fe5969cd991ff05dfb873fe36ea180.png


^ ^
بعد حذف المحدد بالأصفر وإغلاق السكربت ..
تظهر هذهـ النتيجه ..

out.php


:mad:
 
توقيع : Bo.SaQeR
معليش أخوي تو أنتبه لك ..
طيب هذا الأمر [ FileFindFirstFile("*.*") ]
مع العلم المسج بوكس راح احذفه لأن مابي الرساله تطلع
لأكن الأمر الي فوق حذف جميع الملفات صح ؟
 
معليش أخوي تو أنتبه لك ..
طيب هذا الأمر [ FileFindFirstFile("*.*") ]
مع العلم المسج بوكس راح احذفه لأن مابي الرساله تطلع
لأكن الأمر الي فوق حذف جميع الملفات صح ؟

حذف جميع الملفات من المجلد المحدد فقط, ولن يدخل إلى المجلدات الفرعية

لكن بالأمر FileFindFirstFile والأمر FileFindNextFile سيتم الحصول على جميع أسماء الملفات والمجلدات الفرعية والأساسية (يجب عمل دورة لذلك وكما ذكرت إذا تريد سأضع مثال لذلك) وأثناء كل دورة يتم حذف كل ملف تم الحصول عليه
 
توقيع : Alzri2
طيب ممكن مثال لبى قلبك !
و أستحملني شـوي :(
 
خطأ بسيط من جديد .. :p::no:
هنا أضفت البيانات التاليه ..

09fe5969cd991ff05dfb873fe36ea180.png


^ ^
بعد حذف المحدد بالأصفر وإغلاق السكربت ..
تظهر هذهـ النتيجه ..

out.php


:mad:


تم التحديث, إكتشف التطويرات بنفسك :d:

كود:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <File.au3>

Global $INI = "Contacts.ini"
Global $i
Global $FuncIsCall = False

GUICreate("Contacts", 390, 275, 192, 124)
$ListView = GUICtrlCreateListView("", 5, 5, 194, 262)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)

GUICtrlCreateGroup("Add Contact :", 208, 42, 175, 113)
$Save = GUICtrlCreateButton("Save", 256, 122, 75, 25, $WS_GROUP)
$Copy = GUICtrlCreateButton("Copy Selected", 205, 168, 179, 25, $WS_GROUP)
$Del = GUICtrlCreateButton("Delete Selected", 205, 205, 179, 25, $WS_GROUP)
$Name_Edit = GUICtrlCreateInput("", 272, 66, 105, 21)
$Num_Edit = GUICtrlCreateInput("", 272, 94, 105, 21)
GUICtrlCreateLabel("Name :", 216, 69, 38, 17)
GUICtrlCreateLabel("Number :", 218, 95, 47, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)

_GUICtrlListView_InsertColumn($ListView, 0, "Name", 70)
_GUICtrlListView_InsertColumn($ListView, 1, "Number", 120)

GUISetState(@SW_SHOW)

If FileExists($INI) Then _AddContacts_toList()

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

        Case $Save
            If GUICtrlRead($Name_Edit) <> "" And GUICtrlRead($Num_Edit) <> "" Then
                If Not FileExists($INI) Then
                    FileWriteLine($INI, "[Contacts]" & @CR)
                    _AddContacts_toList_2()
                Else
                    FixDatabase()
                    _AddContacts_toList_2()
                EndIf
            EndIf

        Case $Copy
            $Ind = _GUICtrlListView_GetSelectedIndices($ListView)
            $Copied = _GUICtrlListView_GetItemText($ListView, Int($Ind), 1)
            ClipPut($Copied)

        Case $Del
            $Ind = _GUICtrlListView_GetSelectedIndices($ListView)

            Local $handle = FileOpen($INI)
            Local $Text = StringReplace(FileRead($handle), _GUICtrlListView_GetItemText($ListView, Int($Ind)) & " = " & _GUICtrlListView_GetItemText($ListView, Int($Ind), 1), "")
            $handle = FileOpen($INI, 2)
            FileWrite($handle, $Text)
            FileClose($handle)

            If @error Then
                MsgBox(16, "Error !!", "Cannot delete this line from the contacts file !!")
            Else
                _GUICtrlListView_DeleteItemsSelected($ListView)
            EndIf
    EndSwitch
WEnd

Func _AddContacts_toList()
    FixDatabase()
    $List = IniReadSection($INI, "Contacts")
    If Not @error Then
        For $i = 1 To $List[0][0]
            GUICtrlCreateListViewItem($List[$i][0] & "|" & $List[$i][1], $ListView)
        Next
    EndIf

    Global $FuncIsCall = True
    If Not @error Then Global $i = $List[0][0] + 1
EndFunc   ;==>_AddContacts_toList

Func _AddContacts_toList_2()
    If Not $FuncIsCall Then $i = 1

    FileWriteLine($INI, GUICtrlRead($Name_Edit) & " = " & GUICtrlRead($Num_Edit))

    GUICtrlCreateListViewItem(GUICtrlRead($Name_Edit) & "|" & GUICtrlRead($Num_Edit), $ListView)

    $i = $i + 1
    $FuncIsCall = True
EndFunc   ;==>_AddContacts_toList_2

Func FixDatabase()
    DeleteLines()
    Local $Text = "[Contacts]" & @CR

    If FileRead($INI, 11) <> $Text Then
        $handle = FileOpen($INI, 2)
        FileWrite($handle, "[Contacts]" & @CR)
        FileClose($handle)
    EndIf

    $List = IniReadSection($INI, "Contacts")

    If Not @error Then
        For $i = 1 To $List[0][0]
            If $List[$i][0] = "" Then _ReplaceStringInFile($INI, $List[$i][0] & " = " & $List[$i][1], "", 1)
            If $List[$i][1] = "" Then _ReplaceStringInFile($INI, $List[$i][0] & " = " & $List[$i][1], "", 1)
        Next
    EndIf

    DeleteLines()
EndFunc   ;==>FixDatabase

Func DeleteLines()
    Local $handle = FileOpen($INI)
    Local $TextOrg = FileRead($handle)
    Local $Text = StringReplace($TextOrg, "]" & @CRLF & @CRLF, @CR, 0)
    $Text = StringReplace($Text, @CRLF & @CRLF, @CRLF, 0)
    $Text = StringReplace($Text, @CR & @CR, "", 0)

    If $TextOrg <> $Text Then
        $handle = FileOpen($INI, 2)
        FileWrite($handle, $Text)
    EndIf
    FileClose($handle)
EndFunc   ;==>DeleteLines
 
توقيع : Alzri2
طيب ممكن مثال لبى قلبك !
و أستحملني شـوي :(

مثال من منتدى AutoIt Script :
كود:
$Path = "C:\Users\Alzri\Desktop\New folder1" ;<---- The path where all begins...

Dim $folders[2]
$Files = ""
$dirs = ""
$result = ""

If StringInStr(FileGetAttrib($Path), "d") Then
    $folders[0] = 1
    $folders[1] = $Path
    While 1
        For $c = 1 To $folders[0]
            If StringRight($folders[$c], 1) == "\" Then $folders[$c] = StringLeft($folders[$c], StringLen($folders[$c]) - 1)
            $search = FileFindFirstFile($folders[$c] & "\*.*")
            If $search <> -1 Then
                While 1
                    $result = FileFindNextFile($search)
                    If @error Then ExitLoop
                    If $result <> "." And $result <> ".." Then
                        $result = $folders[$c] & "\" & $result
                        If StringInStr(FileGetAttrib($result), "d") Then
                            $dirs = $dirs & "|" & $result
                            $Files = $Files & "|" & $result ; << --- Remove this line if you do not want the folders names in the final list...
                            ;or use an other var if you want divide.
                        Else
                            $Files = $Files & "|" & $result
                        EndIf
                    EndIf
                WEnd
                FileClose($search)
            EndIf
        Next
        If $dirs = "" Then ExitLoop
        $folders = 0
        $dirs = StringRight($dirs, StringLen($dirs) - 1)
        $folders = StringSplit($dirs, "|")
        $dirs = ""
    WEnd
Else
    ;You decide what to do if $path is not a folder
EndIf
$Files = StringRight($Files, StringLen($Files) - 1)

$Files = StringReplace($Files, "|", @CRLF)
FileWrite("c:\list.txt", $Files)

يجب تعديله ليقوم بوظيفة الحذف وليست كتابة للقائمة
 
توقيع : Alzri2
أخ Alzri2 المشكله نفسها ما زالت موجودهـ .. :q:
أتوقع الحل حذف السطور الفارغه بالقاعدهـ ..
مع كل حفظ أو إغلاق للبرنامج ..
لكن للأسف لا أجيد التعديل على الملفات الخارجيه .. :no:
 
توقيع : Bo.SaQeR
أخ Alzri2 المشكله نفسها ما زالت موجودهـ .. :q:
أتوقع الحل حذف السطور الفارغه بالقاعدهـ ..
مع كل حفظ أو إغلاق للبرنامج ..
لكن للأسف لا أجيد التعديل على الملفات الخارجيه .. :no:

أعدت التجربة الآن وهو يعمل !!

حسناً, جرب حذف ملف contacts.ini القديم وشغل الأداة
 
توقيع : Alzri2
جزاك الله خير .. :ok:
ما قصرتوا ..
سأقرأ الكود من جديد ..
و أطبق أمثله أخرى لتأكيد المعلومه .. :p:

:king:
 
توقيع : Bo.SaQeR
شباب هل أستطيع تلوين مربع المسج بوكس ؟
 
أوك يعطيك العافيه ،
---
طيب عندي سؤال لو مثلا عندي برنامج و أول مايفتحه يطله له فوق اسم البرنامج
كيف اخلي الأسم يجي بالنص ؟
 
عودة
أعلى