Autohotkey V2 Web Form fill multiple dropdowns boxes in a web page

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
logindwmartin
Posts: 5
Joined: 27 Jan 2023, 11:29

Autohotkey V2 Web Form fill multiple dropdowns boxes in a web page

Post by logindwmartin » 27 Jan 2023, 13:33

I am trying to write an AutoHotKEY v2 script that changes the values in three drop down boxes on a web page.

When i do this from the keyboard I select all the text in the first drop down box and then I start typing the value i want in the first drop down. After typeing a few letters the dropdown list shows the value i would like. I hit enter and the first drop down box populates with the correct value.

The list of items in the second dropdown box now changes to only those values that work with what is in the value in the first drop down. The second drop down gets highlighted but no cursor. In order to type in the sceond drop down
I have to click on the second drop down box, I start typing the value i want the second drop down box and eventually after some delay the value I would like shows up in the dropdown list. I hit enter and the second drop down box populates with the correct value.

The next dropdown list gets highlighted but no cursor. I have to click in the box I start typing the value i want the third drop down box and eventually after some delay the value I would like show up in the third dropdown list. I hit enter and the third drop down box populates with the correct value.

Do I need to put in some Refresh commands or delay in order to get one script to populate all three drop down boxes correctly. I have tried adding {Down} and tried {Sleep}. Seems to be a timing issue. Feels like I need to slow down autohotkey and wait for the page refresh to take place.

Any suggestions?

logindwmartin
Posts: 5
Joined: 27 Jan 2023, 11:29

Re: Autohotkey V2 Web Form fill multiple dropdowns boxes in a web page

Post by logindwmartin » 30 Jan 2023, 11:34

The following scripts each individually fill in the drop down boxes one at a time. So, to fill in the three dropdowns I type, CTRL-J then CTRL-L and finally CTRL-M. Trying to determine why I am not able to combine all three script into one?

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
^J::
Send, {Home}{Down}
Sleep 60
Send, Store{Enter}{tab}
return

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
^L::
Send, {Home}{Down}
Sleep 60
Send, Driv{Enter}{Tab}
return

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
^M::
Send, {Home}{Down}
Sleep 60
Send, Connec{Enter}{tab}
return

[Mod action: Topic moved from "v2 Help" since this is a v1 script.]

User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: Autohotkey V2 Web Form fill multiple dropdowns boxes in a web page

Post by boiler » 30 Jan 2023, 11:52

That is not a v2 script, so your main problem might be that you are trying to run it using v2. As a v1 script, it has redundancies that are inconsequential, so it should run if you actually ran it as v1. But it should look more like this:

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

^j::
Send, {Home}{Down}
Sleep 60
Send, Store{Enter}{tab}
return

^l::
Send, {Home}{Down}
Sleep 60
Send, Driv{Enter}{Tab}
return

^m::
Send, {Home}{Down}
Sleep 60
Send, Connec{Enter}{tab}
return

As a v2 script:

Code: Select all

#Requires AutoHotkey v2.0
SendMode "Input"  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir A_ScriptDir  ; Ensures a consistent starting directory.

^j:: {
	Send "{Home}{Down}"
	Sleep 60
	Send "Store{Enter}{tab}"
}

^l:: {
	Send "{Home}{Down}"
	Sleep 60
	Send "Driv{Enter}{Tab}"
}

^m:: {
	Send "{Home}{Down}"
	Sleep 60
	Send "Connec{Enter}{tab}"
}

Or more compact:

Code: Select all

#Requires AutoHotkey v2.0
SendMode "Input"  ; Recommended for new scripts due to its superior speed and reliability.

^j::
^l::
^m:: {
	static text := map("^j", "Store", "^l", "Driv", "^m", "Connec")
	Send "{Home}{Down}"
	Sleep 60
	Send text[A_ThisHotkey] "{Enter}{tab}"
}

logindwmartin
Posts: 5
Joined: 27 Jan 2023, 11:29

Re: Autohotkey V2 Web Form fill multiple dropdowns boxes in a web page

Post by logindwmartin » 01 Feb 2023, 13:22

Installed Programs shows I am running AutoHotkey v3.3.14.5.

When I edit the AHK file the program SciTE4AutoHotLey v3.1 is launched.

The help file reports Version 1.1.32.00

I have changed the script as follows, but it still does not work, with the cursor in the drop down box that is empty, when using the CTRL-N hotkey
I see the message "Loading" for s quick second.

The drop down remains blank, and the text box has "See Timer Error Ticket"

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
^N::
Send, {Home}{Down}
Sleep 60
Send, Known{Enter}{tab}
Sleep 60
Send, See Timer Error Ticket
return

User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: Autohotkey V2 Web Form fill multiple dropdowns boxes in a web page

Post by boiler » 01 Feb 2023, 14:06

logindwmartin wrote: Installed Programs shows I am running AutoHotkey v3.3.14.5.
There is no such version of AutoHotkey. Check again because even if the first 3 is a typo and should be a 1, the rest wouldn’t really make sense.

logindwmartin wrote: When I edit the AHK file the program SciTE4AutoHotLey v3.1 is launched.
That’s irrelevant.

logindwmartin wrote: The help file reports Version 1.1.32.00
That’s most likely what you’re running, which is v1, not v2 (and not v3 since it doesn’t exist).

logindwmartin wrote: I have changed the script as follows, but it still does not work,…
To be clear then, that code is v1 code. The fact that it runs at all means for sure that you are running v1, not v2.

Having said that, try using longer Sleep durations and see if that solves the problem since you are thinking it may be a timing issue. Something much longer than 60. Try something like 500, and if that works, then try smaller values.

logindwmartin
Posts: 5
Joined: 27 Jan 2023, 11:29

Re: Autohotkey V2 Web Form fill multiple dropdowns boxes in a web page

Post by logindwmartin » 01 Feb 2023, 15:36

My bad that was AutoIT V3,3, AutoHotkey reports 2.02

User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: Autohotkey V2 Web Form fill multiple dropdowns boxes in a web page

Post by boiler » 01 Feb 2023, 15:58

I'll point this out one last time: The code you posted would not run with AHK v2. You must also have AHK v1 installed if it actually runs.

logindwmartin
Posts: 5
Joined: 27 Jan 2023, 11:29

Re: Autohotkey V2 Web Form fill multiple dropdowns boxes in a web page

Post by logindwmartin » 01 Feb 2023, 16:34

I uninstalled V1 and installed V2

I can compile this script

Code: Select all

^j::
^l::
^m:: {
	static text := map("^j", "Store", "^l", "Driv", "^m", "Connec")
	Send "{Home}{Down}"
	Sleep 60
	Send text[A_ThisHotkey] "{Enter}{tab}"
}
But when run it I get

>"C:\Program Files\AutoHotkey\AutoHotkey.exe" /ErrorStdOut "C:\Users\MartinD\OneDrive - Steak n Shake Enterprises\Desktop\MSTTD-1.ahk"
C:\Users\MartinD\OneDrive - Steak n Shake Enterprises\Desktop\MSTTD-1.ahk (4) : ==> This line does not contain a recognized action.
Specifically: static text := map("^j", "Store", "^l", "Driv", "^m", "Connec")
>Exit code: 2 Time: 0.1772

User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: Autohotkey V2 Web Form fill multiple dropdowns boxes in a web page

Post by boiler » 01 Feb 2023, 17:00

You are still somehow running v1. That is a v1 error, and it's due to using v2 syntax while trying to run it with v1. I get the same exact error here with v1, and I get no error when I run it with v2, as expected. It's not even a question. That is what is happening.

You apparently compiled it but you are not running the file you compiled, or else it would be reporting the name of the script with a .exe file extension, not a .ahk extension. So you must be compiling it with v2 -- hence no error -- and then you are running the uncompiled script file (the .ahk file) with v1 instead of running the .exe file you compiled. That .exe file would run with v2 since that's what you apparently compiled with or else it would have flagged an error.

In case you are not aware, there is no need to compile .ahk scripts to run them. In fact, there is seldom a need to do so. AHK is an interpreted language that operates on the AHK code in real time. When you "compile" it, you are just wrapping the the AHK script into a .exe file along with the AHK interpreter so that it can run stand-alone, even on machines that don't have AHK installed. There is no actual compiling of the script into machine code or anything like that.

Post Reply

Return to “Ask for Help (v2)”