Now I've read a lot of people on this forum in the past have wanted to make the switch to Linux but have been dissuaded from doing so out of fear of not being able to port scripts. I completely understand this. I am a long time Windows user and hardcore AHK user. I also understand that most long time Linux users just don't get it. Many of them are fan-boys/fan-girls who think that Linux is superior at just about everything. And for the most part, I agree. However, these Linux fans have likely have limited experience with Windows, let alone AHK with Windows. They often suggest different packages (programs) for various tasks, and many of these tools are great, but what they don't get is what makes AHK special. It's simple, self contained and does everything like the one ring.
The good news is, I have found it's quite possible to port AHK to Linux and do a lot with it using Wine Tools. There are limitations so I want share in detail how I have worked around them instead of parroting the Linux crowd. Maybe some of you who are on the fence, not wanting to give up AHK like I was for so long. I also want to make it clear that anything you can't do with AHK on Linux can be done in other ways quickly and easily.
Probably the biggest limitation I have experienced so far in using AHK with Linux is hotkeys themselves. Hotkeys are my life and the thought of not being able to use them exactly the way I want to, (that and my ignorance), held me back from switching to Linux a long time ago. The good news is, just about any Linux desktop environment is already equipped with an extremely intuitive keyboard manager by default. On most Linux desktops it's called the, "Keyboard Manager", and/or Windows Manager". Any common task that you could run with AHK using hotkeys can easily be done with the OS, and you won't even have to go near the console. You can run files, launch programs, open, close, arrange windows, etc... You just have to tell it what you want from the Keyboard and/or Window Manager. In some cases, you might have to use specific commands such as XDG-Open, or EXO-Open. You'll see a lot of these commands in the default hotkeys, but if you need to find out more, just look it up on Duckduckgo.com.
In my limited time using AHK with Linux, I haven't found hotstrings to work, but there are very simple work around's for this. I am almost certain you can program the Linux Keyboard manager with hotstrings but if not, I think they can be done using bash scripts, (Shell type scripts) to do things like that.
If you don't want to go that route, there are also some very simple programs I've played with made just for hotstrings. One program is called Autokey. This is a very basic Python editor which comes with simple hotstring, and hotkey scripts to get you on your way. If you know Python 2.7, you can take it a lot further but it's not really necessary if you're just wanting to fill out forms.
If you want something easier, there is, Xdotools. You can use it directly from the console, but it also acts as a sort of plugin to other programs, one being the Keyboard Manager. I have already used it to simulate key presses. I read somewhere that you can adapt it for AHK, but I haven't tried it yet. There is even a program written called AutoHotKeyX which I haven't tried yet.
There are several other programs in addition to these that I haven't even tried.
I have managed to port all my GUI scripts, even complicated ones to AHK and they seem to work flawlessly. The few problems I have had with scripts that had GUI's were not a result of the GUI itself but certain functions that are only specific to Windows.
A bit about Wine first...
In simple terms Linux seems to work differently then Windows. In order to make Windows programs like AHK play nice in Linux, Wine creates a pseudo Windows sandbox for your programs to stay. This is just like an emulator except it's not. In other words it tricks Windows programs into thinking they are running on Windows.
One major aspect of making Windows programs work is resolving connecting drives. Windows uses drive letters to designate file paths, such as C:\, or C:\Programs\. Linux doesn't assign drive letters. In Linux your drive might look something like this /Home/Username/. When you install Wine, it will auto detect your Linux drives and assign them their own Windows drive letters. So your Linux home folder such as /Home/Username/ might be assigned to I:\ in the Wine environment. You don't have to use the auto settings in Wine. You can also tell it which drive letters to use. At home I use drive I have assigned a USB drive as A:\ in Wine
The good news about this is you can assign file paths with ease in AHK. Lets say for example I want to copy a file on my USB drive to my hard drive. With AHK on Linux I can still use Windows paths,
Code: Select all
Filecopy, A:\My File Name, C:\New File Name
But I can also use Linux Paths,
Even better AHK is still able to use it's built in variables,A_ScriptDir, A_WorkingDir etc.
Code: Select all
Filecopy, /...Media/My File Name, /Home.../New File Name
Since file/folder reading doesn't seem to be a problem, I can just as easily work with loops.
From my limited understanding, AHK works with Windows within Wine only. It has nothing to do with much outside that environment. It won't have any affect on Linux windows that I'm aware of. Using AHK, you can open and interact with a Wine GUI File manager, but this is very limited and doesn't offer much versatility.
I haven't tried image searching but, I am wanting to say no, as I think these are specific to Windows OS. However there are other programs which can handle image searches.
I don't think this is possible directly with AHK but I have considered using bash scripts or other programs, and launching them with AHK.
Some programs work and others don't from what I can tell. I have been able to run website links and have it start in my native Browser. I can open files like spreadsheets, docs, and text using Libre Office which is default in most Linux distros. As long as it's a file it should open. I haven't played around much when it comes to launching programs specific to Linux. I think it depends on the context.
Variables, Functions, Objects
I have no problem storing and using variables. I haven't played around with the clipboard, just yet. Objects work as long as their not OS related. I can write and use functions just fine as long as they don't affect the OS itself.
I haven't had much need for this personally but from what I have read it isn't possible. Again you can't really interact directly with the OS which handles a lot of this s
I am pretty sure Com is specific to Windows only. However I think you can install Selenium in Linux for Dom (Document Object Model) management, that can be used with Java Script. I think you can then use AHK with programs like Libre Office (Spreadsheet program), and most web browsers.
I don't know how processes work in Linux, but I haven't played around with them yet.
I have tried but failed to install Scite4Autohotkey, and AHK studio with Wine. I am sure it's a simple fix but I haven't figured it out. You can also install the Linux version of Notepad++ but I haven't figured out how to install the AHK language files into it. For now I am just using a basic text editor without autocomplete and syntax highlighting.
I have managed to do a lot in AHK or am comfortable enough to figure out other ways to do what I need. Who knows, maybe I can do more a lot more in AHK than I am aware of.
I know for some of you, the idea of setting all this up and to find all those work arounds while working inside a new OS seems quite daunting, but let me assure you, it's really not that difficult. You just have to take one step at a time and adjust a few things and you'll be up and running before you know it. This is coming from a not so technical person.
And all those people who say you need learn Python, or get good at the console to automate, no, you don't. I would add this however, bash scripts allow you to do some pretty amazing things. I wrote a five line script to clean and organize my hard drive and files, which I can launch from AHK. In my very short time with Linux as in less than a week, I am beginning to see why people say you don't really need AHK. In getting a feel for the OS, I find it's very intuitive. It's practically made for automation. So combine that with the fact that you can use a lot of AHK functionality, your not losing a tool but gaining a great tool..
I would say to anyone here, play around in a virtual box and see what you can and can't do with AHK. But also play around with other tools. Once you start getting the hang of it, it will be a lot easier to leave Windows. And if you still need AHK to work 100%, you can always install a virtual box in Linux and run AHK on Windows.
Now I am well aware of the dead IronAHK project, but I suspect it was dropped due to the advantages of using AHK for Windows on Wine. I would also add the fact that so many people were saying AHK isn't necessary or that Python is just as good. But here is the thing, if enough people who use AHK switch to Linux and want AHK, I don't see why it can't be done by the community. Autohotkey is an open source dream and doesn't have to live only on Windows.