Tab function vs tab character

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Slammish
Posts: 2
Joined: 17 Nov 2020, 17:55

Tab function vs tab character

17 Nov 2020, 18:03

Aloha,

TL;DR I need tab to go to next field, even when inside of a text box, where the key only produces an indent and is stuck inside the text box.


I'm hoping this is a quick solution. I found plenty of topics addressing the opposite of this, but have an app I interact with that would sure be easier to use if I could tab to the "OK" button underneath the text box.
Tab works up until I reach that, since it allows text formatting options.
Once I'm there, all tab does is create an indent. I need it to go to the next field.
I never use indent at my job, anywhere, ever, so if the only solution that comes up involves disabling that? I'm game.

Is there something like {Nextfield} or {Nextbutton} that I can use after sendinput?
User avatar
boiler
Posts: 16926
Joined: 21 Dec 2014, 02:44

Re: Tab function vs tab character

17 Nov 2020, 18:27

How about having the script perform a mouse click in the next field to move the keyboard focus to it? Better yet, see if the app has individual controls so that you can use ControlFocus to move to that field. The first step is seeing if the various fields have unique control names by using the Window Spy tool that comes with AHK.
User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Tab function vs tab character

17 Nov 2020, 20:00

I agree.

In case that fails, in some cases, although pressing TAB inserts a tab character, pressing SHIFT+TAB navigates to the previous control. It might be possible to send that sequence multiple times, to navigate the controls in a reverse sequence, until you get to the right one.

Another strategy can be sending a keyboard shortcut to jump to a different control, and then sending TAB to get to the right control from there.
Slammish
Posts: 2
Joined: 17 Nov 2020, 17:55

Re: Tab function vs tab character

18 Nov 2020, 08:51

Thanks guys, I'll try to set some time aside to learn the control function. I was just kinda hoping there was something I could throw in some brackets that specifically meant next field and decided to ask here first. AHK did a great job of accounting for every other key with multiple uses, I was thinking "There's gotta be..." lol

Again, thanks all.
User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Tab function vs tab character

18 Nov 2020, 10:01

If you don't care about inserting tab characters, it might be possible to set up a Tab hotkey that does something different when you press that key. You could then also set ^Tab to send the tab character.
slrcreative
Posts: 3
Joined: 10 Jan 2024, 22:03

Re: Tab function vs tab character

10 Jan 2024, 23:32

I have the same problem.... except 4 years later.

I would need 6 tabs to move to the OK box in the app I'm using, which is IrfanView. I use it with AHK to quickly resize my photos with very good results.

Now I'm trying to enter text in several places on a photo, and then do the same on others.

This involves clicking a spot on the photo, then hitting my auto hot key which makes a small selection area for the text, then doing ctrl+T (send, ^t) to pull up IrfanView's text dialog window, then (send, the desired text), then moving to the OK button at the bottom of the window.

When doing it manually, I type in the desired text, and then simply move the mouse pointer to the OK button. But can also get there with 6 tabs, or with alt+O since the O in OK box is underlined which means the alt+O will work.

And, the alt+O does work in my AHK script with: "send, !O".

SOILER: THE FOLLOWING LINE IS NOT LONGER TRUE - see rest of the post below for explanation.

But after one run, I find that my laptop mouse clicks don't work until I manually hit ctrl+alt. After doing that, I can run my AHK script again, but with the same issue each time.

Can I just copy and paste my script here for you all to look over and let me know if I'm doing it wrong, or if I'm on the right track or not.

WAIT, I FIXED IT!!! - While getting my script ready to copy and paste, I cleaned up a couple of things and NOW IT WORKS.

My initial reaction to this fortunate turn was to just stop writing this post. But perhaps it might be of use to someone in the future with a similar task. So I am still going to copy and past my script. WHICH WORKS :xmas: :xmas: :xmas:

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.
;LINE 9
; 
; PURPOSE OF THIS SCRIPT is mouse move experimentation for the purpose of setting a small selection of part of a photo to enter text into, i.e. "Look here" or "Check this out" with a different ahk script  for each of those.  i.e.  ctrl+L fo Look and ctrl+C for Check.
; NOTE to sel - Save with .ahk extension
;*****************************************************************
; LINE 18
^l::
sleep, 200
;The script starts with mouse at any location in the photo.
sleep, 200
MouseClickDrag, Left, 25, 50, 100, 100, , R.
;That line defines the size and location of the text box on the photo.  NEED TO EXPERIMENT AND TWEEK
send, ^t
send, Look here
sleep, 200
send, !O::
sleep, 200
return
; LINE 32 v240110
I hope this helps somebody else. Thanks for letting me join your community. I'm sure I will be coming here a lot.

[Mod edit: Added [code][/code] tags. Please use them yourself when posting code!]
User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Tab function vs tab character

10 Jan 2024, 23:44

In most cases, triggering actions in programs is done with lowercase letters rather than uppercase letters. If you send an uppercase letter, AHK will honor your command by managing Shift accordingly. See the KeyHistory to learn what is happening with the keys.
slrcreative
Posts: 3
Joined: 10 Jan 2024, 22:03

Re: Tab function vs tab character

11 Jan 2024, 00:29

Thanks Mike. Checking that out now. Pretty cool and a bit intimidating at the same time. I've got a lot to learn. My sense of caution has led me to copy examples for my boilerplate and then experiment with new commands as I learn them.

May I ask about your comment in reference to the script I included in my post? I am thinking the use of uppercase is not an issue when they are in a comment which follows the semi-colon. Is that correct? I like to use them there so that it is easy for me to understand my own work when coming back to it after a bit of time.
User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Tab function vs tab character

11 Jan 2024, 00:52

Comments are never executed, so you would put anything you wish there. They have absolutely no consequence for what the script does.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: RandomBoy, Theda and 270 guests