Dxnny Posted December 7, 2019 Posted December 7, 2019 Is there a way to make it so when I press a key down, it will display some information on the Koda GUI I already have made. So when I press the K key it will pop on the GUI saying "Category B is now enabled", then would disappear after 5 seconds or so.
Jfish Posted December 7, 2019 Posted December 7, 2019 Something like this? ; update label examnple #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 438, 190, 192, 124) $Button1 = GUICtrlCreateButton("Press Me", 120, 96, 185, 33) $Label1 = GUICtrlCreateLabel("Sow this label on key pree but only for three seconds", 96, 64, 253, 17) GUICtrlSetState(-1, $GUI_HIDE) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg case $Button1 GUICtrlSetState($Label1,$GUI_SHOW) sleep(3000) GUICtrlSetState($Label1,$GUI_HIDE) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt
Dxnny Posted December 7, 2019 Author Posted December 7, 2019 19 minutes ago, Jfish said: Something like this? ; update label examnple #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 438, 190, 192, 124) $Button1 = GUICtrlCreateButton("Press Me", 120, 96, 185, 33) $Label1 = GUICtrlCreateLabel("Sow this label on key pree but only for three seconds", 96, 64, 253, 17) GUICtrlSetState(-1, $GUI_HIDE) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg case $Button1 GUICtrlSetState($Label1,$GUI_SHOW) sleep(3000) GUICtrlSetState($Label1,$GUI_HIDE) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd I don't want to have to press a button on a GUI, I want to press a key down, like the letter K. Is that possible?
FrancescoDiMuro Posted December 7, 2019 Posted December 7, 2019 @Dxnny You could use WM_KEYDOWN handler, like shown here Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
Jfish Posted December 7, 2019 Posted December 7, 2019 merging the two concepts ... something like this? #include <GUIConstantsEx.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()')) GUIRegisterMsg($WM_KEYDOWN, 'WM_KEYDOWN') GUISetState(@SW_SHOW) $Label1 = GUICtrlCreateLabel("Sow this label on D key press but only for three seconds", 25, 50, 350, 25) GUICtrlSetState(-1, $GUI_HIDE) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_KEYDOWN($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam ConsoleWrite(_WinAPI_GetKeyNameText($lParam) & @CRLF) if _WinAPI_GetKeyNameText($lParam) = "D" then GUICtrlSetState($Label1,$GUI_SHOW) sleep(3000) GUICtrlSetState($Label1,$GUI_HIDE) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_KEYDOWN Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt
Nine Posted December 7, 2019 Posted December 7, 2019 It is not a good idea to hold few seconds a notification. As you can read in help file : Warning: blocking of running user functions which executes window messages with commands such as "MsgBox()" can lead to unexpected behavior, the return to the system should be as fast as possible !!! Also WM_KEYDOWN will hardly be useful if you got some controls in the GUI. Using _IsPressed function or having a keyboard callback would be better (depending if you want the key to go thru or be held)... “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) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Nine Posted December 7, 2019 Posted December 7, 2019 (edited) This is an example with _IsPressed : #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> GUICreate('Test') GUICtrlCreateInput ("", 100,100,100,25) GUICtrlCreateButton ("Test", 150,150,80,25) GUISetState(@SW_SHOW) Local $bTool = False Do If _IsPressed ("4B") Then ; K key ToolTip ("Category B is now enabled") $bTool = True $hTime = TimerInit () EndIf if $bTool and TimerDiff ($hTime) > 5000 Then ToolTip ("") Until GUIGetMsg() = $GUI_EVENT_CLOSE Key goes thru to the GUI... Here another example where key is captured : #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> GUICreate('Test') GUICtrlCreateInput ("", 100,100,100,25) $idK1 = GUICtrlCreateDummy () Local $aAccelKeys[1][2] = [["k", $idK1]] GUISetAccelerators($aAccelKeys) GUICtrlCreateButton ("Test", 150,150,80,25) GUISetState(@SW_SHOW) Local $bTool = False While True Switch GUIGetMsg () Case $GUI_EVENT_CLOSE ExitLoop Case $idK1 ToolTip ("Category B is now enabled") $bTool = True $hTime = TimerInit () EndSwitch if $bTool and TimerDiff ($hTime) > 5000 Then ToolTip ("") WEnd Edited December 7, 2019 by Nine “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) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Dxnny Posted December 8, 2019 Author Posted December 8, 2019 16 hours ago, Nine said: This is an example with _IsPressed : #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> GUICreate('Test') GUICtrlCreateInput ("", 100,100,100,25) GUICtrlCreateButton ("Test", 150,150,80,25) GUISetState(@SW_SHOW) Local $bTool = False Do If _IsPressed ("4B") Then ; K key ToolTip ("Category B is now enabled") $bTool = True $hTime = TimerInit () EndIf if $bTool and TimerDiff ($hTime) > 5000 Then ToolTip ("") Until GUIGetMsg() = $GUI_EVENT_CLOSE Key goes thru to the GUI... Here another example where key is captured : #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> GUICreate('Test') GUICtrlCreateInput ("", 100,100,100,25) $idK1 = GUICtrlCreateDummy () Local $aAccelKeys[1][2] = [["k", $idK1]] GUISetAccelerators($aAccelKeys) GUICtrlCreateButton ("Test", 150,150,80,25) GUISetState(@SW_SHOW) Local $bTool = False While True Switch GUIGetMsg () Case $GUI_EVENT_CLOSE ExitLoop Case $idK1 ToolTip ("Category B is now enabled") $bTool = True $hTime = TimerInit () EndSwitch if $bTool and TimerDiff ($hTime) > 5000 Then ToolTip ("") WEnd All I essentially want is all the console information to pop up on a GUI instead of in SciTE console.
Nine Posted December 8, 2019 Posted December 8, 2019 (edited) Well, I gave you some code example, now, it is your turn to create some... ps. don't quote every posts, we know what we told you Edited December 8, 2019 by Nine “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) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Dxnny Posted December 8, 2019 Author Posted December 8, 2019 That's not doing what I need though, I need it so when I press a key on my keyboard it will show up on the GUI, not when I press a button on the GUI itself.
Nine Posted December 8, 2019 Posted December 8, 2019 I do not understand what you are talking about, time for you to make some code. I have invested enough now, you need to make an effort on your side. “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) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
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