 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
i3egohan
Joined: 18 Jul 2006 Posts: 315
|
Posted: Sat Jul 12, 2008 11:31 pm Post subject: Button Focus |
|
|
Hey guys, I have a question.
Ok, in my GUI i have some pictures that act has button's using label's.
This GUI is for a computer that has no mouse (dont ask why it just does) so i want to give the user a easy GUI with just a keyboard, so the user tabs across the buttons etc and uses the arrow keys on his/her keyboard to select buttons, but the user cannot see which button is currently in focus.
So i need a way to change the picture to a diffrent picture when the focus/tab is currently on the button/picture.
If you can anwser the above then have you got a anwser to achive the same goal using normal GUI buttons.
Thanks in advanced! _________________ `Autohotkey User`
- I3egohan |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 666 Location: MN, USA
|
|
| Back to top |
|
 |
i3egohan
Joined: 18 Jul 2006 Posts: 315
|
Posted: Sat Jul 12, 2008 11:58 pm Post subject: |
|
|
thanks but, the images doesnt change when you use the arrows keys.. i need something that will show the user which button there currently focused on, if you goto that link you gave me and download the sample, and try to use your arrow keys the image dont change, its only when the mouse is hovering over it.
Thanks thou, still need help _________________ `Autohotkey User`
- I3egohan |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 1145 Location: The Interwebs
|
Posted: Sun Jul 13, 2008 12:12 am Post subject: |
|
|
| Use ControlGetFocus on a timer, then change whichever picture has current focus |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 6264
|
Posted: Sun Jul 13, 2008 4:04 am Post subject: |
|
|
| Krogdor wrote: | | Use ControlGetFocus on a timer |
only Input-capable controls will recieve keyboard focus..
 _________________
 |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 1145 Location: The Interwebs
|
Posted: Sun Jul 13, 2008 4:22 am Post subject: |
|
|
Ooh... right... Silly me  |
|
| Back to top |
|
 |
i3egohan
Joined: 18 Jul 2006 Posts: 315
|
Posted: Sun Jul 13, 2008 4:14 pm Post subject: |
|
|
So is there anyway at all? _________________ `Autohotkey User`
- I3egohan |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 666 Location: MN, USA
|
Posted: Sun Jul 13, 2008 4:37 pm Post subject: |
|
|
The easiest way is to use normal buttons with a picture next to each one as a visual indication of what the button does.
I think graphic buttons are a bit frivolous; but if you're determined to do it, you can create them manually by manipulating picture controls. | Code: | #SingleInstance force
#NoEnv
Gui, Margin, 20,20
Loop,40
{
If A_Index in 1,11,21,31
coord = m
Else coord = +20
Gui, Add, Picture, x%coord% Icon%A_Index%, shell32.dll
}
F=0
Gui, Show
return
GuiClose:
ExitApp
#IfWinActive ahk_class AutoHotkeyGUI
Tab::
Backspace::
Left::
Right::
Up::
Down::
prev := F
F := A_ThisHotkey="Tab" ? F+1
:A_ThisHotkey="Backspace" ? F-1
:A_ThisHotkey="Left" ? F-1
:A_ThisHotkey="Right" ? F+1
:A_ThisHotkey="Up" ? F-10
:A_ThisHotkey="Down" ? F+10:F
F := F<1 ? F+40:F>40 ? F-40:F
GuiControl, +Border, Static%F%
GuiControl, MoveDraw, Static%F%, w36 h36
GuiControl, -Border, Static%prev%
GuiControl, MoveDraw, Static%prev%, w32 h32
return
Enter::MsgBox, 64, Enter, You selected picture #%F%. | This is a very simple design, but it gives you the general idea. More functionality would be more work, but if you're determined... _________________ http://autohotkey.net/~jaco0646/ |
|
| Back to top |
|
 |
i3egohan
Joined: 18 Jul 2006 Posts: 315
|
Posted: Sun Jul 13, 2008 10:58 pm Post subject: |
|
|
Thanks really appriciate it! Im still open for suggestions so if someone got better code etc, Then post here.
Thanks again _________________ `Autohotkey User`
- I3egohan |
|
| Back to top |
|
 |
nick
Joined: 24 Aug 2005 Posts: 345 Location: Berlin / Germany
|
Posted: Mon Jul 14, 2008 5:15 am Post subject: |
|
|
| i3egohan wrote: | | If you can anwser the above then have you got a anwser to achive the same goal using normal GUI buttons. |
| Code: | #NoEnv
OnMessage(WM_COMMAND := 0x111, "WM_COMMAND")
BS_NOTIFY := 0x4000
Gui, +ToolWindow +AlwaysOnTop
Gui, Margin, 10, 10
Gui, Add, Button, w150 vBT1 gBT1 hwndBT1ID +%BS_NOTIFY%
GuiControl, , BT1, %BT1ID%
ButtonList := BT1ID
%BT1ID% := "BT1"
Gui, Add, Button, ym wp vBT2 gBT2 hwndBT2ID +%BS_NOTIFY%
GuiControl, , BT2, %BT2ID%
ButtonList .= "," . BT2ID
%BT2ID% := "BT2"
Gui, Add, Button, xm wp vBT3 gBT3 hwndBT3ID +%BS_NOTIFY%
GuiControl, , BT3, %BT3ID%
ButtonList .= "," . BT3ID
%BT3ID% := "BT3"
Gui, Add, Button, x+10 wp vBT4 gBT4 hwndBT4ID +%BS_NOTIFY%
GuiControl, , BT4, %BT4ID%
ButtonList .= "," . BT4ID
%BT4ID% := "BT4"
Gui, Add, Text, xm w150 vTX
Gui, Add, Edit, xm y+5 w310 r20 vED1 T35 HwndEDID
GuiControl, , TX, &%EDID%
Gui, Show, , Buttons
Return
; ------------------------------------------------------------------------------
BT1:
BT2:
BT3:
BT4:
Return
; ------------------------------------------------------------------------------
GuiClose:
ExitApp
; ------------------------------------------------------------------------------
WM_COMMAND(W, L, M, H) {
Global
Static BN_SETFOCUS := 0x6
Static BN_KILLFOCUS := 0x7
Static BN_CLICKED := 0x0
Static BN_DBLCLK := 0x5
SetBatchLines, -1
SetFormat, Integer, H
HWND := L+0
If HWND In %ButtonList%
{
MSG := (W >> 16) + 0
CID := (W & 0xFFFF) + 0
If (MSG = BN_SETFOCUS Or MSG = BN_KILLFOCUS)
{
Gui, Font, % (MSG = BN_SETFOCUS ? "W1000" : "Norm")
GuiControl, Font, %HWND%
}
}
Return 0
} |
_________________ nick
denick @ http://de.autohotkey.com/forum/ |
|
| Back to top |
|
 |
i3egohan
Joined: 18 Jul 2006 Posts: 315
|
Posted: Mon Jul 14, 2008 12:00 pm Post subject: |
|
|
Thanks nick, another nice example! _________________ `Autohotkey User`
- I3egohan |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|