Jump to content

Another Send To toy


GEOSoft
 Share

Recommended Posts

I wrote this acouple of years ago and just dragged it out of the archives today to update some of the syntax

Download the file HERE

The download file includes the latest version of the script and a setup.exe file in case you want to install it on your system.

The script must be compiled to use it.

#cs
    AutoIt Version:     3.0.103.149
    Language:           English (United States)
    Platform:                  All
    Author:                 GEOSoft ©
    Script Function:   New SendTo Power toys
    Script Version: 1.2.2.1 (debug) (September 21 /2005 12:48 PM)
#ce

#NoTrayIcon
$INI = @ScriptDir & '\SendTo.ini'
If $CMDLINE[0] > 1 Then
    $FILE = FileGetLongName($CMDLINE[2])
    Select
        Case $CMDLINE[1] == '-c' ;;<<
            ClipPut('')
            $OUT = ''
            For $I = 2 To $CMDLINE[0]
                $FILE = FileGetLongName($CMDLINE[$I])
                If StringInStr($FILE, CHR(32)) > 0 Then $FILE = CHR(34) & $FILE & CHR(34)
                $OUT &= $FILE & @CRLF
            Next
            $OUT = StringStripWS($OUT, 2)
            ClipPut($OUT)
        Case $CMDLINE[1] == '-r' ;;<<========= Command line
            $Valid = ".exe|.com|.bat|.cmd|" ;;<<=== Valid file types Be sure to add the pipe
            If StringInStr($Valid, StringRight($File, 4) & '|' Then
                ;If StringRight($FILE, 4) = '.exe' OR StringRight($FILE, 4) = '.com' OR StringRight($FILE, 4) = '.bat' Then ;; Replaced above
                If StringInStr($FILE, CHR(32)) > 0 Then $FILE = CHR(34) & $FILE & CHR(34)
                Run(@ComSpec, '', @SW_MAXIMIZE)
                Sleep(250)
                Send( '"' & $FILE & '"')
            Else
                MsgBox(4096, 'File type invalid', 'The selected file is not a Win32 executable or batch file.')
            EndIf
        Case $CMDLINE[1] == '-C' OR $CMDLINE[1] == '-M' ;;<<===== Copy (-C) or move (-M) the file
            If FileExists($INI) > 0 Then
                $DEF = IniRead($INI, 'Files', 'Last Folder', @WorkingDir)
            Else
                $DEF = @WorkingDir
            EndIf
            $COPY_FLDR = FileSelectFolder('Select the folder to copy or move the file(s) to', '', 3, $DEF)
            If @error Then Exit
            IniWrite($INI, 'Files', 'Last Folder', $COPY_FLDR)
            For $I = 2 To $CMDLINE[0]
                $FILE = FileGetLongName($CMDLINE[$I])
                $FN = StringMid($FILE, StringInStr($FILE, '\', 0, -1) + 1)
                $NEW_FILE = $COPY_FLDR & '\' & $FN
                If FileExists($NEW_FILE) > 0 Then
                    $TS_1 = Get_DateTime(FileGetTime($NEW_FILE))
                    $FD_1 = $COPY_FLDR & $FN & @CRLF & Round(FileGetSize($NEW_FILE) / 1024, 2) & ' kb' & @CRLF & 'modified ' & $TS_1
                    $TS_2 = Get_DateTime(FileGetTime($FILE))
                    $FD_2 = $FILE & @CRLF & Round(FileGetSize($FILE) / 1024, 2) & ' kb' & @CRLF & 'modified ' & $TS_2
                    $WARNING = MsgBox(262180, 'File Warning', 'This folder already contains a file named ' & $FN & @CRLF & @CRLF & 'Do you wish to replace' & @CRLF & $FD_1 & @CRLF & @CRLF & 'With this one?' & @CRLF & @CRLF & $FD_2)
                    If $WARNING = 6 Then
                        $FC = FileCopy($FILE, $NEW_FILE, 1)
                        If $FC = 0 Then
                            MsgBox(262192, 'File Copy Error', 'Unable to copy ' & $FILE & ' to ' & $NEW_FILE & '.' & @CRLF & 'The file may be in use. Please close the application and try again.')
                            ContinueLoop
                        EndIf
                        If $CMDLINE[1] == '-M' Then FileDelete($FILE)
                    Else
                        ContinueLoop
                    EndIf
                Else
                    $FC = FileCopy($FILE, $NEW_FILE, 1)
                    
                    If $FC = 0 Then MsgBox(262192, 'File Copy Error', 'An error has occured while copying ' & $FILE)
                EndIf
            Next
        Case $CMDLINE[1] == '-R' ;;<<=========  Run dialog
            ClipPut($FILE)
            Send('#{r}')
            Sleep(100)
            Send('^{v}')
            ClipPut('')
            ;Send('{ENTER}') Removed so parameters can be added to the run dialog
        Case $CMDLINE[1] == '-f'  ;;<<=====  Send to Favorites
            $FAV_FLDR = @FavoritesDir & '\'
            For $I = 2 To $CMDLINE[0]
                $FILE = FileGetLongName($CMDLINE[$I])
                $FN = StringMid($FILE, StringInStr($FILE, '\', 0, -1) + 1)
                $NEW_FILE = $FAV_FLDR & '\' & $FN
                If FileExists($NEW_FILE) > 0 Then
                    $TS_1 = Get_DateTime(FileGetTime($NEW_FILE))
                    $FD_1 = $FAV_FLDR & $FN & @CRLF & Round(FileGetSize($NEW_FILE) / 1024, 2) & ' kb' & @CRLF & 'modified ' & $TS_1
                    $TS_2 = Get_DateTime(FileGetTime($FILE))
                    $FD_2 = $FILE & @CRLF & Round(FileGetSize($FILE) / 1024, 2) & ' kb' & @CRLF & 'modified ' & $TS_2
                    $WARNING = MsgBox(262180, 'Warning', 'This folder already contains a file named ' & $FN & @CRLF & @CRLF & 'Do you wish to replace' & @CRLF & $FD_1 & @CRLF & @CRLF & 'With this one?' & @CRLF & @CRLF & $FD_2)
                    If $WARNING = 6 Then
                        $FC = FileCopy($FILE, $NEW_FILE, 1)
                        If $FC = 0 Then
                            MsgBox(262192, 'Copy Error', 'Unable to copy ' & $FILE & ' to ' & $NEW_FILE & '.' & @CRLF & 'The file may be in use. Please close the application and try again.')
                            ContinueLoop
                        EndIf
                    Else
                        ContinueLoop
                    EndIf
                Else
                    FileCopy($FILE, $NEW_FILE, 1)
                EndIf
            Next
        Case $CMDLINE[1] == '-d' ;;<<========  Directory list
            If Not StringInStr (FileGetAttrib ($File), "D") Then
                MsgBox ( 262160, 'ERROR!!', 'You have selected a file.' & @CRLF & 'The option is only valid for FOLDERS', 3)
            Else
                $File &= '\*'
                $oFile = @TempDir & '\Temp.txt'
                $fArray = ''
                If FileExists($oFile) Then FileDelete($oFile)
                $f = FileFindFirstFile($File)
                While 1
                    $Out = FileFindNextFile($f) 
                    If @error Then ExitLoop
                    If Not StringInStr($Out, '.') Then  $Out = '<DIR>' & Chr(9) & $Out
                    FileWriteLine($oFile,$Out)
                WEnd
                ShellExecuteWait($oFile)
                FileDelete($oFile)
            EndIf
        Case $CMDLINE[1] == '-m' ;;<<========  Send to Menu
            If StringRight($File, 4) <> '.exe' Then
                MsgBox ( 262160, 'ERROR!!', 'The option is only available for exe files', 3)
            Else
                $L_Name = StringMid($File, StringInStr($File, '\', 0, -1) +1)
                $L_Name = StringLeft($L_Name, StringInStr($L_Name, '.') -1)
                $L_Name = InputBox ( "Add Item", "Enter the display name of the new shortcut" , $L_Name, '', 150, 50)
                $ST_FLDR = RegRead('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 'Sendto') & '\'
                If Not FileExists($ST_FLDR & $L_Name & '.lnk') Then FileCreateShortcut($FILE, $ST_FLDR & $L_Name & '.lnk', '', '', '', $File, '', 0)
            EndIf
        Case Else
            Enable_GUI()
    EndSelect
Else
    Enable_GUI()
EndIf
Exit

Func Enable_GUI()
    $ST_FLDR = RegRead('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 'Sendto') & '\'
    $MAIN = GUICreate ('Send To links......', 300, 150)
    $LBL_1 = GUICtrlCreateLabel ('Include links on "Send To" menu....', 5, 5, 180, 20)
    $CLIP_CBX = GUICtrlCreateCheckbox ('Clipboard (as name)', 15, 20, 110, 20)
    If FileExists ($ST_FLDR & 'ClipBoard (as name).lnk') = 1 Then GUICtrlSetState ($CLIP_CBX, 1)
    $CMND_CBX = GUICtrlCreateCheckbox ('Command Line', 160, 20)
    If FileExists ($ST_FLDR & 'Command Line.lnk') = 1 Then GUICtrlSetState ($CMND_CBX, 1)
    $FLDR_CPY_CBX = GUICtrlCreateCheckbox ('Folder (Copy)', 15, 40)
    If FileExists ($ST_FLDR & 'Folder (Copy).lnk') = 1 Then GUICtrlSetState ($FLDR_CPY_CBX, 1)
    $FLDR_MOV_CBX = GUICtrlCreateCheckbox ('Folder (Move)', 160, 40)
    If FileExists ($ST_FLDR & 'Folder (Move).lnk') = 1 Then GUICtrlSetState ($FLDR_MOV_CBX, 1)
    $RUN_CBX = GUICtrlCreateCheckbox ('Run Line', 15, 60)
    If FileExists ($ST_FLDR & 'Run Dialog.lnk') = 1 Then GUICtrlSetState ($RUN_CBX, 1)
    $FAV_CBX = GUICtrlCreateCheckbox ('Favorites', 160, 60)
    If FileExists ($ST_FLDR & 'Favorites.lnk') = 1 Then GUICtrlSetState ($FAV_CBX, 1)
    $ST_CBX = GUICtrlCreateCheckbox('Add to "Send To" menu', 15, 80)
    If FileExists($ST_FLDR & 'Add to menu.lnk') Then GUICtrlSetState($ST_CBX, 1)
    $DIR_CBX = GUICtrlCreateCheckbox('Folder List (Text)', 160, 80)
    If FileExists($ST_FLDR & 'Folder List.lnk') Then GUICtrlSetState($DIR_CBX, 1)
    $OK_BTN = GUICtrlCreateButton ('OK', 120, 110, 60, 30, 1)
    GUISetHelp('hh.exe ' & @ScriptDir & '\SendTo.chm')
    GUISetState ()
    
    While 1
        $MSG = GUIGetMsg ()
        If $MSG = -3 Then Exit
        If $MSG = $OK_BTN Then
            If GUICtrlRead ($CLIP_CBX) = 1 AND FileExists ($ST_FLDR & 'ClipBoard (as name).lnk') < 1 Then
                FileCreateShortcut(@ScriptFullPath, $ST_FLDR & 'ClipBoard (as name).lnk', '', ' -c')
            ElseIf GUICtrlRead ($CLIP_CBX) = 4 Then
                If FileExists($ST_FLDR & 'ClipBoard (as name).lnk') Then FileDelete($ST_FLDR & 'ClipBoard (as name).lnk')
            EndIf
            If GUICtrlRead ($CMND_CBX) = 1 AND FileExists ($ST_FLDR & 'Command Line.lnk') < 1 Then
                FileCreateShortcut(@ScriptFullPath, $ST_FLDR & 'Command Line.lnk', '', ' -r', '', @ComSpec)
            ElseIf GUICtrlRead ($CMND_CBX) = 4 Then
                If FileExists($ST_FLDR & 'Command Line.lnk') Then FileDelete($ST_FLDR & 'Command Line.lnk')
            EndIf
            If GUICtrlRead ($FLDR_CPY_CBX) = 1 AND FileExists ($ST_FLDR & 'Folder (Copy).lnk') < 1 Then
                FileCreateShortcut(@ScriptFullPath, $ST_FLDR & 'Folder (Copy).lnk', '', ' -C', '', @SystemDir & '\shell32.dll', '', 66)
            ElseIf GUICtrlRead ($FLDR_CPY_CBX) = 4 Then
                If FileExists($ST_FLDR & 'Folder (Copy).lnk') Then FileDelete($ST_FLDR & 'Folder (Copy).lnk')
            EndIf
            If GUICtrlRead ($FLDR_MOV_CBX) = 1 AND FileExists ($ST_FLDR & 'Folder (Move).lnk') < 1 Then
                FileCreateShortcut(@ScriptFullPath, $ST_FLDR & 'Folder (Move).lnk', '', ' -M', '', @SystemDir & '\shell32.dll', '', 66)
            ElseIf GUICtrlRead ($FLDR_MOV_CBX) = 4 Then
                If FileExists($ST_FLDR & 'Folder (Move).lnk') Then FileDelete($ST_FLDR & 'Folder (Move).lnk')
            EndIf
            If GUICtrlRead ($RUN_CBX) = 1 AND FileExists ($ST_FLDR & 'Run Dialog.lnk') < 1 Then
                FileCreateShortcut(@ScriptFullPath, $ST_FLDR & 'Run Dialog.lnk', '', ' -R', '', @SystemDir & '\shell32.dll', '', 24)
            ElseIf GUICtrlRead ($RUN_CBX) = 4 Then
                If FileExists($ST_FLDR & 'Run Dialog.lnk') Then FileDelete($ST_FLDR & 'Run Dialog.lnk')
            EndIf
            If GUICtrlRead ($FAV_CBX) = 1 AND FileExists ($ST_FLDR & 'Favorites.lnk') < 1 Then
                FileCreateShortcut(@ScriptFullPath, $ST_FLDR & 'Favorites.lnk', '', ' -f', '', @SystemDir & '\shell32.dll', '', 43)
            ElseIf GUICtrlRead ($FAV_CBX) = 4 Then
                If FileExists($ST_FLDR & 'Favorites.lnk') Then FileDelete($ST_FLDR & 'Favorites.lnk')
            EndIf
            If GUICtrlRead ($ST_CBX) = 1 AND FileExists ($ST_FLDR & 'Add to menu.lnk') < 1 Then
                FileCreateShortcut(@ScriptFullPath, $ST_FLDR & 'Add to menu.lnk', '', ' -m', '', @SystemDir & '\shell32.dll', '', 137)
            ElseIf GUICtrlRead ($ST_CBX) = 4 Then
                If FileExists($ST_FLDR & 'Add to menu.lnk') Then FileDelete($ST_FLDR & 'Add to menu.lnk')
            EndIf
            If GUICtrlRead ($DIR_CBX) = 1 AND FileExists ($ST_FLDR & 'Folder List.lnk') < 1 Then
                FileCreateShortcut(@ScriptFullPath, $ST_FLDR & 'Folder List.lnk', '', ' -d', '', @SystemDir & '\shell32.dll', '', 70)
            ElseIf GUICtrlRead ($DIR_CBX) = 4 Then
                If FileExists($ST_FLDR & 'Folder List.lnk') Then FileDelete($ST_FLDR & 'Folder List.lnk')
            EndIf
            Exit
        EndIf
    Wend
    
EndFunc   ;<==> Enable_GUI()

Func Get_DateTime($DT)
    $INT_KEY = 'HKCU\Control Panel\International'
    $AP = RegRead($INT_KEY, 's1159')
    $AP2 = RegRead($INT_KEY, 's2359')
    $TSC = RegRead($INT_KEY, 'sTime')
    $DSC = RegRead($INT_KEY, 'sDate')
    Local $MONTH[13]
    $MONTH[1] = "January"
    $MONTH[2] = "February"
    $MONTH[3] = "March"
    $MONTH[4] = "April"
    $MONTH[5] = "May"
    $MONTH[6] = "June"
    $MONTH[7] = "July"
    $MONTH[8] = "August"
    $MONTH[9] = "September"
    $MONTH[10] = "October"
    $MONTH[11] = "November"
    $MONTH[12] = "December"
    $DATE = $MONTH[$DT[1]] & ' ' & $DT[2] & $DSC & $DT[0]
    $TIME = $TSC & $DT[4] & $TSC & $DT[5] & CHR(32)
    Switch $DT[3]
        Case 00
            $HR = '12'
        Case 01 To 11
            $HR = $DT[3]
        Case 12
            $HR = $DT[3]
            $AP = $AP2
        Case Else
            $HR = $DT[3] - 12
            $AP = $AP2
    EndSwitch
    $TIME = ' at ' & $HR & $TIME & $AP
    Return $DATE & $TIME
EndFunc   ;<==> Get_DateTime($DT)

Edit: Got the FTP working AGAIN!!!! The file attachment has been removed from the post. Use the link at the top instead. Just right click the link and choose Save Target As

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

I forgot to mention that one of the available items on this app is Add to Menu

If it's enabled in the configuration window then you can right click on any exe file and add it to your Send To menu. Very similar to using Windows New>Shortcut.

Also all of the items available in the configuration window can be added or removed at any time.

The next time I pull it out of the archives I'll add a function to remove any item from Send To.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

This is probly my nub streak talking but what exactly does this do?

It adds or removes certain items from the Send To Menu. Right Click on a file >Send To> Pick your poison.

The added items are Send To > Folder (copy), Folder (Move), Favorites, Clipboard (as name), Command Line, Run Dialog, Write a folder list to a text file, Add any EXE file to the send To Menu (Example; Add VB2Aut.exe to the menu then click on a VBScript file and get it converted to AutoIt Or add ResHckr.exe to the menu and send an executable or dll to Resource Hacker)

The full setup as well as the code is in the download file and the setup also has a 1 page help file in it. It's really simple to use, that's why the help file is only 1 short page

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

  • 1 year later...

It's too bad http://dundats.mvps.org/AutoIt/SendTo/sendto.zip download no longer works.

Casualty of a site cleanup. I just put it back up at

http://dundats.mvps.org/AutoIt/files/sendto.zip

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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...