AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

AutoHotKey.net File Upload

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Travley



Joined: 13 May 2007
Posts: 47

PostPosted: Tue Jun 19, 2007 7:12 am    Post subject: AutoHotKey.net File Upload Reply with quote

This is in no way shape or form the best method of doing this, as I'm sure there are more defined, controlled ways of doing this. However, This works and with that said, I hope you enjoy.

This has been tested on FireFox & IE 6-7 only. A version could easily be made for Maxthon as well.

Cheers

Code:
; Title : AHKDoNet Uploader
; Version : 1.0
; Author : Travley
; Coded In : AHK (AutoHotKey.Com)
; Notes : Thanks to the AHK Forums
; ONLY TESTED IN FIREFOX & INTERNET EXPLORER
; I COULD DO ANOTHER 'DONE PNG' FOR MAXTHON IF REQUESTED
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Windows Vista UAC Prompt
if not A_IsAdmin
{
DllCall("shell32\ShellExecuteA", uint, 0, str, "RunAs", str, A_AhkPath
, str, """" . A_ScriptFullPath . """", str, A_WorkingDir, int, 1) ; Last parameter: SW_SHOWNORMAL = 1
ExitApp
}

#SingleInstance Force
#NoEnv
SendMode Input
siteurl = http://www.autohotkey.net
username = username ; Your AHKdotNet Username
password = password ; Your AHKdotNet Password
browser = C:\program files\Mozilla Firefox\firefox.exe ; Change this to Iexplore if you use IE (tested on v6-v7)
imgurl = http://img224.imageshack.us/img224/9764/donekz6.png ; File used for PixelSearch

; Downloads PixelSearch Image
IfNotExist, %TEMP%\ahkdotnetiedone.png
UrlDownloadToFile, %imgurl%, %TEMP%\ahkdotnetiedone.png

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

WinClose, ahk_class MozillaUIWindowClass ; I force-close FF only because I find it has problems sometimes if its not a fresh-start. You could code another IfWinExist already in to it to go another route based on what the problem is, but Im lazy  ;) Change to ahk_class IEFrame for IE

FileSelectFile, File2Upload, 1, RootDir\Filename, Select Which File You Wish to Upload, AHK Documents (*.ahk)
Run %browser% %siteurl%
WinWait, ahk_class MozillaUIWindowClass ; Change to ahk_class IEFrame for IE
IfWinNotActive, ahk_class MozillaUIWindowClass ; Change to ahk_class IEFrame for IE
 {
  WinActivate, ahk_class MozillaUIWindowClass ; Change to ahk_class IEFrame for IE
  goto Login
 }
IfWinActive, ahk_class MozillaUIWindowClass ; Change to ahk_class IEFrame for IE
 {
  goto Login
 }


Login:
WinWaitActive, AutoHotkey.net - Mozilla Firefox ; Change to AutoHotkey.net - Microsoft Internet Explorer for IE
ImageSearch, imageX, imageY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, %TEMP%\ahkdotnetiedone.png
If ErrorLevel = 0
{
Send {tab 20}
Send %username%
Send {tab}
Send %password%
Send {enter}
goto Upload
}
Else
{
Goto Login
}

Upload:
WinWaitActive, File Manager - Browsing directory / - Mozilla Firefox ; Change to File Manager - Browsing directory / - Microsoft Internet Explorer for IE
ImageSearch, imageX, imageY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, %TEMP%\ahkdotnetiedone.png
If ErrorLevel = 0
{
Send {tab 7}
Send {enter}
goto FileInsert
}
Else
{
  Goto Upload
}

FileInsert:
WinWaitActive, http://www.autohotkey.net - File upload - Mozilla Firefox ; Change to ttp://www.autohotkey.net - File upload - Microsoft Internet Explorer for IE
ImageSearch, imageX, imageY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, %TEMP%\ahkdotnetiedone.png
If ErrorLevel = 0
{
Send {tab}
Send %File2Upload%
Send {tab 4}
Send {Enter}
Goto Clippy
}
Else
{
 Goto FileInsert
}

Clippy:
WinWaitClose, http://www.autohotkey.net - File upload - Mozilla Firefox ; Change to  http://www.autohotkey.net - File upload - Microsoft Internet Explorer for IE
ImageSearch, imageX, imageY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, %TEMP%\ahkdotnetiedone.png
If ErrorLevel = 0
{
SplitPath, File2Upload, name
clipboard = %siteurl%/~%username%/%name%
MsgBox, , Success!, The File Was Successfully Uploaded. The URL of your file is now in clipboard.
FileDelete, %TEMP%\ahkdotnetiedone.png
Return
}
Else
{
  Goto Clippy
}


Image :
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6836
Location: France (near Paris)

PostPosted: Tue Jun 19, 2007 8:37 am    Post subject: Reply with quote

Uh, I had not the courage to analyze the code, as you wrote I suppose it ad hoc for your needs.
We often advise to use JavaScript to manipulate Web pages, and in the given case, it is much easier to ask an FTP account... Smile
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group