topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Thursday March 28, 2024, 5:42 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: IDEA: Moving Keyboard focus to a control  (Read 4537 times)

kiran45

  • Participant
  • Joined in 2008
  • *
  • Posts: 5
    • View Profile
    • Donate to Member
IDEA: Moving Keyboard focus to a control
« on: February 22, 2008, 12:52 AM »
Hi
I love autohotkey. Thanks for the great program.

Though I use autohotkey scrips regularly, one simple command is driving me crazy. Hope somebody will help.

I have a html page with many controls and one of them is defined like this:

<input type="text" name="textbox1" id="textboxid1" value="">

Now how can I move my keyboard focus to this control irrespective of where the focus is.
I am using this:
!q:: ;shortcut key
controlfocus, textbox1
I do not want to give window title, as I want to use the current window

Please help
Thanks
« Last Edit: February 22, 2008, 12:54 AM by kiran45 »

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: IDEA: Moving Keyboard focus to a control
« Reply #1 on: February 22, 2008, 05:57 AM »
ControlFocus is used for focusing stactic controls of the current window itself (in this case the browser). Thus, it can't focus parts of webpages.

I'd suggest you do 2 things on the script:
first, lose the focus (send,{esc}) and then, depending on your webbrowser, tab a number of times until you get to where you need the focus (send,{tab}).

Hope that helps!

PS: actually, autohotkey isn't a DonationCoder project, we just use it a lot ;)

kiran45

  • Participant
  • Joined in 2008
  • *
  • Posts: 5
    • View Profile
    • Donate to Member
Re: IDEA: Moving Keyboard focus to a control
« Reply #2 on: February 22, 2008, 09:34 PM »
Hi
thanks for the alternative

regards
kiran

tinjaw

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,927
    • View Profile
    • Donate to Member
Re: IDEA: Moving Keyboard focus to a control
« Reply #3 on: February 22, 2008, 09:44 PM »
I suggest using JavaScript and the DOM to set the focus on the element you want. Don't rely on tabs because there are many things that will cause that to be different under various conditions. If you name the element and use the DOM it won't matter how many tabs you think it might be.

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA: Moving Keyboard focus to a control
« Reply #4 on: February 23, 2008, 06:35 AM »
btw, you didn't mention what browser are you using because if you're using Firefox then AHK would not be much of a use..