Make edit control default for alwaysontop ahk window

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
gallaxhar
Posts: 143
Joined: 03 Sep 2014, 06:35

Make edit control default for alwaysontop ahk window

28 Feb 2016, 04:13

My ahk window has an edit control, and a listview.
I have set the window to be always on top, by using this code:

Code: Select all

WinGet, active_id, ID, A
WinSet, AlwaysOnTop, ON, ahk_id %active_id%
The edit control has focus when the gui is first created, if I left click on another window, such as notepad, and then try to type, the listview on my ahk gui has focus. This is actually close to what I want, except I want the edit control to have focus instead of the listview by default.

I tried

Code: Select all

GuiControl, +Default, ControlID
I used the vVariable from the edit control as the controlID, then I tried to use the g-label, then I tried to use the hwndHWNDVAR, none worked.
What is the proper controlID?
I also encountered a "paramter #1 is invalid" each time. That is, it's saying the +Default is invalid.
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Make edit control default for alwaysontop ahk window

28 Feb 2016, 04:18

Not sure what you mean. As long as another window is active, none of the GUI controls will have the focus.
gallaxhar
Posts: 143
Joined: 03 Sep 2014, 06:35

Re: Make edit control default for alwaysontop ahk window

28 Feb 2016, 04:32

When another window tries to be active, it seems the alwaysontop keeps my listview active, when I try to type, it starts navigating the listview via keyboard by going to listview rows with those characters
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Make edit control default for alwaysontop ahk window

28 Feb 2016, 04:59

That's not the standard behavior. You should provide some more code.
gallaxhar
Posts: 143
Joined: 03 Sep 2014, 06:35

Re: Make edit control default for alwaysontop ahk window

28 Feb 2016, 06:32

your feedback led me to the answer, the script has grown quite long and I forgot there was a hotkey catching the left mouse button, which sent focus to the listview... im an idiot

so the real problem now is I need to make any key press send focus to the edit control, while keeping left clicks and mouse wheels sending focus to the listview (right click exits the script)

of course I could make a long list of hotkeys like
~a::
~b::
~c::
...
~z::
ControlFocus, Edit, MyEdit

and I guess that's what I'll do, unless there's a better way
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Make edit control default for alwaysontop ahk window

28 Feb 2016, 06:38

So do you want to allow to activate other windows, or not?
gallaxhar
Posts: 143
Joined: 03 Sep 2014, 06:35

Re: Make edit control default for alwaysontop ahk window

28 Feb 2016, 06:43

no, I'm trying to give it similar behavior as basically a context menu, it's like a context menu but in listview form, with an edit box to search the contents
the mouse of course scrolls the listview, left click selects, right click closes the "context menu listview edit box hybrid" altogether, and any key press sends to the edit box

looks like to detect any key press, this code i found on the forum will work

Code: Select all

Input, SingleKey, L1, {LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{AppsKey}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}{BS}{Capslock}{Numlock}{PrintScreen}{Pause}
Msgbox, A key was pressed.
Return
I'll have to test and see if ctrl+v for paste still works (modifier+another key at same time), and stuff like that
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Make edit control default for alwaysontop ahk window

28 Feb 2016, 07:06

You must have something (like a Hotkey) to prevent other windows from being activated, then. Just set the focus where you do it..

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Lpanatt, macromint, peter_ahk, Spawnova and 271 guests