2
votes

This is my first post so please be gentle.
I have found that I often am constantly saving files and then uploading them to a webserver to test them. This gets rather annoying so I am trying to create an autohotkey script that will automatically upload files to a server using filezilla when I save a file in notepad++.

Currently I have this:

loop {
  IfWinExist, File has changed
  {
    WinActivate
    Send, !y
  }
  Sleep, 1000
}

This works to a degree. It uploads the saved file to the server but it doesn't consider directories so I end up uploading a load of js and css files into the main site directory instead of their respective directories, which is obviously a problem.

I am pretty new to AutoHotkey and don't really know what I am doing so I am not sure how I can fix this.

My idea (not sure if possible)
All of my sites have a similar file structure on my computer:

*sitename* / root / css / *css files*
                     js / *js files*
                    img / *image files*

and then also the site directories and pages inside the root folder. This means I can just open the sites root folder in FileZilla and copy all of the files across to the public_html folder on the server.

I was wondering if I could get the file path for the saved file, say: 'd://files/Website_name/root/css/styles.css'
and cut out the stuff before root to leave 'css/styles.css'. Then navigate to the css directory on the webserver and then transfer the file. This would need to work with multiple directories, say 'about/info/index.php' which would need to change to the 'about' directory and then afterwards the 'info' directory and then upload the file.

If at any point the directory doesn't exist I want the process to just stop running and return to the starting directory. It should also do this after uploading a file so it is ready for another upload.

I don't really understand why this isn't already part of FileZilla's functionality as many other FTP programs automatically upload files. If anyone can help me modify my script or show me another (free) way of auto-uploading files using FileZilla it would be much appreciated.

Jimmy

2
All this would be unnecessary if you could just mount your ftp to a folder on your computer, then you could just open files on it with your regular editor. If you have a Mac, take a look at Transmit. If you're using Windows, there will probably be a million similar programs for mounting ftps.Hassan
What Windows version do you use?Brigand

2 Answers

3
votes

Not what you were asking for, but once you're editing with Notepad++, why don't you use its FTP plug-in? It gets shipped with N++ itself and is easy to configure. If you want an approach with more possibilities, then you should rather try out WinSCP and set Notepad++ as its default editor. Both approaches will automatically upload your changes once saved in N++.

0
votes

I remade the AutoHotKey Script so if anybody is interestedd there:

loop {
  IfWinExist, Datei wurde geändert ;original -> File has changed
  {
    WinGetTitle, windowBefore, A
    WinActivate
    ;Send, !y (wont work at me)
    Send, {Enter}
    WinActivate, %windowBefore%
  }
  Sleep, 1000
}