Best Answer
Here you go.
You are lucky I am wrapping things up with my own little excel project and I happen to know everything needed to do just what you are looking for. I left comments in that explains practically every part. Change what you want, but I've added everything you wanted. I've also added a way to choose which row to start on, and it defaults to 2 since the first row is usually a column title. It will loop until it finds a row where the A column cell block is a blank value. I have made most parts of the code as understandable as I can through comments.
Change the sleep timers if it is too fast/slow. Ctr+1 is the hotkey to start it. I have made Escape into a hotkey while the script is running to immediately stop the script in case there is a failure of some sort. Enjoy
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
$^1::
Setkeydelay, 35
; SELECT THE EXCEL FILE TO OPEN AND MAKE A VARIABLE CONTROL FOR IT CALLED Xl
FileSelectFile, Path, 3, , Open Excel File, Excel File (*.xls; *.xlsx)
if Path =
ExitApp
Xl := ComObjCreate("Excel.Application")
Xl.Workbooks.Open(Path) ;open an existing file
Xl.Visible := True
if Errorlevel
{
MsgBox, % "Error opening excel file! Exiting..."
ExitApp
}
; Ask user to choose the sheet to open
Sheet_Titles =
global Sheet_To_Calculate := 0
loop, % xl.Sheets.Count
Sheet_Titles .= A_Index . ": " . xl.Sheets(A_Index).Name . "`n"
While Sheet_To_Calculate < 1 || Sheet_To_Calculate > xl.Sheets.Count || !IF_Integer(Sheet_To_Calculate)
inputbox, Sheet_To_Calculate, % Xl.ActiveWorkbook.Name, %Sheet_Titles%, , , , , , , , 1
if ErrorLevel
ExitApp
; ASK WHICH ROW TO START ON, DEFAULT TO 2 SINCE 1 IS USUALLY THE COLUMN TITLES
global Current_Row := -1
While Current_Row < 1 || !IF_Integer(Current_Row)
inputbox, Current_Row, % Xl.ActiveWorkbook.Name, % "Enter the row to start on.", , , , , , , , 2
if ErrorLevel
ExitApp
; THE REAL MEAT :) while the current row's A column is not blank, continue the loop
while Xl.Sheets(Sheet_To_Calculate).Range("A" . Current_Row).Value != ""
{
; Store the values into variables
A_stored := Xl.Sheets(Sheet_To_Calculate).Range("A" . Current_Row).Value
B_stored := Xl.Sheets(Sheet_To_Calculate).Range("B" . Current_Row).Value
C_stored := floor(Xl.Sheets(Sheet_To_Calculate).Range("C" . Current_Row).Value)
; THIS MAY NEED CHANGING NOT SURE... it will bring the window labeled B32PTS102.entry.com-Remote Desktop Connection to the front
ControlFocus,, B32PTS102.entry.com-Remote Desktop Connection
Sleep 550
; Enter A and enter five times
MouseClick, Left, 548, 126
Sleep 150
Send %A_stored%
Send {Enter 5}
Sleep 100
; Enter B and enter five times
MouseClick, Left, 548, 423
Sleep 150
Send %B_stored%
Send {Enter 5}
Sleep 100
; Enter C and enter five times
MouseClick, Left, 548, 627
Sleep 150
Send %C_stored%
Send {Enter 5}
Sleep 100
; Move to the next row
Current_Row++
}
MsgBox, % "Done! :)"
ExitApp
IF_Integer(check_this)
{
if check_this is not integer
return false
else
return true
}
$Esc::ExitApp ;EMERGENCY EXIT HOTKEY