Is it possible to use AutoHotkeys to submit form data on a website?

0

I have set up hot keys to let me highlight a word in a foreign language(FR, SP, GE) and based on the hotkey I can either conjugate it, hear a human pronounce it, or define it in context. However the site that I want to use to conjugate German verbs does not submit the word in the url. I like this conjugator the best: https://deutsch.lingolia.com/en/grammar/conjugator and I don't know much about Jquery nor about how hotkeys could be used to submit a verb in the form data on this page. Does anyone know if this is possible? There are many conjugators that I could use the URL method, but I want to use this site.

#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.
#f::
clipboard=
send, {ctrl down}c{ctrl up}
ClipWait, .5
Run, "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" ""http://forvo.com/search/"%clipboard%"/fr""
Return
#g::
clipboard=
send, {ctrl down}c{ctrl up}
ClipWait, .5
Run, "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" ""http://forvo.com/search/"%clipboard%"/de/""
Return
#s::
clipboard=
send, {ctrl down}c{ctrl up}
ClipWait, .5
Run, "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" ""http://forvo.com/search/"%clipboard%"/es/""
Return

#!f::
clipboard=
send, ^c
ClipWait, .5
StringReplace, totranslate, clipboard, %A_Space%, +, All
;MsgBox, %totranslate% = %clipboard%
Run, "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" ""http://context.reverso.net/translation/french-english/"%totranslate%"
Return

#!g::
clipboard=
send, ^c
ClipWait, .5
StringReplace, totranslate, clipboard, %A_Space%, +, All
Run, "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" ""http://context.reverso.net/translation/german-english/"%totranslate%"
Return

#!s::
clipboard=
send, ^c
ClipWait, .5
StringReplace, totranslate, clipboard, %A_Space%, +, All
Run, "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" ""http://context.reverso.net/translation/spanish-english/"%totranslate%"
Return

+#g::
clipboard=
send, {ctrl down}c{ctrl up}
ClipWait, .5
Run, "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" ""http://www.verbix.com/webverbix/German/"%clipboard%".html""
Return

+#f::
clipboard=
send, {ctrl down}c{ctrl up}
ClipWait, .5
Run, "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" ""http://www.collinsdictionary.com/dictionary/french-english/conjugation/"%clipboard%"
Return

+#s::
clipboard=
send, ^c
ClipWait, .5
Run, "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" ""http://www.spanishdict.com/conjugate/"%clipboard%"
Return

#+!g::
clipboard=
send, {ctrl down}c{ctrl up}
ClipWait, .5
Run, "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" ""https://en.wiktionary.org/wiki/"%clipboard%"#Declension""
Return

user5389726598465

Posted 2017-03-28T00:29:05.700

Reputation: 179

Is this an AutoHotkey script? – Bob – 2017-03-28T00:40:35.063

Yes, AutoHotkey v1.1.24.01. I haven't upgraded to 2, but it should still work. – user5389726598465 – 2017-03-28T00:43:52.043

Answers

1

You could mimic the way that a human would use the website:

+#s::
clipboard=
send, ^c
ClipWait, .5
Run, "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "https://deutsch.lingolia.com/en/grammar/conjugator"

WinWait, Conjugate German Verbs - Lingolia German - Google Chrome, 
IfWinNotActive, Conjugate German Verbs - Lingolia German - Google Chrome, , WinActivate, Conjugate German Verbs - Lingolia German - Google Chrome, 
WinWaitActive, Conjugate German Verbs - Lingolia German - Google Chrome, 
MouseClick, left,  460,  399
Sleep, 100
Send, {TAB}{CTRLDOWN}v{CTRLUP}{ENTER}


Return

Sir Adelaide

Posted 2017-03-28T00:29:05.700

Reputation: 4 758

That's a great idea. Lucky the form is only one tab down. I just need to debug this for my triple monitor setup and I think I could get it to work. – user5389726598465 – 2017-03-28T01:20:12.813

If necessary, you could add a CoordMode line to make the click and coords relative to the Chrome window: https://autohotkey.com/docs/commands/CoordMode.htm

– Sir Adelaide – 2017-03-28T01:22:51.537

Something like "CoordMode, Mouse, Relative" would let you give coordinates relative to chrome top left corner – Sir Adelaide – 2017-03-28T01:24:17.473

I use the AutoScriptWriter linked in the accepted answer of https://superuser.com/questions/229720/where-can-i-find-a-macro-recorder-for-autohotkey I do the clicking and typing, and then check the click coordinates in the record window and edit as necessary

– Sir Adelaide – 2017-03-28T01:32:49.917

Ahh, that's an even better answer! I got the coordinates from windows multimonitor app that has a bug which displays the coordinate of the top left corner of a selected window. – user5389726598465 – 2017-03-28T01:34:08.367

One hitch is that if I change the zoom level of the browser the coordinates change and it might click the google ad. – user5389726598465 – 2017-03-28T01:36:04.693

1Ctrl-0 resets zoom to default in chrome. – user5389726598465 – 2017-03-28T02:10:59.067