Hi Everyone,
Rather new to Scripting but really excited to use it properly.
I'm having a huge amount of trouble finding out how to break a loop that reaches an empty cell in excel.
This Script simply goes down a column, copies the cell, jumps to a search program, downloads the file and jumps back to excel.
This works correctly for everything i need, and loops great with no issues, except that i can not get it to break once it copies an empty cell.
I'd like it to loop infinitely until it copies an empty cell in Excel.
This is a slightly earlier draft of my script where I use AltTab instead of using WinActivate. But this one is definitely stable and worked great. But i need it to break at copying empty cell.
Please let me know if i can provide any more information!
F12::
Loop, 10
{
suspend
Send, {Alt Down}
Sleep 100
Send, {Tab}
Sleep 100
Send, {Alt Up}
send, {Down}
send, ^c
Send, {Alt Down}
Sleep 100
Send, {Tab}
Sleep, 100
Send, {Alt Up}
send, ^v
Sleep, 100
send, {Enter}
Sleep, 10000
Send, {Tab 6}
Sleep, 100
Send, {Down}
Sleep, 100
Send, +{F10}
Sleep, 100
Send, {Down}
Sleep, 100
Send, {Enter}
Sleep, 100
Send, {Enter}
Sleep, 10000
Send, {Tab 7}
}
Return
Loop Break when copying an empty cell in Excel
Re: Loop Break when copying an empty cell in Excel
There are a number of things I would do to make the script more reliable, but to add only what you asked:
Code: Select all
F12::
Loop
{
suspend
Send, {Alt Down}
Sleep 100
Send, {Tab}
Sleep 100
Send, {Alt Up}
send, {Down}
Clipboard := ""
send, ^c
ClipWait
if (Clipboard = "")
break
Send, {Alt Down}
Sleep 100
Send, {Tab}
Sleep, 100
Send, {Alt Up}
send, ^v
Sleep, 100
send, {Enter}
Sleep, 10000
Send, {Tab 6}
Sleep, 100
Send, {Down}
Sleep, 100
Send, +{F10}
Sleep, 100
Send, {Down}
Sleep, 100
Send, {Enter}
Sleep, 100
Send, {Enter}
Sleep, 10000
Send, {Tab 7}
}
Return
Re: Loop Break when copying an empty cell in Excel
Hmm this didn't work for me even with just using your code rather then modifying mine.
It doesn't break the Loop.
From what I've been able to figure out online, the main reason its so difficult is because a Blank cell in Excel is not technically actually blank or empty. It has some data in it which is why I'm having difficulties with this.
Thank you for your Help!
It doesn't break the Loop.
From what I've been able to figure out online, the main reason its so difficult is because a Blank cell in Excel is not technically actually blank or empty. It has some data in it which is why I'm having difficulties with this.
Thank you for your Help!
Re: Loop Break when copying an empty cell in Excel
That makes sense, but this should work then:
Code: Select all
F12::
Loop
{
suspend
Send, {Alt Down}
Sleep 100
Send, {Tab}
Sleep 100
Send, {Alt Up}
send, {Down}
Clipboard := ""
send, ^c
ClipWait
if (Clipboard = "`r`n")
break
Send, {Alt Down}
Sleep 100
Send, {Tab}
Sleep, 100
Send, {Alt Up}
send, ^v
Sleep, 100
send, {Enter}
Sleep, 10000
Send, {Tab 6}
Sleep, 100
Send, {Down}
Sleep, 100
Send, +{F10}
Sleep, 100
Send, {Down}
Sleep, 100
Send, {Enter}
Sleep, 100
Send, {Enter}
Sleep, 10000
Send, {Tab 7}
}
Return
Re: Loop Break when copying an empty cell in Excel
I'm just going to leave this here in case you are interested in going the more-reliable route that boiler alluded to.
https://autohotkey.com/boards/viewtopic ... 48#p112648
https://autohotkey.com/boards/viewtopic ... 48#p112648
Re: Loop Break when copying an empty cell in Excel
Blank cell copied to clipboard actually contains carriage return and linefeed. You have to remove those.VV710 wrote:Hmm this didn't work for me even with just using your code rather then modifying mine.
It doesn't break the Loop.
From what I've been able to figure out online, the main reason its so difficult is because a Blank cell in Excel is not technically actually blank or empty. It has some data in it which is why I'm having difficulties with this.
Thank you for your Help!
Code: Select all
send ^{c}
str := StrReplace(Clipboard, "`r`n")
if(str == "") {
Break
}
Here's a simple example from another post : https://autohotkey.com/boards/viewtopic ... 99#p133199
Re: Loop Break when copying an empty cell in Excel
Awesome!
This worked:
Clipboard := ""
send, ^c
ClipWait
if (Clipboard = "`r`n")
break
I wasn't to far off with previous attempts but its really nice to have a working example to learn from.
I know I've got a LOT to learn and I've bookmarked your guys recommendations.
Thank you all!
This worked:
Clipboard := ""
send, ^c
ClipWait
if (Clipboard = "`r`n")
break
I wasn't to far off with previous attempts but its really nice to have a working example to learn from.
I know I've got a LOT to learn and I've bookmarked your guys recommendations.
Thank you all!