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: Clicking in fields  (Read 8,589 times)

oblivion

  • Supporting Member
  • Joined in 2010
  • **
  • Posts: 499
    • Participated in NANY Challenge Once
Clicking in fields
« on: October 26, 2012, 04:54 PM »
I have an AHK routine that picks up some information and pastes it into an input field on a webpage.

What I'd like to be able to (but can't) is use some sort of keyboard shortcut that put the cursor into said textfield then hit ^v to paste the text. The reason I can't is, apparently, that the developer of the code for the relevant webpage wrote it in dotNet and (he says) there's no way to communicate back out of it to the host PC to set up a keyboard shortcut. So that's that, and all I can do is take advantage of the fact that the field never moves relative to its containing frame, pick an appropriate coordinate and click there.

There's a lot to go wrong with that approach. If IE develops a left-hand bar -- history, for instance -- we'll be clicking in the wrong place.

Can anyone suggest any other possible approaches?
-- bests, Tim

...this space unintentionally left blank.

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,649
    • Participated in NANY Challenge Eleven Times
    • Coding Snacks
    • Linux User
    • Hardware Hacker
Re: Clicking in fields
« Reply #1 on: October 26, 2012, 06:08 PM »
You can locate the position of the text label that's usually on the left side of the input, and click a few pixels right of that? AHK or AutoIt can do that for you.
/Ton
Ath's software collection, Quote: "A problem well stated is a problem half-solved." (Charles Kettering)

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: Clicking in fields
« Reply #2 on: October 26, 2012, 06:29 PM »
If you're using IE, you can use the COM interface available in AHK_L.

oblivion

  • Supporting Member
  • Joined in 2010
  • **
  • Posts: 499
    • Participated in NANY Challenge Once
Re: Clicking in fields
« Reply #3 on: October 29, 2012, 04:34 PM »
You can locate the position of the text label that's usually on the left side of the input, and click a few pixels right of that? AHK or AutoIt can do that for you.

I know what I'm looking for on the screen but I can't work out how to find it. I thought ImageSearch was going to help but that looks more like a brute-force mechanism for finding a graphic I already have in a specified area of the screen. That's not quite what I'm trying to do: I'm trying to say "please give me the coordinates in the active window of xyz bit of text or a graphic called abc.jpg"

Do I have to use, say, FileCopy to copy a nearby graphic from the webpage, then ImageSearch to locate it? That feels clunky but I can't find anything better...?  :huh:
-- bests, Tim

...this space unintentionally left blank.
« Last Edit: October 29, 2012, 05:00 PM by oblivion »

oblivion

  • Supporting Member
  • Joined in 2010
  • **
  • Posts: 499
    • Participated in NANY Challenge Once
Re: Clicking in fields
« Reply #4 on: October 29, 2012, 05:01 PM »
If you're using IE, you can use the COM interface available in AHK_L.
All my "too complicated" lights have come on at once. :D

I'm not a proper programmer, honest!
-- bests, Tim

...this space unintentionally left blank.

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: Clicking in fields
« Reply #5 on: October 29, 2012, 06:58 PM »
All my "too complicated" lights have come on at once. :D

Yeah, it's not for the faint of heart.  However, it is reliable.

oblivion

  • Supporting Member
  • Joined in 2010
  • **
  • Posts: 499
    • Participated in NANY Challenge Once
Re: Clicking in fields
« Reply #6 on: October 31, 2012, 04:59 PM »
All my "too complicated" lights have come on at once. :D

Yeah, it's not for the faint of heart.  However, it is reliable.

My "too complicated" lights have continued to blink, at least intermittently. However, I've done pretty much what I said I'd do if I couldn't find anything simpler: I've downloaded a graphic that sits directly above the input field using UrlDownloadToFile, then used ImageSearch to provide its coordinates, which I then add a bit to and feed to Click.

It still feels clunky. But what the heck, it works -- and I don't have to try to decode what's going on at COM level, which can only be a bonus. :)

Thanks, both!
-- bests, Tim

...this space unintentionally left blank.

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