1. can each of these have modifier keys too? ex: shift + numpad2 + ctrl + numpad8 (order doesn't matter)You can define a custom combination of two (and only two) keys (except controller buttons) by using & between them. In the example below, you would hold down Numpad0 then press Numpad1 or Numpad2 to trigger one of the hotkeys
ahk documentation questions
-
- Posts: 142
- Joined: 28 Oct 2020, 02:58
ahk documentation questions
hello. this topic will include some questions I have regarding ahk documentation. thanks in advance for all help.
Re: ahk documentation questions
Hello,
These questions are OK but you can answer them more quickly and directly by running your test scripts. In other words, to answer the question, "Will my script work?", you can always run your script to find out! Your script might even execute more quickly than this forum server could record your post!
The same page that you are citing also discusses combinations of three or more keys, and provides you with an example of how to approach that. When you have a script that does not work, you can post it here to get specific feedback about it.
If you have more questions, I would avoid hiding them here. Post a list, or create new threads if you feel that the topics differ much.
These questions are OK but you can answer them more quickly and directly by running your test scripts. In other words, to answer the question, "Will my script work?", you can always run your script to find out! Your script might even execute more quickly than this forum server could record your post!
The same page that you are citing also discusses combinations of three or more keys, and provides you with an example of how to approach that. When you have a script that does not work, you can post it here to get specific feedback about it.
If you have more questions, I would avoid hiding them here. Post a list, or create new threads if you feel that the topics differ much.
-
- Posts: 142
- Joined: 28 Oct 2020, 02:58
Re: ahk documentation questions
okaythank you mikey. another question: in the docs they didnt define / show how you would use this is it a way to create an object without having a class and without being able to easily make more objects with similar properties / methods??
not sure if this example is right but
thanks in advance
Code: Select all
{ ... } / Object Creates an Object from a list of property name and value pairs.
not sure if this example is right but
Code: Select all
obj1 = {
name = "mary"
int2 = 16
myfunc(x=16){
return sqrt(x)
}
}
Re: ahk documentation questions
You can use a map object.
Code: Select all
#Requires AutoHotkey v2.0
obj1 := Map(
'name', 'mary'
, 'int2', 16
)
MsgBox myfunc(obj1['int2']), 'Result', 'Iconi'
myfunc(n) {
Return Sqrt(n)
}
-
- Posts: 142
- Joined: 28 Oct 2020, 02:58
Re: ahk documentation questions
okay thank you. this works but I'm not sure if I wasn't clear. creating an object using map is like creating a dictionary, no? what I meant was that: is it possible to create an object as an instance of a class without creating a class? so I would just use this (or something similar if it exists) and use the syntax associated with objects as instances of a class. (ex x.name, x.myfunction() , ...)
Code: Select all
x = {
name= "alice"
age = 22
}
Re: ahk documentation questions
v2.1
Code: Select all
obj1 := {
name : "mary",
int2 : 16,
myfunc: (this,x:=16){
return sqrt(x)
}
}
Last edited by thqby on 25 May 2024, 08:12, edited 1 time in total.
-
- Posts: 142
- Joined: 28 Oct 2020, 02:58
Re: ahk documentation questions
@thqby I tried your way and I get
Error: Unexpected "{"
038: Return
040: {
▶ 041: obj1 := { name : "mary" int2 : 16 myfunc: (this,int2:=16){ return sqrt(int2) } }
048: msgbox(type(obj1))
049: }
I also tried my way I get something weird:
Error: Missing "propertyname:" in object literal.
038: Return
040: {
▶ 041: x := { name = "alice" age = 22 }
Error: Unexpected "{"
038: Return
040: {
▶ 041: obj1 := { name : "mary" int2 : 16 myfunc: (this,int2:=16){ return sqrt(int2) } }
048: msgbox(type(obj1))
049: }
I also tried my way I get something weird:
Error: Missing "propertyname:" in object literal.
038: Return
040: {
▶ 041: x := { name = "alice" age = 22 }
Re: ahk documentation questions
V2.1 is required, not V2.0.
In addition, some line breaks are necessary.
In addition, some line breaks are necessary.
-
- Posts: 142
- Joined: 28 Oct 2020, 02:58
Re: ahk documentation questions
okay so I guess i'll either use classes or maps like how mikey suggested. thank you