DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: [SOLVED] Help tweak an AHK script  (Read 9,604 times)

magician62

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 180
[SOLVED] Help tweak an AHK script
« on: May 03, 2022, 05:38 PM »
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.

Code
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
Why an I Magician62? Because Magician1 thru 61 were gone. :)
« Last Edit: May 04, 2022, 07:36 AM by magician62 »

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: Help tweak an AHK script
« Reply #1 on: May 03, 2022, 08:35 PM »
trying to find a  solution to a repetitive task

What's the task?

magician62

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 180
Re: Help tweak an AHK script
« Reply #2 on: May 03, 2022, 08:46 PM »
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
Why an I Magician62? Because Magician1 thru 61 were gone. :)

highend01

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 188
Re: Help tweak an AHK script
« Reply #3 on: May 04, 2022, 06:38 AM »
Code
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

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 180
Re: Help tweak an AHK script
« Reply #4 on: May 04, 2022, 07:21 AM »
Code
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
}

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


Why an I Magician62? Because Magician1 thru 61 were gone. :)

Original address: https://www.donationcoder.com/forum/index.php?topic=52314.0