Search the Community
Showing results for tags 'key'.
-
Greetings, Someone can help-me to translate this Python's code to AutoIt? Python (source: https://repl.it/repls/InstructiveDarkslategreyJackrabbit) str = 'age=12,name=bob,hobbies="games,reading",phrase="I\'m cool!"' key = "" val = "" dict = {} parse_string = False parse_key = True # parse_val = False for c in str: print(c) if c == '"' and not parse_string: parse_string = True continue elif c == '"' and parse_string: parse_string = False continue if parse_string: val += c continue if c == ',': # terminate entry dict[key] = val #add to dict key = "" val = "" parse_key = True continue elif c == '=' and parse_key: parse_key = False elif parse_key: key += c else: val+=c dict[key] = val print(dict.items()) Python's output: [('phrase', "I'm cool!"), ('age', '12'), ('name', 'bob'), ('hobbies', 'games,reading')] AutoIt #include-once #include <Array.au3> #include <StringConstants.au3> Global $opt $opt = "estado = """" , cep = """", idade=32, nome = ""Luismar"", campo=""campo = campo""" $opt = "age=12,name=bob,hobbies=""games,reading"",phrase=""I\'m cool!""" ConsoleWrite($opt & @LF) Local $arr = StringSplit($opt, "", $STR_CHRSPLIT) Local $key = "" Local $val = "" Local $dict = ObjCreate("Scripting.Dictionary") Local $parse_string = False Local $parse_key = True Local $c For $ii = 1 To $arr[0] $c = $arr[$ii] If $c == '"' And Not $parse_string Then $parse_string = True ContinueLoop ElseIf $c == """" And $parse_string Then $parse_string = False ContinueLoop EndIf If $parse_string Then $val &= $c ContinueLoop EndIf If $c = "," Then $dict.Add($key, $val) $key = "" $val = "" $parse_key = True ContinueLoop ElseIf $c == "=" And $parse_key Then $parse_key = False ElseIf $parse_key Then $key &= $c Else $val &= $c EndIf Next $dict.Add($key, $val) ; missing this line... For $each In $dict ConsoleWrite($each & " = " & $dict.Item($each) & @LF) Next AutoIt's output age=12,name=bob,hobbies="games,reading",phrase="I\'m cool!" age = 12 name = bob hobbies = games,reading Best regards.
-
Hi All, 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!
-
Hi guys! I took @GaryFrost's Scripting Dictionary UDF and made just a few modifications. It now accepts multiple Scripting Dictionary objects around your script (many at once) and also allows you to choose any name for your variable. Also, it now uses OOP-like approach as proposed by @guinness. The modifications were too simple (and I would post it on the original thread, but it's dated 2007) so all credit goes to @GaryFrost. Example: #include 'scriptingdic.au3' #include <Array.au3> ; Needed only for _ArrayDisplay, and not required by the lib ; Init the object $oObj = _InitDictionary() ; Adding a single value _AddItem($oObj, 0, "Test") ; And showing it msgbox(0, '', _Item($oObj, 0)) ; Adding an array Dim $aArr[] = [0, -80, -49, -44, 80, 100, 8, 7, 6, 5, 4, 3, 2, 1] _AddItem($oObj, 1, $aArr) ; And showing it _ArrayDisplay(_Item($oObj, 1)) ; We can also use this approach: $oObj3 = _InitDictionary() $oObj.Add("test", "foo") MsgBox(0, '', $oObj.Item("test")) Download: scriptingdic.au3
-
Hi all 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
-
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..
- 16 replies
-
- _ispressed
- autoit
-
(and 2 more)
Tagged with:
-
Hi, i a stuck with a hopefully a little problem. I know the value of a not yet known key in an ini file. I need to be able to find the key using the value. The value is a unique value in a section. Hope you guys can help me.
-
How do I chain letters in a HotKeySet? This works: HotKeySet("+!d", "function")I tried this but does not work HotKeySet("abc", "function")Just reacts to the a, how to accomplish this?
-
Hi all, I currently have this small script here: $T_INIT = TimerInit() Do Send("{DEL down}") Until TimerDiff($T_INIT) >= 2000 ;2000 miliseconds = 2 seconds, exactly how long it takes to delete one entire row in Microsoft Word Send("{DEL up}") What the above code does is hold down the delete key for 2 seconds. How would I make this script do the exact same thing if I had "DEL" as a variable? For example something like this: (Which by the way doesn't work) $ChosenKey = "DEL" $T_INIT = TimerInit() Do Send("{$ChosenKey& down}") Until TimerDiff($T_INIT) >= 2000 Send("{$ChosenKey& up}")All the parenthesis and "&" symbols and brackets make this difficult.
-
The scenario is thus: You have a button on a gui, and it does an action that takes some time - let's just assume it is a sleep(20000). The user clicks the button, the script does it's thing. HOWEVER if the user gets impatient and clicks the button again before it finishes, or if they spam the button, you will get an endless looping of the function over and over. Is there any way that if I had a function that took a while to run, and someone clicked the button to start/restart it again, that I could immediately kill/return the function instead of waiting for it to finnish? Or would there be a way to disable the gui from accepting and clicks or keystrokes until the current function finishes executing? My goal is to avoid the pressing the button twenty times impatiently making it do the same thing over and over.
-
In the serie of handy Tiny tools, here is RegJumper ! Open Registry Editor to the Reg Key who is copied in the clipboard. Reg Keys are automatically added to Regedit favorites. For an easy "navigation" favorites names are Reg Keys. If Key doesnt exists RegJumper offers you to open his ( existing ) parent Key. 32 or 64 bits Reg Keys will be adapted to your OS env. Favorites are limited to 20, deleting the oldest Keys. Without Reg Key in clipboard it open Registry Editor as usual to the last opened Key but if you hold "Left SHIFT" Key when clicking, it will be open to the root. Only an Icon used for compilation is downloaded at first execution. I was a bit tired of clicking in the registry editor for access a key. One day i have found a vbs script who use the fact to delete the last opened reg key for open it to the root. Playing with this astuce and after some tries for add some functionnalities, i have made this tiny tool. Previous Downloads : 795 Source : RegJumper1.0.1.7.au3.html Executable : RegJumper.exe.html (Once this html file downloaded, double click on it for start the download) Will be added to the next version of SciTE Hopper. Trying it, it's adopt it ! Hope you find it handy !
-
Hi there, the title says it all. My problem here is: im starting the autoit compiled .exes from a cmd window. So im also passing needed parameters there. These parameters are in this case paths to files, and sometimes some slashes within these paths got switched with the german "ß" character which lies on the same key as the backslash. After checking the cmd window the .exe call with the parameter includes the correct path. For some odd reason its only happening sometimes and also only in the license_A_Prof_Sec function. So any hints what could cause this problem? Here is my code: #RequireAdmin run("C:\Program Files (x86)\Avira\AntiVir Desktop\avcenter.exe") sleep(2000) $aWins=WinList("Avira") For $i = 1 To $aWins[0][0] Switch $aWins[$i][0] case "Avira Professional Security" license_A_Prof_Sec($aWins[$i][1]) Case "Avira Free Antivirus" license_A_Free_AV($aWins[$i][1]) EndSwitch Next func license_A_Free_AV($handle) WinActivate($handle) sleep(3000) Send("!H") Send("m") $whnd=winwait("Avira Free Antivirus","Lizenz",60) ControlClick($whnd,"","[CLASS:Static; INSTANCE:4]") $whnd=winwait("Öffnen") ControlSend($whnd,"","[CLASS:Edit; INSTANCE:1]",$CMDLine[1]) ControlClick($whnd,"","[CLASS:Button; INSTANCE:1]") $whnd=WinWait("Avira Free Antivirus","Lizenz ist bereits vorhanden",60) ControlClick($whnd,"","[CLASS:Button; INSTANCE:1]") $whnd=WinWait("Avira Free Antivirus","Die Lizenzdatei wurde aktualisiert",60) ControlClick($whnd,"","[CLASS:Button; INSTANCE:1]") $whnd=WinWait("Avira Free Antivirus","Lizenzinformationen",60) sleep(500) ControlClick($whnd,"","[CLASS:Button; INSTANCE:8]") winclose("Avira Free Antivirus") EndFunc func license_A_Prof_Sec($handle) WinActivate($handle) sleep(3000) Send("!H") Send("l") $whnd=winwait("Öffnen","",60) ControlSend($whnd,"","[CLASS:Edit; INSTANCE:1]",$CMDLine[1]) ControlClick($whnd,"","[CLASS:Button; INSTANCE:1]") $whnd=WinWait("Avira Professional Security","Die Lizenzdatei wurde aktualisiert",60) ControlClick($whnd,"","[CLASS:Button; INSTANCE:1]") winclose("Avira Professional Security") EndFunc
-
so I have a script, and it contains Send("{RCTRL down}") ;Holds the right control key this seems to work fine, and that's half the problem. The other half is this Send("{RCTRL up}") ;Releases the right control key This does not seem to be working, cause after I run this script, my system seems to act as if right control is forever engaged, I'm forced to log out then back in to get rid of it.
-
IsPressed_UDF is based on original _IsPressed function. Description : -This udf can detect if some keys are pressed by user on keyboard or mouse. -IsPressed functions extend possibility to choice keys to check. -Keys are specified in functions by their hexadecimal number, ['0D' = 'ENTER'] you can also translate hexadecimal key to alpha key (see functions and examples) Update : [Latest: 12 Jun 2013] Functions : Exemples : IsPressed_UDF 2.3 : IsPressed_UDF.au3 IsPressed_UDF 2.2 : IsPressed_UDF.au3 Add IsPressed_UDF functions to SciTE : IsPressed_Function Enjoy !
- 104 replies
-
- _ispressed
- key
-
(and 2 more)
Tagged with:
-
Hello! Do anyone know a simple program, a website, or perhaps a simple AutoIt script to achieve the following: When i press [Enter], ".", or any othey key, I want to see for how long that specific key is pressed down. This should generally be a very low number, a few milliseconds perhaps. I want to measure this with precision. Later on I want to measure mouse clicks as well (down time), but I'd love to start look at keyboard data. Thanks in advance!
-
how can i check if the quote key (') is pressed?
-
I want to send key to On-Screen Keyboard (program in win 7) and then On-Screen Keyboard program send that key to notepad, but my script is not work, this is my script: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <Timers.au3> Global $nDelay,$handle,$pid; $nDelay = 2000 $gui = GUICreate("My GUI",200,100) $button_gen = GUICtrlCreateButton("Start",10,30,60) $button_stop = GUICtrlCreateButton("Stop",10,60,60) $handle = WinGetHandle('On-Screen Keyboard', "") $pid = WinGetProcess($handle) GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $button_gen _Timer_SetTimer($gui, $nDelay, "AutoTDK") Case $button_stop _Timer_KillAllTimers($gui) EndSwitch WEnd GUIDelete() Func AutoTDK($hWnd, $Msg, $iIDTimer, $dwTime) WinActivate("Untitled - Notepad") ; active notepad program ControlSend($handle, "", $pid,"{SPACE}") ; send space key to On-Screen Keyboard EndFunc pls help me
-
Note: This is completely unrelated to the program offered on TuCows and CNET, I named it without ever checking the title, and I may decide to change it at will. What Does it do? This program allows you to require a specific drive (USB preferably) to be connected to the computer to gain access while the program is running. Downloads: USBLock.zip (Includes Source code, Compiled version, and English .LANG file) UPDATES: (click "see post" to see notes on changes) Version 6: see post Version 5: see post Version 4: see post Version 3: see post Version 2: see post ----------------------------------- -How does it do it? 1a. On a normal run, the program will ask you for a drive letter to assign as a "Key Drive". 1b. A drive letter is assigned by command-line parameter. 1c. The "auto" parameter is used, and we skip to Step 4. 2. The Program will then generate a random keyfile, save a hash of the keyfile locally and save the actual keyfile on the root of the chosen/validated drive. 3. Waits until the keydrive is removed. 4. BlockInput is called 5. Then the program then checks repeatedly for the existence of the keyfile on all drives 6. The keyfile is validated, if it is valid, BlockInput is released and we return tp Step 2. 7. Assuming the keyfile is invalid, it is deleted and we return to step 5. Note: There is a special keyfile that can be saved on a drive that will shut down the program to allow emergency access. (if you edit the emergency text in the script, you will need to edit your own emergency keyfile) USBLock_Emergency_Keyfile.zip Requirements: WindowsConstants.au3 GUIConstants.au3 StaticConstants.au3 String.au3 Misc.au3 myToast.au3 - by me (given) MD5.au3 - which is either by: - Ward (Using CallWindowProc; I suggest this one.) - Frez Systems Ltd and SvenP (all AutoIt) - Other Credits: Monitor On/Off Example - MrCreatoR MD5 - SvenP or Ward ... let me know if you were missed for credit. EDIT: fixed the "steps" explanation 5-5-13 Edit: Re-added images to post