Jump to content

Keyboard navigation in a GUI with GUICtrlCreatePic


azaze1
 Share

Recommended Posts

Hi all,

I'm a decent Shell scripter in Linux (familar with scripting constructs etc), but pretty new to AutoIT. I used it some 6 years ago for 1 project.. so it's been a while.

What i'm trying to do today is an extremely simple GUI window that will present 2 images next to each other, with a small icon to close/exit if desired.

I modfied a sample script from the install with some online docs etc and have come up with something that works if you use a mouse to click on the images... but I'd like this to be something that responds to keyboard presses for left/right navigation and selection rather than depending on a mouse click (it will be used via a HTPC remote control which sends keyboard presses).

Code is below, and for testing purposes I've got 'XBMC' launching the calc.exe program while Windows Media Center launches notepad.exe. I'll be replacing these with the real apps once I get this working as desired.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ListviewConstants.au3>
#include <Misc.au3>

; Make sure only one instance of this script can run at a time
If _Singleton("pict_media", 0) = 0 Then
Exit
EndIf
; If either XBMC or WMC is running... then exit this script
If ProcessExists("calc.exe") Then
Exit
ElseIf ProcessExists("notepad.exe") Then
Exit
EndIf


_Main()


Func _Main()
Local $xbmcID, $wmcID, $ExitID, $msg

GUICreate("Media Selector", 960, 400, -1)

GUISetBkColor(0x000000)

GUICtrlCreateLabel("Choose your player", 10, 10)

$xbmcLOGO = GUICtrlCreatePic("xbmc_logo_400_black.jpg", 10, 80, 400, 200)
$wmcLOGO = GUICtrlCreatePic("wmc_logo_400_black.jpg", 460, 80, 400, 200)
$ExitID = GUICtrlCreateButton("Exit", 860, 50, 80, 20)

GUISetState() ; display the GUI
$lkejr = "some stuff"

Do
     $msg = GUIGetMsg()

Select
Case $msg = $xbmcLOGO
;MsgBox(0, "You clicked on", "XBMC")
;Run("C:\Users\htpc\Documents\XbmcLauncher.exe")
Run("C:\windows\system32\calc.exe")
Case $msg = $wmcLOGO
;MsgBox(0, "You clicked on", "Windows Media Center")
     ;Run("C:\Windows\ehome\ehshell_m.exe")
Run("C:\windows\system32\notepad.exe")
Case $msg = $ExitID
;MsgBox(0, "You clicked on", "Exit")
Case $msg = $GUI_EVENT_CLOSE
;MsgBox(0, "You clicked on", "Close")
EndSelect
Until $msg = $GUI_EVENT_CLOSE Or $msg = $xbmcLOGO Or $msg = $wmcLOGO Or $msg = $ExitID
EndFunc ;==>_Main
Link to comment
Share on other sites

Well, I've updated it a bit to stick with buttons since they can take a $BS_BITMAP turning the button into a picture... and keyboard navigation works just fine with this.

Now the only thing I need to do is make the button with the current focus have some sort of an obvious border around it so that it's completely obvious which one you're about to select when hitting return. Right now it's just a tiny dotted line which is impossible to see without being right next to the screen.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...