DonationCoder.com Software > Post New Requests Here
[SOLVED] Help tweak an AHK script
(1/1)
magician62:
First, if there is a better forum for this post, please feel free to move it.
In trying to find a solution to a repetitive task, I found some old code by skwire, which was almost perfect. It did what I wanted but required a key combination to move to the next string in the array. I wanted to see if I could get it to run by itself.
I have a very basic understanding of it's function, and how now tweaked to to the following. The only thing I have not been able to work out is how to stop the loop when the array matches "z", which would allow for a variable length array. So for the moment I have set the loop to 3. Please note d, e, and z in the array are just placeholders for URL's.
--- ---myURLs =
(
d
e
z
)
StringSplit, myURLsArray, myURLs, `n
WinActivate, ahk_exe chrome.exe
Sleep, 3000 ;Time to move focus to Chrome
Send, +!,
Loop, 3
{
myCounter++
% ( myCounter > myURLsArray0 ) ? ( myCounter := 1 ) : ()
myURL := "myURLsArray" . myCounter
SendInput, ^l
Sleep, 750
SendInput, % %myURL%
Sleep, 1000
SendInput, {ENTER}
Sleep, 2000
SendInput, {ENTER}
Sleep, 3000
SendInput, {ENTER}
Sleep, 2000
}
If someone can guide me into what I need to do, it would be appreciated. If you wonder, the three SendInput {ENTER} are deliberate.
Regards John
skwire:
trying to find a solution to a repetitive task-magician62 (May 03, 2022, 12:38 PM)
--- End quote ---
What's the task?
magician62:
Open a URL, hit enter twice to respond to save dialog, then move onto the next in the list URL. Currently all URL are on one site, but maybe different in future.
This is where your original code came from.
https://www.donationcoder.com/forum/index.php?topic=34285.0
Regards John
highend01:
--- ---myURLs =
(
d
e
z
)
WinActivate, ahk_exe chrome.exe
Sleep, 3000 ;Time to move focus to Chrome
Send, +!,
Loop, Parse, myURLs, `n
{
SendInput, ^l
Sleep, 750
SendInput, % A_LoopField
Sleep, 1000
SendInput, {ENTER}
Sleep, 2000
SendInput, {ENTER}
Sleep, 3000
SendInput, {ENTER}
Sleep, 2000
}
magician62:
--- ---myURLs =
(
d
e
z
)
WinActivate, ahk_exe chrome.exe
Sleep, 3000 ;Time to move focus to Chrome
Send, +!,
Loop, Parse, myURLs, `n
{
SendInput, ^l
Sleep, 750
SendInput, % A_LoopField
Sleep, 1000
SendInput, {ENTER}
Sleep, 2000
SendInput, {ENTER}
Sleep, 3000
SendInput, {ENTER}
Sleep, 2000
}
-highend01 (May 04, 2022, 01:38 AM)
--- End quote ---
Many thanks highend01.
In removing unneeded stuff to achieve what I wanted from the original code, and then merging what was left to reduce it. Due to my lack of knowledge, I totally missed the obvious solution.
This can be marked as SOLVED
Navigation
[0] Message Index
Go to full version