Help to change sending key commands on 3rd record Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Bad husband
Posts: 54
Joined: 21 Oct 2017, 13:38

Help to change sending key commands on 3rd record

05 Apr 2019, 23:07

Hi there,

Hope I can clearly communicate what I’m looking for my script. I have an excel sheet that can have 1 record to sometimes 100 records. My script was working fine but our IT department did an upgrade and the script is not working the way it should. They added an extra field that I need to input a letter “A”, but only for the first 2 loops and then on the 3rd loop this letter “A” is not required because the system adds it automatically. How do I add this to my script to not input the “A” after the second loop?

Here is my code

Code: Select all

~CapsLock & r::	;With your Excel file open, Press CapsLock+R to begin
objExcel := ComObjActive("Excel.Application") 		; Gets an open instance of the excel application
CellA2 := objExcel.ActiveWorkbook.ActiveSheet.Range("A2")		; Save a reference to cell 
InputBox, Location, Putaway Location, Enter Putaway Location, , ,

Loop, {
	OffsetVal := (A_Index - 1)*1 ; Some math to determine which cell is next
	Cell_One := CellA2.Offset(OffsetVal, 0).Text		; Store the text from the 1st cell 
	Cell_Two := CellA2.Offset(OffsetVal, 1).Text	; Store the text from the 2nd cell 
	Cell_Three := CellA2.Offset(OffsetVal, 2).Text		; Store the text from the 3rd cell 
	Cell_Four := CellA2.Offset(OffsetVal, 3).Text		; Store the text from the 4th cell
		
	if (!Cell_One || !Cell_Two)	; If either of the "Cell_One" or "Cell_Two" variables is blank, break the loop
		break
	
	;MsgBox, % "Cell_One: " Cell_One "`nCell_Two: " Cell_Two "`nCell_Three: "  Cell_Three "`nCell_Four: " Cell_Four ;"`nCell_Five: " Cell_Five
	
	; Put Send/Click commands here
	Send, %Cell_Two% {ENTER}
    Send, {a}
	Send, %Cell_Three% {TAB}{END}
	Sleep, 700
	Send, %Cell_Four% {ENTER 2}
	Sleep, 700
	Send, %Cell_Three% {ENTER}
	Sleep, 700
	Send, %Location% {ENTER}{F2}
		
}return
Thanks for looking
Bad husband
Posts: 54
Joined: 21 Oct 2017, 13:38

Re: Help to change sending key commands on 3rd record  Topic is solved

06 Apr 2019, 09:28

I found a solution to my problem, it was simple. I added this new piece of code

Code: Select all

if A_Index < 3
{
Send, %Cell_Two% {ENTER}
    Send, {a}
	Send, %Cell_Three% {TAB}{END}
	Sleep, 700
	Send, %Cell_Four% {ENTER 2}
	Sleep, 700
	Send, %Cell_Three% {ENTER}
	Sleep, 700
	Send, %Location% {ENTER}{F2}
}
else
{if A_Index > 2
Send, %Cell_Two% {ENTER}
	Send, %Cell_Three% {TAB}{END}
	Sleep, 700
	Send, %Cell_Four% {ENTER 2}
	Sleep, 700
	Send, %Cell_Three% {ENTER}
	Sleep, 700
	Send, %Location% {ENTER}{F2}
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Freddie, gongnl, mikeyww, mmflume, OrangeCat, ShatterCoder and 93 guests