topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday October 10, 2024, 11:54 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: [SOLVED] Help tweak an AHK script  (Read 5659 times)

magician62

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 180
    • View Profile
    • Donate to Member
[SOLVED] Help tweak an AHK script
« on: May 03, 2022, 12: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.

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, 02:36 AM by magician62 »

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
Re: Help tweak an AHK script
« Reply #1 on: May 03, 2022, 03:35 PM »
trying to find a  solution to a repetitive task

What's the task?

magician62

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 180
    • View Profile
    • Donate to Member
Re: Help tweak an AHK script
« Reply #2 on: May 03, 2022, 03: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.donation...ex.php?topic=34285.0

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

highend01

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 188
    • View Profile
    • Donate to Member
Re: Help tweak an AHK script
« Reply #3 on: May 04, 2022, 01:38 AM »
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
    • View Profile
    • Donate to Member
Re: Help tweak an AHK script
« Reply #4 on: May 04, 2022, 02:21 AM »
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. :)