AutoHotkey Community

It is currently May 25th, 2012, 8:57 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: June 19th, 2007, 8:12 am 
Offline

Joined: May 13th, 2007, 5:40 pm
Posts: 47
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 : Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 19th, 2007, 9:37 am 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
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... :)

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot], Google Feedfetcher, tic and 13 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group