Hi,
I'm seeking for help again for a script that include a class name that change slightly. I think that i have to introduce a variable at the part that is changing but can't figure out how to do it. I have done a load of researches without finding the solution, so if a more knowledgable person than me could help, that would be great.
Thanks in advance
How to write the script with a variable class?
How to write the script with a variable class?
Last edited by necomerx on 28 Jan 2021, 07:26, edited 1 time in total.
-
- Posts: 15
- Joined: 11 Sep 2017, 23:47
Re: How to write the script with a variable class?
Hi, I'm no expert with AHK classes, but why do you need a variable class?
Isn't easier to just create a new instance of a class? Or give the classes a property that you can use to trigger certain code.
If you initialize the class with such a variable, you can trigger conditions within the class. Depending on your use case it might not be the prettiest solution, but in python this would work. I'm guessing AHK works about the same way with classes.
Isn't easier to just create a new instance of a class? Or give the classes a property that you can use to trigger certain code.
Code: Select all
self.uniqueID := 'whatever you throw in here'
Re: How to write the script with a variable class?
Hi, Thanks for your reply.
Do you think that the self.uniqueID gonna be the solution? Can you give me an example with my script because i still have a lot to learn in Autohotkey and don't know how to do that
Do you think that the self.uniqueID gonna be the solution? Can you give me an example with my script because i still have a lot to learn in Autohotkey and don't know how to do that
Last edited by necomerx on 28 Jan 2021, 07:30, edited 1 time in total.
-
- Posts: 19
- Joined: 25 May 2020, 23:04
Re: How to write the script with a variable class?
You've already added "SetTitleMatchMode, RegEx", which should accomplish your goal (assuming the window class name always starts with JUCE_176f9xxxxx as you mentioned above). But it looks like you forgot to change the text in "#IfWinActive", since it still says "JUCE_176f9c1b56c" instead of "JUCE_176f9".https://www.autohotkey.com/docs/commands/SetTitleMatchMode.htm wrote:"RegEx also applies to ahk_class and ahk_exe; for example, ahk_class IEFrame searches for any window whose class name contains IEFrame anywhere."
If you wanted, you might also be able to just do "#IfWinActive, ahk_exe FL64.exe" instead of using ahk_class, assuming all your plugins are running from FLStudio's exe.
Re: How to write the script with a variable class?
Thanks for your reply. It is solved. I didn't know that I have to keep only what's not changing. I don't use the ahk_exe because I still need the space bar in FL studio when typing text. I try instead using that in the line "winactivate, FL Studio 20" but for a reason I don't know, it didn't work