bladem2003 Posted February 18, 2019 Share Posted February 18, 2019 hello, i want to create a virtual keyboard in that i can navigate with the arow keys. How can i navigate up and down? expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> AutoItSetOption("GUIResizeMode", $GUI_DOCKAUTO) Global $aButtons[47] Global $aKeys[47] = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", _ "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "[", "]", _ "a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", '\', _ "z", "x", "c", "v", "b", "n", "m", ",", ".", "/", "Enter"] $hGUI = GUICreate("VK", 300, 125, 500, 100, BitOR($WS_SYSMENU, $WS_POPUP), BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_NOACTIVATE)) $iCount = 0 For $j = 0 To 3 For $i = 0 To 11 If $j = 3 and $i = 10 Then $aButtons[$iCount] = GUICtrlCreateButton("", $i * 25, $j * 25, 50, 25) Else $aButtons[$iCount] = GUICtrlCreateButton("", $i * 25, $j * 25, 25, 25) EndIf GUICtrlSetData(-1, $aKeys[$iCount]) $iCount += 1 GUICtrlSetFont(-1, 10) If $iCount > 46 Then ExitLoop Next Next GUISetState() $swX = 800 $swY = 230 WinMove($hGUI, "", (@DesktopWidth - $swX) / 2, @DesktopHeight - $swY, $swX, $swY);488) $iCount = 0 For $j = 0 To 3 For $i = 0 To 11 GUICtrlSetFont($aButtons[$iCount], (20 / 240) * ($swY), 80, 1, "ARIAL") $iCount += 1 If $iCount > 46 Then ExitLoop Next Next While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit WEnd Link to comment Share on other sites More sharing options...
Nine Posted February 18, 2019 Share Posted February 18, 2019 Very hard coded but you will get the idea : expandcollapse popup#include <Constants.au3> #include <GUIConstants.au3> #include <WinAPISysWin.au3> AutoItSetOption("GUIResizeMode", $GUI_DOCKAUTO) Global $aButtons[47] Global $aKeys[47] = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", _ "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "[", "]", _ "a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", '\', _ "z", "x", "c", "v", "b", "n", "m", ",", ".", "/", "Enter"] $hGUI = GUICreate("VK", 300, 125, 500, 100, BitOR($WS_SYSMENU, $WS_POPUP), BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_NOACTIVATE)) HotKeySet ("{UP}", "_up") HotKeySet ("{ESC}", "_exit") HotKeySet ("{DOWN}", "_down") $iCount = 0 For $j = 0 To 3 For $i = 0 To 11 If $j = 3 and $i = 10 Then $aButtons[$iCount] = GUICtrlCreateButton("", $i * 25, $j * 25, 50, 25) Else $aButtons[$iCount] = GUICtrlCreateButton("", $i * 25, $j * 25, 25, 25) EndIf GUICtrlSetData(-1, $aKeys[$iCount]) $iCount += 1 GUICtrlSetFont(-1, 10) If $iCount > 46 Then ExitLoop Next Next GUISetState() $swX = 800 $swY = 230 WinMove($hGUI, "", (@DesktopWidth - $swX) / 2, @DesktopHeight - $swY, $swX, $swY);488) $iCount = 0 For $j = 0 To 3 For $i = 0 To 11 GUICtrlSetFont($aButtons[$iCount], (20 / 240) * ($swY), 80, 1, "ARIAL") $iCount += 1 If $iCount > 46 Then ExitLoop Next Next While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then _exit () WEnd Func _up () Local $pos = GetPosition () if $pos = -1 then Return if $pos > 11 then Send ("{LEFT 12}") EndFunc Func _down () Local $pos = GetPosition () if $pos = -1 then Return if $pos < 34 then Send ("{RIGHT 12}") if $pos = 35 then Send ("{RIGHT 11}") EndFunc Func GetPosition () Local $hndl = _WinAPI_GetFocus (), $button = -1 For $i = 0 to Ubound($aButtons)-1 if $hndl = GUICtrlGetHandle ($aButtons[$i]) Then $button = $i ExitLoop EndIf Next Return $button EndFunc Func _exit () Exit EndFunc “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
bladem2003 Posted February 19, 2019 Author Share Posted February 19, 2019 (edited) thank you so much. I solved it in that way expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <array.au3> HotKeySet("{RIGHT}", "_rightOsk") HotKeySet("{LEFT}", "_leftOsk") HotKeySet("{DOWN}", "_downOsk") HotKeySet("{UP}", "_upOsk") HotKeySet("{ENTER}", "_enterOsk") AutoItSetOption("GUIResizeMode", $GUI_DOCKAUTO) Global $aButtons[5][47], $iPosX, $iPosY Global $aKeys2[5][14] = [["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "="], _ ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "[", "]"], _ ["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", '\'], _ ["z", "x", "c", "v", "b", "n", "m", ",", ".", "/", "Enter"], _ ["space", "back"]] ;_ArrayDisplay($aKeys2) $hGUI = GUICreate("VK", 300, 125, 500, 100, BitOR($WS_SYSMENU, $WS_POPUP), BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_NOACTIVATE)) For $j = 0 To 3 $iCount = 0 For $i = 0 To 11 If $j = 3 And $i = 10 Then $aButtons[$j][$iCount] = GUICtrlCreateButton("", $i * 25, $j * 25, 50, 25) GUICtrlSetData(-1, $aKeys2[$j][$iCount]) GUICtrlSetFont(-1, 10) ExitLoop Else $aButtons[$j][$iCount] = GUICtrlCreateButton("", $i * 25, $j * 25, 25, 25) GUICtrlSetData(-1, $aKeys2[$j][$iCount]) GUICtrlSetFont(-1, 10) EndIf $iCount += 1 Next Next $i = 3 $aButtons[4][0] = GUICtrlCreateButton("", $i * 25, $j * 25, 150, 25, $WS_GROUP) GUICtrlSetData(-1, "Space") GUICtrlSetFont(-1, 10) $i = 9 $drag = GUICtrlCreateLabel("", $i * 25.2, $j * 25.4, 29, 24, -1, $GUI_WS_EX_PARENTDRAG) GUICtrlSetBkColor(-1, 0x6E7B8B) $i = 10 $aButtons[4][1] = GUICtrlCreateButton("", $i * 25.5, $j * 25, 45, 25, $WS_GROUP) GUICtrlSetData(-1, "<--") GUICtrlSetFont(-1, 10) GUISetState() $swX = 800 $swY = 230 WinMove($hGUI, "", (@DesktopWidth - $swX) / 2, @DesktopHeight - $swY, $swX, $swY);488) For $j = 0 To 4 For $i = 0 To 11 GUICtrlSetFont($aButtons[$j][$i], (20 / 240) * ($swY), 80, 1, "ARIAL") Next Next $iPosY = 0 $iPosX = 0 GUICtrlSetBkColor($aButtons[$iPosY][$iPosX], 0xff0000) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit WEnd Func _rightOsk() If $aKeys2[$iPosY][$iPosX + 1] <> "" Then GUICtrlSetBkColor($aButtons[$iPosY][$iPosX], 0xffffff) $iPosX += 1 GUICtrlSetBkColor($aButtons[$iPosY][$iPosX], 0xff0000) EndIf EndFunc ;==>_rightOsk Func _leftOsk() If $iPosX - 1 <> -1 Then GUICtrlSetBkColor($aButtons[$iPosY][$iPosX], 0xffffff) $iPosX -= 1 GUICtrlSetBkColor($aButtons[$iPosY][$iPosX], 0xff0000) EndIf EndFunc ;==>_leftOsk Func _downOsk() If $iPosY + 1 <> 5 Then GUICtrlSetBkColor($aButtons[$iPosY][$iPosX], 0xffffff) If $iPosY = 2 And $iPosX = 11 Then $iPosY += 1 $iPosX -= 1 GUICtrlSetBkColor($aButtons[$iPosY][$iPosX], 0xff0000) ElseIf $iPosY = 3 Then ;And $iPosX = 5 Then $iPosY += 1 If $iPosX < 9 Then $iPosX = 0 If $iPosX > 8 Then $iPosX = 1 GUICtrlSetBkColor($aButtons[$iPosY][$iPosX], 0xff0000) Else $iPosY += 1 GUICtrlSetBkColor($aButtons[$iPosY][$iPosX], 0xff0000) EndIf EndIf EndFunc ;==>_downOsk Func _upOsk() If $iPosY - 1 <> -1 Then GUICtrlSetBkColor($aButtons[$iPosY][$iPosX], 0xffffff) If $iPosY = 4 Then $iPosX = 5 $iPosY -= 1 GUICtrlSetBkColor($aButtons[$iPosY][$iPosX], 0xff0000) EndIf EndFunc ;==>_upOsk Func _enterOsk() ConsoleWrite($aKeys2[$iPosY][$iPosX] & @CRLF) EndFunc ;==>_enterOsk Edited February 19, 2019 by bladem2003 Link to comment Share on other sites More sharing options...
Nine Posted February 19, 2019 Share Posted February 19, 2019 7 hours ago, bladem2003 said: I solved it in that way Nice. Only problem with your approach is that you cannot use mouse to select a key... Look also for GUI accelerator keys instead of HotKeySet. I didn't bother with it, but that's something may interest you. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
bladem2003 Posted February 19, 2019 Author Share Posted February 19, 2019 I will use this keyboard in my htpc software which I operate with a ir remote control. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now