Sign in to follow this  
Followers 0
islandspapand

Inputbox Drag and Drop Help

8 posts in this topic

Hello I am a noob to autoit and programming and have just startet a small project.

I have run into a problem I hope someone can help me with.

I have a GUI with a two Inputboxes with drag and drop function and this are the problemes i have run in to.

1# Restrict the inputboxes to only accept files with the extision .bin or .txt

2# Reading the .txt file dropt in the inputbox and then writing som of the txt to a label in the GUI

Here is a little exsample of what i have tried:

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <String.au3>
#include <File.au3>
#include <Array.au3>
#include <Date.au3>
#include <Process.au3>
#include <ProgressConstants.au3>


    If FileExists(@TempDir & "\lstdsk.ini") Then
        FileDelete(@TempDir & "\lstdsk.ini")
    EndIf
    $File = FileOpen(@TempDir & '\lstdsk.ini', 2)
    FileWrite($File, 'list disk')
    FileClose($File)
    If FileExists(@TempDir & "\lstdsk.txt") Then
    FileDelete(@TempDir & "\lstdsk.txt")
    EndIf
    RunWait('cmd /c diskpart /s lstdsk.ini > lstdsk.txt', @TempDir, @SW_HIDE)
    $szFile = @TempDir & "\lstdsk.txt"
    $szText = FileRead($szFile, FileGetSize($szFile))
    $szText = StringReplace($szText, "  disk", "Drive")
    $szText = StringReplace($szText, "    online", "")
    FileDelete($szFile)
    FileWrite($szFile, $szText)
    ;***********************end of edit**************************
    Local $Line, $Array = _StringExplode(FileRead(@TempDir & '\lstdsk.txt'), @LF)
    For $i = 0 To UBound($Array) - 1
        If StringRegExp($Array[$i], '(?i)drive [\d]+') Then $Line &= $Array[$i] & '|'
    Next
    $Line = StringRegExpReplace($Line, '[\s|]*$', '') ;trim spaces, returns, line breaks, and pipes from end of the string
    ;************************************end*****************





#Region ### START Koda GUI section ### Form=C:\Users\Krabben\Desktop\##Recovery Source Codes##\GUIRecovery Restore.kxf
$GUIRecovery = GUICreate("Recovery Manager Restore", 279, 275, 292, 320, -1, BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE,$WS_EX_ACCEPTFILES))
$MenuFile = GUICtrlCreateMenu("&File")
$MenuFileAD = GUICtrlCreateMenuItem("Advanced Menu", $MenuFile)
$MenuFileEX = GUICtrlCreateMenuItem("Exit", $MenuFile)
$MenuH = GUICtrlCreateMenu("&Help")
$MenuHAB = GUICtrlCreateMenuItem("About", $MenuH)
$MenuHH = GUICtrlCreateMenuItem("Help", $MenuH)
$MenuItem1 = GUICtrlCreateMenu("License")
$NextB = GUICtrlCreateButton("Next", 8, 216, 265, 33, BitOR($BS_DEFPUSHBUTTON,$WS_GROUP), $WS_EX_STATICEDGE)
$DskLST = GUICtrlCreateList("", 8, 32, 113, 123, BitOR($LBS_SORT,$LBS_STANDARD,$WS_VSCROLL,$WS_BORDER))
GUICtrlSetData(-1, $Line)
$Dsklabel = GUICtrlCreateLabel("Select Your Disk", 8, 8, 110, 17, $SS_CENTERIMAGE)
$MBRDROP = GUICtrlCreateInput("", 128, 32, 137, 25)
GUICtrlSetState($MBRDROP, $GUI_ACCEPTFILES)
$LOGDROP = GUICtrlCreateInput("", 128, 88, 137, 25)
GUICtrlSetState($LOGDROP, $GUI_FOCUS & $GUI_ACCEPTFILES)
$DropL = GUICtrlCreateLabel("Drop Your MBR File Here", 128, 9, 133, 17, $SS_CENTER)
$OSL = GUICtrlCreateLabel("Drop Log File Here", 144, 64, 102, 17)
$TrueCH = GUICtrlCreateRadio("True", 136, 176, 41, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$FalseCH = GUICtrlCreateRadio("False", 201, 178, 41, 17)
$OS = GUICtrlCreateGroup("    OS Version    ", 128, 120, 137, 81, $BS_CENTER)
$OSVL = GUICtrlCreateLabel("", 144, 144, 100, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$PRODLA = GUICtrlCreateGroup("Producent", 8, 160, 113, 41)
$PROL = GUICtrlCreateLabel("", 16, 176, 92, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState()
#EndRegion ### END Koda GUI section ###


GUICtrlSetState($NextB, $GUI_DEFBUTTON)

; Display GUI and wait for action
GUISetState(@SW_SHOW)
While 1

        $msg = GUIGetMsg()
        Switch $msg

            Case $GUI_Event_close
                Exit

            Case $GUI_EVENT_DROPPED
                ;GUICtrlSetData($LOGDROP, @GUI_DRAGFILE & @CRLF, 1)
                Dim $TEXT[11]
                $FILE = FileOpen(@GUI_DRAGFILE,0)
                For $INDEX = 11 To 12
                $TEXT[$INDEX-11] = FileReadLine($FILE,$INDEX)
                Next
                FileClose($FILE)
                GUICtrlSetData($OSVL,Send ($TEXT,1))

            Case $NextB
               Exit
           Case $MenuFileEX
                Exit


        EndSwitch

    WEnd

Share this post


Link to post
Share on other sites



Have a look here >>


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

thnx but not quite what i am looking for.

my biggeste probleme is to restric the inputboxes to only accept files that end on .bin and .txt

Share this post


Link to post
Share on other sites

Monitor when the file is Dropped and then use _IsValidType() in my signature.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

thnx allot i can see how i can use it i just dont know how to add it to my script.

I am like a real NoooB :huh2:

Updatet

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <String.au3>
#include <File.au3>
#include <Array.au3>
#include <Date.au3>
#include <Process.au3>
#include <ProgressConstants.au3>


    If FileExists(@TempDir & "\lstdsk.ini") Then
        FileDelete(@TempDir & "\lstdsk.ini")
    EndIf
    $File = FileOpen(@TempDir & '\lstdsk.ini', 2)
    FileWrite($File, 'list disk')
    FileClose($File)
    If FileExists(@TempDir & "\lstdsk.txt") Then
    FileDelete(@TempDir & "\lstdsk.txt")
    EndIf
    RunWait('cmd /c diskpart /s lstdsk.ini > lstdsk.txt', @TempDir, @SW_HIDE)
    $szFile = @TempDir & "\lstdsk.txt"
    $szText = FileRead($szFile, FileGetSize($szFile))
    $szText = StringReplace($szText, "  disk", "Drive")
    $szText = StringReplace($szText, "    online", "")
    FileDelete($szFile)
    FileWrite($szFile, $szText)
    ;***********************end of edit**************************
    Local $Line, $Array = _StringExplode(FileRead(@TempDir & '\lstdsk.txt'), @LF)
    For $i = 0 To UBound($Array) - 1
        If StringRegExp($Array[$i], '(?i)drive [\d]+') Then $Line &= $Array[$i] & '|'
    Next
    $Line = StringRegExpReplace($Line, '[\s|]*$', '') ;trim spaces, returns, line breaks, and pipes from end of the string
    ;************************************end*****************



$GUIRecovery = GUICreate("Recovery Manager Restore", 289, 276, 292, 320, -1, BitOR($WS_EX_ACCEPTFILES,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
$MenuFile = GUICtrlCreateMenu("&File")
$MenuFileAD = GUICtrlCreateMenuItem("Advanced Menu", $MenuFile)
$MenuFileEX = GUICtrlCreateMenuItem("Exit", $MenuFile)
$MenuH = GUICtrlCreateMenu("&Help")
$MenuHAB = GUICtrlCreateMenuItem("About", $MenuH)
$MenuHH = GUICtrlCreateMenuItem("Help", $MenuH)
$MenuItem1 = GUICtrlCreateMenu("&License")
$NextB = GUICtrlCreateButton("Next", 8, 216, 265, 33, BitOR($BS_DEFPUSHBUTTON,$WS_GROUP), $WS_EX_STATICEDGE)
$DskLST = GUICtrlCreateList("", 8, 32, 113, 175, BitOR($LBS_SORT,$LBS_STANDARD,$WS_VSCROLL,$WS_BORDER))
GUICtrlSetData(-1, $Line)
$Dsklabel = GUICtrlCreateLabel("Select Your Disk", 8, 8, 110, 17, $SS_CENTERIMAGE)
$MBRDROP = GUICtrlCreateInput("", 128, 32, 153, 21)
GUICtrlSetState($MBRDROP, $GUI_ACCEPTFILES)
$LOGDROP = GUICtrlCreateInput("", 128, 88, 153, 21)
GUICtrlSetState($LOGDROP, $GUI_FOCUS & $GUI_ACCEPTFILES)
$DropL = GUICtrlCreateLabel("Drop Your MBR File Here", 136, 9, 133, 17, $SS_CENTER)
$OSL = GUICtrlCreateLabel("Drop Log File Here", 152, 64, 102, 17)
$OS = GUICtrlCreateGroup("OS Version", 208, 136, 73, 41, $BS_CENTER)
$OSVL = GUICtrlCreateLabel("", 224, 152, 52, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$PRODLA = GUICtrlCreateGroup("Producent", 128, 136, 73, 41)
$PROL = GUICtrlCreateLabel("", 136, 152, 60, 20, $SS_CENTER)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$InfoLABel = GUICtrlCreateLabel("   Er det Følgende Info Rigitigt?", 128, 112, 150, 17)
$TRUECH = GUICtrlCreateRadio(" True", 136, 184, 65, 25)
GUICtrlSetState(-1, $GUI_CHECKED)
$FALSECH= GUICtrlCreateRadio(" False", 216, 184, 65, 25)
GUISetState()


GUICtrlSetState($NextB, $GUI_DEFBUTTON)

; Display GUI and wait for action
GUISetState(@SW_SHOW)
While 1

        $msg = GUIGetMsg()
        Switch $msg

            Case $GUI_Event_close
                Exit

            Case $GUI_EVENT_DROPPED
                If GUICtrlRead($LOGDROP) = @GUI_DragFile Then
                $OSVline = FileReadLine(@GUI_DragFile, 11)
                $PDline = FileReadLine(@GUI_DragFile, 5)
                GUICtrlSetData($OSVL, $OSVline)
                GUICtrlSetData($PROL, $PDline)
                EndIf




            Case $NextB
               Exit
           Case $MenuFileEX
                Exit


        EndSwitch

    WEnd

EndFunc

Func _IsValidType($sFilePath, $sList = "bat;cmd;exe")
    Local $sMask
    If StringRegExp($sList, "\\|/|:|\<|\>|\|") Then
        Return SetError(1, 0, -1)
    EndIf
    $sList = "*." & StringReplace(StringStripWS(StringRegExpReplace($sList, "\s*;\s*", ";"), 3), ";", "|*.")
    $sList = StringReplace(StringReplace(StringRegExpReplace($sList, "(\^|\$|\.)", "\\$1"), "?", "."), "*", ".*?")
    $sMask = "(?i)^(" & $sList & ")\z"
    If StringRegExp($sFilePath, $sMask) Then
        Return 1
    EndIf
    Return 0
EndFunc   ;==>_IsValidType
Edited by islandspapand

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Try this:

#include <APIConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListBoxConstants.au3>
#include <StaticConstants.au3>
#include <String.au3>
#include <WindowsConstants.au3>


    If FileExists(@TempDir & "\lstdsk.ini") Then
        FileDelete(@TempDir & "\lstdsk.ini")
    EndIf
    $File = FileOpen(@TempDir & '\lstdsk.ini', 2)
    FileWrite($File, 'list disk')
    FileClose($File)
    If FileExists(@TempDir & "\lstdsk.txt") Then
    FileDelete(@TempDir & "\lstdsk.txt")
    EndIf
    RunWait('cmd /c diskpart /s lstdsk.ini > lstdsk.txt', @TempDir, @SW_HIDE)
    $szFile = @TempDir & "\lstdsk.txt"
    $szText = FileRead($szFile, FileGetSize($szFile))
    $szText = StringReplace($szText, "  disk", "Drive")
    $szText = StringReplace($szText, "    online", "")
    FileDelete($szFile)
    FileWrite($szFile, $szText)
    ;***********************end of edit**************************
    Local $Line, $Array = _StringExplode(FileRead(@TempDir & '\lstdsk.txt'), @LF)
    For $i = 0 To UBound($Array) - 1
        If StringRegExp($Array[$i], '(?i)drive [\d]+') Then $Line &= $Array[$i] & '|'
    Next
    $Line = StringRegExpReplace($Line, '[\s|]*$', '') ;trim spaces, returns, line breaks, and pipes from end of the string
    ;************************************end*****************





#Region ### START Koda GUI section ### Form=C:\Users\Krabben\Desktop\##Recovery Source Codes##\GUIRecovery Restore.kxf
$GUIRecovery = GUICreate("Recovery Manager Restore", 279, 275, 292, 320, -1, BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE,$WS_EX_ACCEPTFILES))
$MenuFile = GUICtrlCreateMenu("&File")
$MenuFileAD = GUICtrlCreateMenuItem("Advanced Menu", $MenuFile)
$MenuFileEX = GUICtrlCreateMenuItem("Exit", $MenuFile)
$MenuH = GUICtrlCreateMenu("&Help")
$MenuHAB = GUICtrlCreateMenuItem("About", $MenuH)
$MenuHH = GUICtrlCreateMenuItem("Help", $MenuH)
$MenuItem1 = GUICtrlCreateMenu("License")
$NextB = GUICtrlCreateButton("Next", 8, 216, 265, 33, BitOR($BS_DEFPUSHBUTTON,$WS_GROUP), $WS_EX_STATICEDGE)
$DskLST = GUICtrlCreateList("", 8, 32, 113, 123, BitOR($LBS_SORT,$LBS_STANDARD,$WS_VSCROLL,$WS_BORDER))
GUICtrlSetData(-1, $Line)
$Dsklabel = GUICtrlCreateLabel("Select Your Disk", 8, 8, 110, 17, $SS_CENTERIMAGE)
$MBRDROP = GUICtrlCreateInput("", 128, 32, 137, 25)
GUICtrlSetState($MBRDROP, $GUI_ACCEPTFILES)
$LOGDROP = GUICtrlCreateInput("", 128, 88, 137, 25)
GUICtrlSetState($LOGDROP, $GUI_FOCUS & $GUI_ACCEPTFILES)
$DropL = GUICtrlCreateLabel("Drop Your MBR File Here", 128, 9, 133, 17, $SS_CENTER)
$OSL = GUICtrlCreateLabel("Drop Log File Here", 144, 64, 102, 17)
$TrueCH = GUICtrlCreateRadio("True", 136, 176, 41, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$FalseCH = GUICtrlCreateRadio("False", 201, 178, 41, 17)
$OS = GUICtrlCreateGroup("    OS Version    ", 128, 120, 137, 81, $BS_CENTER)
$OSVL = GUICtrlCreateLabel("", 144, 144, 100, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$PRODLA = GUICtrlCreateGroup("Producent", 8, 160, 113, 41)
$PROL = GUICtrlCreateLabel("", 16, 176, 92, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState()
#EndRegion ### END Koda GUI section ###


GUICtrlSetState($NextB, $GUI_DEFBUTTON)

; Display GUI and wait for action
GUISetState(@SW_SHOW)

While 1

        $msg = GUIGetMsg()
        Switch $msg

            Case $GUI_Event_close
                Exit

            Case $GUI_EVENT_DROPPED
                ;GUICtrlSetData($LOGDROP, @GUI_DRAGFILE & @CRLF, 1)
                $ext = StringRight(@GUI_DragFile, 4)
                Switch @GUI_DropId
                    Case $MBRDROP
                        If $ext <> ".bin" Then
                            GUICtrlSetData($MBRDROP, "")
                        Else
                            DropAction(@GUI_DragFile)
                        EndIf
                    Case $LOGDROP
                        If $ext <> ".txt" Then
                            GUICtrlSetData($LOGDROP, "")
                        Else
                            DropAction(@GUI_DragFile)
                        EndIf
                EndSwitch
            Case $NextB
               Exit
           Case $MenuFileEX
                Exit
        EndSwitch

WEnd

Func DropAction($dropped)
    Local $TEXT
    $FILE = FileOpen($dropped,0)
    For $INDEX = 11 To 12
        $TEXT &= FileReadLine($FILE,$INDEX) & @CRLF
    Next
    FileClose($FILE)
    GUICtrlSetData($OSVL, $TEXT)
EndFunc

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Thanx you so much UEZ

It work :huh2:

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

For future use using _IsValidType() >>

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

_Main()

Func _Main()
    Local $iLabel

    GUICreate("Simple Drop", 255, 155, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX), $WS_EX_ACCEPTFILES)
    $iLabel = GUICtrlCreateLabel("Drop Supported FileType (txt/bin)", 2, 2, 250, 150, $SS_CENTER)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $GUI_EVENT_DROPPED
                If _IsValidType(@GUI_DragFile, "bin;txt") Then
                    GUICtrlSetData($iLabel, "Dropped - " & @GUI_DragFile)
                Else
                    GUICtrlSetData($iLabel, 'I said "Supported FileType!"')
                EndIf

        EndSwitch
    WEnd
EndFunc   ;==>_Main

; #FUNCTION# =========================================================================================================
; Name...........: _IsValidType
; Description ...: Checks if a filepath contains an approved filetype extension.
; Syntax.........: _IsValidType($sFilePath, [$sList])
;                  $sFilePath - File path of the file.
;                  $sList - [Optional] A list of filetype extensions separated with ';' e.g. "zip;rar;7zip;gzip"
; Parameters ....: None
; Requirement(s).: v3.2.2.0 or higher
; Return values .: Success - Return 1 = Valid filetype or 0 = InValid filetype
;                  Failure - Returns -1 & sets @error = 1
; Author ........: guinness
; Example........; Yes
; Remarks........; The code is based on the original function of _RFLTA_ListToMask() by Melba23
;=====================================================================================================================
Func _IsValidType($sFilePath, $sList = "bat;cmd;exe")
    Local $sMask
    If StringRegExp($sList, "\\|/|:|\<|\>|\|") Then
        Return SetError(1, 0, -1)
    EndIf
    $sList = "*." & StringReplace(StringStripWS(StringRegExpReplace($sList, "\s*;\s*", ";"), 3), ";", "|*.")
    $sList = StringReplace(StringReplace(StringRegExpReplace($sList, "(\^|\$|\.)", "\\$1"), "?", "."), "*", ".*?")
    $sMask = "(?i)^(" & $sList & ")\z"
    If StringRegExp($sFilePath, $sMask) Then
        Return 1
    EndIf
    Return 0
EndFunc   ;==>_IsValidType
Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

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
Sign in to follow this  
Followers 0