In autoit hotkey setting, how can I set the hotkey "ctrl + shift + alt + F1" to work? [duplicate] - autoit

This question already has answers here:
How to press "Ctrl+Shift+Q" in AutoIt
(2 answers)
Closed 5 years ago.
I tried defining it as seen below, but it is not working.
HotKeySet("^+{ALT}{F1}", "function")
How can I make a hotkey composed of more than 4 keys with Ctrl, Shift and Alt keys?
Thank you.

The syntax for ALT is !:
HotKeySet("^+!{F1}", "function")
While True
Sleep(200)
WEnd
Func function()
ConsoleWrite("Hotkey triggered" & #CRLF)
EndFunc ;==>function

Related

update map with another map [duplicate]

This question already has answers here:
Merge maps with recursive nested maps in Groovy
(4 answers)
Closed 4 years ago.
In groovy, I want to update (left merge) a map with another.
def item = [attributes:[color:'Blue', weight:500], name:'hat', price:150]
def itemUpdate = [attributes:[size: 10]]
item << itemUpdate
println item
Gives:
[attributes:[size:10], name:hat, price:150]
But what I want is:
[attributes:[color:'Blue', weight:500, size:10], name:'hat',
price:150]
I have also tried:
item += itemUpdate
or using Updating groovy object fields from a map.
None fulfils my requirements; in python the method would be the update() method.
Edit: I'm wrong about python actually.
What you're doing is effectively overwriting the attributes entry.
What you want to do, instead, is:
item.attributes = item.attributes + itemUpdate
You can even do:
item.attributes += itemUpdate
Both of which yield the expected
[attributes:[color:Blue, weight:500, size:10], name:hat, price:150]

Compare Dates in Angular 2 [duplicate]

This question already has answers here:
JavaScript Date Object Comparison
(7 answers)
Closed 6 years ago.
I'm trying to figure out how best to compare dates in Angular 2 and TypeScript 1.8.7.
Given:
startDate: Date;
endDate: Date;
if(this.startDate.getUTCMilliseconds() === this.endDate.getUTCMilliseconds()){
//do stuff here
} else {
// do something else here
}
This will return an error like "startDate.getUTCMilliseconds is not a function..."
Does somebody have a best practice? Thanks,
Date object method to get milliseconds is called getTime.
You can compare Date objects directly, with operators like <, >, and ==.
this.startDate == this.endDate
I know it's irrelevant and not what you asked for, but use angular-moment / momentjs. Dates in JS are a complete mess.

Error with Python 3 in RPi [duplicate]

This question already has answers here:
Troubleshooting "TypeError: ord() expected string of length 1, but int found"
(2 answers)
Closed 3 years ago.
First, sorry if I have a bad English or if anything is wrong, this is my first "post".
I'm trying to use a USB gamepad to turn an LED on and off with gpiozero.
I have an error while trying to execute the program:
import sys
from gpiozero import LED
led = LED(17)
pipe = open('/dev/input/js0', 'rb')
msg = []
while 1:
for char in pipe.read(1):
msg += [ord(char)]
if len(msg) == 8:
if msg[6] == 1:
if msg[4] == 1:
print ('button', msg[7], 'down')
led.on()
else:
print ('button', msg[7], 'up')
led.off()
msg = []
Error:
File "script.py", line 13, in <module>
msg += [ord(char)]
TypeError: ord() expected string of length 1, but int found
What can I do to solve this?
Thanks.
Looks like to are trying to add items to a list. Make use of append().
Documentation:
list.append(x)
Add an item to the end of the list. Equivalent to a[len(a):] = [x].
Example of append vs extend for future use:
append vs. extend
In the end I didn't get it to work with the version I was using, I just used a different python version instead.
Thanks for the help.

Autoit get current caret position Or current text box position

So i am working on a project and i got stuck on this part.
I am trying to locate the position of ether the typing caret(The blinking line while typing) or the current text box that is being typed in.
The main part that is hard is i am looking to do this for every input on my computer (Firefox search, Notepad, Renaming files, writing this post...)
I am beginning to doubt that auto-it can do this, i am open to using another language that can do this. (I have not checked any other language but Auto-it yet)
I have tested "WinGetCaretPos()" and a few other random scripts, but they had the same problem, they don't return the correct position.
~Thanks
Not all controls are standard window controls that can be accessed with AutoIt functions. Many programs (especially browsers) have nonstandard controls so "every input" on the computer might be hard to get.
Here is an example of how to get the control information of any active window that is giving focus to a control AND has standard windows controls.
HotKeySet("{ESC}", "Terminate")
While 1
Sleep(500)
GetControlFocus()
WEnd
Func GetControlFocus()
Local $hWinHandle = WinGetHandle("[Active]")
Local $sControl = ControlGetFocus($hWinHandle)
Local $sText = "The active window handle is: " & $hWinHandle & #CRLF
If $sControl <> "" Then
$sText &= "The control with focus in the active window is: " & $sControl & #CRLF
Local $aPos = ControlGetPos($hWinHandle, "", $sControl)
$sText &= "Mouse position: X: " & $aPos[0] & " Y: " & $aPos[1] & #CRLF & "Size: " & $aPos[2] & ", " & $aPos[3]
Else
$sText &= "The active window is not giving focus to a control that AutoIt recognizes."
EndIf
ToolTip($sText, 0, 0)
EndFunc ;==>GetControlFocus
Func Terminate()
Exit
EndFunc ;==>Terminate
You can get the control position of other programs using IUIAutomation and this UDF. But it would not be as simple as using a few standard AutoIt functions.

AutoIt: Illegal text at end of statement

I'm unable to figure out what it wrong with this
Func Hypotenuse($a, $b)
Return sqrt($a * $a + $b * $b)
EndFunc
Error is
Func Hypotenuse($a, $b)
Func Hypotenuse($a, $b)^ERROR
Error: Illegal text at end of statement (one statement per line).
EDIT: It appears to have been a hidden character
Well, nothings wrong there :O
This:
Func Hypotenuse($a, $b)
Return sqrt($a * $a + $b * $b)
EndFunc
ConsoleWrite(Hypotenuse(2,2))
Works perfect for me? And for you? Whats the rest of the Code?
You copied code from AutoIt forum or some other Invision Power Board driven forum.
If that is correct, you copy the end-of-line HTML-character if you don't pop out the code box. Easiest fix for many lines is to CTRL + A, copy & paste into Notepad, then copy that and paste back into SciTE.
This sort of thing can happen when you call your function from the incorrect If..Then statement. For example, the code
If Hypotenuse(1,1) > 0 Then ConsoleWrite("test" & #CRLF) EndIf
gives you an "Illegal text at end of statement" error, whereas the code
If Hypotenuse(1,1) > 0 Then ConsoleWrite("test" & #CRLF)
or
If Hypotenuse(1,1) > 0 Then
ConsoleWrite("test" & #CRLF)
EndIf
works just fine.
I had the same issue when I had an extra ) at the end of the call.
Real code issue:
LogProgram("(SM) Selected Image SM: " & $imageList[$smPicName]))
Correct:
LogProgram("(SM) Selected Image SM: " & $imageList[$smPicName])

Resources