I'm learning about GUI's, I'm trying the below code, the idea being if I press the letter "e" while I have the GUI open I want the label color to change to green (I'm using a UDF for label colors). But every time I press "e" on my keyboard I just get a "ding" sound from my speakers and nothing changes with the label.
I've looked at using something like "While GUIGetMsg() <> $GUI_EVENT_CLOSE" as I've seen it in other code instead of "While 1", but I don't think it's relevant.
#include <GUIConstantsEx.au3>; for GUI... #include <GUIRichLabel.au3>; UDF for rich text label fonts #include <Misc.au3>; for _IsPressed $myLetter = "e" $hGUI = GUICreate("test", 700, 60) $lbl2 = _GUICtrlRichLabel_Create($hGUI, '<font color="purple">' & $myLetter & '</font>', 10, 10); , 260, 25 GUISetState(@SW_SHOW) Local $hDLL = DllOpen("user32.dll") While 1 if _IsPressed(Hex($myLetter), $hDLL) Then While _IsPressed(Hex($myLetter), $hDLL) Sleep(250) WEnd _GUICtrlRichLabel_SetData($lbl2, '<font color="green">' & $myLetter & '</font>') Sleep(2000) DllClose($hDLL) Exit EndIf Sleep(50) WEnd DllClose($hDLL) I am using an array of letters that I'm wanting to do this for, but as I can't get it to work I've stripped it down to the simplest code I can think of to try and get this working first. Appreciate any help.
I've bought a Ergodox EZ programmable keyboard with layers of key maps (eg, layer 0 = dvorak, layer 1 = numberpad & nav, layer 2 = qwerty, etc), I've also got a small USB screen that can pull information from the registry. What I would like to determine is a way to pull the value of each current key from the keyboard, I can then write the values to the registry and pull them into my USB screen so I can see the keyboard key layout.
I'm stuck with retrieving the key values, I've looked at _IsPressed(), _WinAPI_GetKeyState(), _WinAPI_GetKeyboardState(), _WinAPI_GetKeyboardType(), _WinAPI_GetKeyNameText(), but none of them appear to be able to pull the keyboard key values without user interaction.
The idea being, in pseudo code, bear in mind no error checking etc in this code, "GetKeyValue()" is what I'm needing help with and is a made up function, as is "HardwareKey1" etc:
$keyOnePrev = "" $numOfKeys = 76 While 1 $keyOneCurrent = GetKeyValue(HardwareKey1) If $keyOneCurrent <> $keyOnePrev Then For $key = 1 To $numOfKeys $keyToWrite = GetKeyValue(HardwareKey & $key) RegWrite("HKEY_CURRENT_USER\Software\myKeyboard", "key" & $key, "REG_SZ", $keyToWrite) Next EndIf $keyOnePrev = $keyOneCurrent Sleep(5000) WEnd Thanks guys!
I want a way to get the last key pressed.
I have a program that works with keyboard shortcuts and I want to give the permission for the user to edit shortcut keys depending on what suits him
i want to make read-only edit box and the program writes the latest shortcut key pressed
Please help me,
greetings to all
And thanks in advance
Hello to all,
I've written a script using following part is inserted.
Func _CallFolder() ; .... Local $_hDLL = DllOpen("user32.dll") ; .... ; .... While 1 ; .... ; .... If _IsPressed("1b",$_hDLL) then _Terminate($_hDll,$_iPID,$_hGUI) Sleep(10) WEnd ; .... ; .... EndFunc Func _Terminate($_para1, $_para2, $_para3) DllClose($_para1) ProcessClose($_para2) GUIDelete($_para3) Exit EndFunc The script is working right. But on typing "ESC" not only my script is closing all other open programs using "ESC" for termination too going closed.
I've no idea why that happens.
Maybe one of the "profis" can help me on it.
Please ecxuse my bad English but I'm a German trying his best.
Thank you and best regards, HalleMike
I want to create a loop which loops a code until for example f2 is pressed.
So I tried something with _IsPressed but it doesn't work.
Local $test = WinActivate("Notepad") Do Send("hi") Until _IsPressed("72", $test)
I don't know how I can do nothing when pressing f2 because it says "error: _IsPressed(): undefined function.".
I did put
Send("hi") after Local $test = but it gives the same error.
Does anyone know how to solve this problem?
Maybe I am wrong and I need to use a whole other Function.. I am new to AutoIT so I am sorry..