Jump to content

filename as parameter


Recommended Posts

hello,

i want to help my users to do a annoying job.

make a script that do their job, only request is complete file path as variable.

Which is best way to drag & drop file (autoit code) over my .exe ad set this file as my input parameter ?

thank you,

(and sorry for bad english)

m.

Link to comment
Share on other sites

hello,

i want to help my users to do a annoying job.

make a script that do their job, only request is complete file path as variable.

Which is best way to drag & drop file (autoit code) over my .exe ad set this file as my input parameter ?

thank you,

(and sorry for bad english)

m.

Help
Link to comment
Share on other sites

This may get you started.

#NoTrayIcon
#include <GUIConstants.au3>

If $CMDLine[0] = 0 Then
    $PathGUI = GUICreate('Drag & Drop File', 454, 75, -1, -1, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_WINDOWEDGE))
    GUICtrlCreateLabel('File Path:', 8, 10, 48, 17)
    $FilePath_inp = GUICtrlCreateInput('', 56, 8, 393, 21)
    GUICtrlSetState($FilePath_inp, $GUI_DROPACCEPTED)
    $Ok_btn = GUICtrlCreateButton('Ok', 136, 40, 75, 25, 0)
    $Close_btn = GUICtrlCreateButton('Close', 256, 40, 75, 25, 0)
    GUISetState(@SW_SHOW)

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $Close_btn, $GUI_EVENT_CLOSE
                Exit
            Case $Ok_btn
                $FilePath = GUICtrlRead($FilePath_inp)
                If $FilePath = '' Then
                    MsgBox(48, 'Drag & Drop', 'You need to drag and drop a file.')
                    ContinueLoop
                ElseIf FileGetAttrib($FilePath) = 'D' Then
                    MsgBox(48, 'Drag & Drop', 'You need to drag and drop a file not a folder.')
                    GUICtrlSetData($FilePath_inp, '')
                    ContinueLoop
                EndIf
                If @Compiled Then
                    Run(@ScriptFullPath & ' "' & $FilePath & '"', @ScriptDir)                   
                Else
                    Run(@AutoItExe & ' "' & @ScriptFullPath & '" "' & $FilePath & '"', @ScriptDir)
                EndIf
                Exit
        EndSwitch
    WEnd
Else
    $FilePath = $CMDLine[1]
EndIf

; Start your code from here....
MsgBox(0, 'Select File', $FilePath)

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...