Mouse/Screen Coordinates – Simulating Click on ChatGPT Send Button

That works, thanks. But now we're back to the same problem I had when I was trying to click on the button using coordinates. The basic idea was that I wanted to get the return key to send the query when the browser window wasn't sufficiently wide. But then I'm back at wanting the button click only when I'm in a ChatGPT tab. This is what I was going around and around with with the ChatGPT bot. I want to put the click in an If Then Else action so it occurs only under that given circumstance. This seems like something I should be able to do, but I haven't been able to do it.

Try this at the start of your macro:

The problem with that is it will eat the hotkey,

You should put the macro in its own group, then set the group like this:

image

I use a Stream Deck so much that sometimes forget about hotkeys getting eaten. It's easily accounted for by simulating the hotkey in the else section, but I agree that it's less elegant than your suggestion.

Unless something's changed, and I don't believe it has, this is not a good idea. You can't guarantee it will work.

Paraphrasing the the wiki:

If you try to pass on the hotkey by "typing" it in the macro, what happens "will vary depending on many unpredictable factors though Keyboard Maestro will try to ensure no macro is triggered in response to its own typing."

Many of us old-timers on the forum have considered this one of those "don't try this at home" kinds of things, but YMMV, IANAL, YOLO... :joy:

3 Likes

noisneil:

Try this at the start of your macro:

Thanks, but then I don't get the return if it's not a GPT window or tab – as I now see DanThomas has noted.

DanThomas:

You should put the macro in its own group, then set the group like this:

I never noticed these Available in all windows / Enabled when a focused window [...] options, and I wonder how far back in the KM history they go. If all the way, I'm the more embarrassed.

That said, my KM Groups panel is as crowded as my (undesiredly notched, grr-r) menu bar, so I'll put this condition in the macro itself if I can, which I assume is possible even though I think GPT and I were trying this and it wasn't working somehow. (This has been, for a while now, one of those cases where much more time and trouble is put into elaborating a working macro than is saved by using it, but I'm sure everyone here knows the pleasure of finally getting it going whatever it takes. I'm hoping to visit Peter Lewis in heaven, by the way, as I'm sure he's going to have an absolutely fabulous pad there.) [...] But no, the AI chat doesn't include anything about the KM FrontBrowserURL token, so I think that's my salvation.

And it is. Here's my macro. Thanks, everybody!

Brave - Click on ChatGPT Arrow.kmmacros (3.4 KB)

I now see DanThomas has apparently disapproved this saying you can't guarantee the simulated key will work, but it's working for me here so I'm not going to worry about it unless at some point it doesn't.

Just one question: GPT affably asked me to send it the macro that worked, and I again suffered having forgotten how to export the macro in text-only format. So I manually typed it thus:

If all of the following are true:
The text:
%FrontBrowserURL%
contains chatgpt.com
execute the following actions
Click Link: /html/body/div[1]/div[1]/div/main/div[1]/div[2]/div[1]/div/form/div/div[2]/div/div/button
otherwise execute the following actions
Simulate keystroke: Return

I know I used to be able to do this, but I can't remember how and it doesn't appear to be provided for in the KM File > Export options. What it may be is that in those cases I just copied the actions in the macro and this worked because they were all simple one-step actions, and it didn't work now because the If Then Else action is more complex. But if there's some way to get the entire text of such an action/macro I'd like to know what it is. Thanks again.

1 Like

Then feel embarrassed - they've been there as long as I can remember. :flushed:

I have 184 groups. Get used to it. :stuck_out_tongue: For macros that are available in only specific apps, I name the group the name of the app, to make it easier to find.

Hence, my recommendation to not do this.

Anytime you try to force KM to do something it doesn't want to do, you're asking for trouble. Seriously, there's no downside to putting it in its own group. What's one more group? (Which is why I have 184 groups :roll_eyes:).

@peternlewis, feel free to jump in here, if you've got the time (I know how busy you are.)

Copy as Text.

1 Like

I'm sure you're right, and I can imagine there are circumstances where it might pose problems, but in my personal experience, it's never not worked, or triggered any errant macros. I see it a bit like using found images; it's never my first choice, but other considerations can sometimes lead you to it. I think, all things considered, I would feel the same as @Roy_McCoy and prefer not to create yet another macro group to house a single macro, if the simulated hotkey is working as intended.

I understand exactly what you're saying, and I may actually reconsider my stance on "passing on" keystrokes.

But not separate groups for each app I use KM with. "Never gonna give them up..." :joy:

Me either! In this instance, leveraging group availability conditions (Available when a focused window title contains:) would mean creating a new group just for that particular site (chatgpt.com), and just for one particular macro. Sorry if I didn't explain what I meant very well earlier.

Thanks for getting the reference. :joy:

And we're cool. :sunglasses:

Oh no, I've been Rickrolled! But I'm never gonna give up my separate groups for each app either.

2 Likes

Thinking outside of the box, what kind of queries are you using ChatGPT for? would you be able to use Ollama and a model like Llama 3?

Then it would run in a terminal window

bhowells:

Thinking outside of the box, what kind of queries are you using ChatGPT for?

Anything that comes to mind. If there are things it can do that I don't know about, then I guess they're just simple text queries.

would you be able to use Ollama and a model like Llama 3?

Maybe, but I've never heard of these and don't know what they are.

Then it would run in a terminal window

I open Terminal only rarely, not being connected to an office UNIX system anymore. If the advantage in my case would be being able to send my query by hitting return no matter what the window width, I'm now able to do that with the macro I posted. But thanks for the suggestion anyway. What's the advantage or what are the advantages of doing ChatGPT in Terminal for you?

@Roy_McCoy Thanks for starting this thread. Because of you, I just started using it, and it's awesome!

It's really kind of amazing. I've done Keyboard Maestro searches and gotten great results. Same with Javascript, html and css.

I mean, I've only been using it for a day, but so far it's saved me a lot of time. I'm starting to go to it first, before going to Google.

Ollama is an open source locally run LLM (essentially ChatGPT just not quite so good. - https://ollama.com/

If it's just things that aren't super in-depth i've found it to be pretty useful.

Theres a number of different models you can use depening on what you're doing.

Yeah ChatGPT is great, i've been using it for a while now, I was more asking to see if a locally ran LLM would meet his requirements. Ollama has the benefit of being locally ran, so your data is yours.

Have you tried Claude? @alltiagocom turned me onto it and I've found it to be wayyy more reliable than Chat GPT for code stuff. YMMV etc.

1 Like

DanThomas:

@Roy_McCoy Thanks for starting this thread. Because of you, I just started using it, and it's awesome!

Yes, ChatGPT is awesome. I had Google Gemini as my default AI because ChatGPT in my browser wasn't giving me the cursor in the text field or sending my queries when I hit return unless the window was wide enough, but I eventually realized that I was getting more and better answers from ChatGPT so I switched to that and resolved the two problems concerned. The return key > Send button macro is above. Here below is the other one, which puts the cursor in the text field on my 13" MacBook Air. It requires sizing and positioning the browser window, and I don't know if this is possible without doing that.

Web - Go To ChatGPT.kmmacros (3.5 KB)

It's really kind of amazing. I've done Keyboard Maestro searches and gotten great results. Same with Javascript, html and css.

You can also get lousy results. Beware.

I mean, I've only been using it for a day, but so far it's saved me a lot of time.

Yeah. Who needs government disinformation in dozens of Google finds or in long Wikipedia articles when you can get concise, to-the-point government disinformation in a single AI reply?

I'm starting to go to it first, before going to Google.

This is true with me and several people I know, and I understand it's common. Google has gotten worse and worse, so good riddance.

bhowells:

Ollama is an open source locally run LLM (essentially ChatGPT just not quite so good. - https://ollama.com/

If it's just things that aren't super in-depth i've found it to be pretty useful.

Theres a number of different models you can use depen[d]ing on what you're doing.

Thanks, but I'm good for the moment. What I would really like would be something that doesn't try to gaslight me with crap on political matters. But, as with Google and Wikipedia, I can pretty much tell when it's doing that and get the info I want on less "controversial" things.