Page 1 of 2

Autohotkey and Moho

Posted: Mon Feb 11, 2019 2:50 pm
by Greenlaw
This weekend, I started having problems between Autohotkey and Moho. Both AHK and Moho are working fine individually but right now Moho is mostly ignoring AHK. It's not completely ignoring it because I see Moho flashing (beeping?) every time I try to use AHK to operate the Moho UI. It looks to me like AHK is still sending commands to Moho but Moho is rejecting them for some reason. Previously, AHK and Moho worked fine with each other.

I'm not seeing the same problem on another computer so I suspect something had changed on this computer to cause this issue but I can't figure out what that could be. Has anybody seen this problem on their computer and know what's going on?

This is frustrating because I was preparing to release a tool I've been using all last year and then this happens. :(

If anybody has a helpful suggestion, please reply. Thanks!

Re: Autohotkey and Moho

Posted: Mon Feb 11, 2019 3:18 pm
by Greenlaw
Ok, it seems to be a permissions thing. When I set my AHK script to 'run as administrator', it's allowed to control Moho.

This is weird because I don't believe I had to do this before to use AHK with Moho. Does anybody know if something recently changed in Windows to cause this restriction? I know I can permanently change the permissions settings but I'd rather not do that if I don't have to.

Re: Autohotkey and Moho

Posted: Mon Feb 11, 2019 3:34 pm
by Greenlaw
After a little research, I learned that UAC and other security changes can cause this. I should have mentioned that this is a new computer I'm using, so it's likely I adjusted an 'annoying' security option recently and hadn't immediately noticed the effect on AHK.

Apparently, I can get the script to 'Run As Admin' all by itself. Not exactly sure how but I'm going to look into it now.

Re: Autohotkey and Moho

Posted: Mon Feb 11, 2019 4:00 pm
by Greenlaw
I'm guessing a recent Windows update made it more picky about running AHK scripts as .exe.

This bit of code seems to allows the script to work:

Code: Select all

if not A_IsAdmin
Run *RunAs "%A_ScriptFullPath%"
But unless I set UAC to its lowest setting, Windows keeps asking for permission to run every time I launch the script, which is pretty annoying.

Does anybody have a better 'in-script' solution?

Re: Autohotkey and Moho

Posted: Mon Feb 11, 2019 4:28 pm
by Greenlaw
Sigh! Now I'm getting the Windows permission requester even when I run the ahk script (instead of the .exe). For now, I'm going to run the .exe with UAC set to its lowest setting on this computer. I don't think I had to do that on my older computer but will check on this when I can.

One of the reasons I started this project was to teach myself AutoHotkey, so when I post the tool later this week, I'll include the source code and maybe somebody can help me improve it.

I just need to record a video to show how I use the tool with Moho. When it's ready, I'll post the tool in the Scripting discussion.

Re: Autohotkey and Moho

Posted: Mon Feb 11, 2019 4:44 pm
by synthsin75
You might try "RunAs, Administrator", as per: https://autohotkey.com/docs/commands/RunAs.htm

Re: Autohotkey and Moho

Posted: Mon Feb 11, 2019 6:35 pm
by Greenlaw
synthsin75 wrote:You might try "RunAs, Administrator", as per: https://autohotkey.com/docs/commands/RunAs.htm
Thanks! I'll give that a try with my laptop at lunchtime.

A minute ago, I checked how I have it configured on my work computer and I see I'm not using the Run As Administrator option in the AHK file properties, but then we're using Win 7 here so I'm guessing this is a Win 10 thing. That said, I'm almost certain I didn't have to do that on my old Win 10 computer. I still have that computer but will have to wait till this evening to check.

Re: Autohotkey and Moho

Posted: Mon Feb 11, 2019 6:44 pm
by Greenlaw
Just curious but have you run into this issue on any computers? I'm trying to understand why I'm seeing this only on my new computer and wish to include any helpful troubleshooting info in the docs.

Re: Autohotkey and Moho

Posted: Mon Feb 11, 2019 8:17 pm
by synthsin75
Greenlaw wrote:Just curious but have you run into this issue on any computers? I'm trying to understand why I'm seeing this only on my new computer and wish to include any helpful troubleshooting info in the docs.
Gosh, if I have, it's been so long that I'm not likely to remember where or how I solved it. And I'm not running Win10 on anything.

Re: Autohotkey and Moho

Posted: Mon Feb 11, 2019 8:30 pm
by Greenlaw
Ok, thanks. If I figure this out, I'll be sure to post the info here or in the upcoming thread.

Re: Autohotkey and Moho

Posted: Mon Feb 11, 2019 10:45 pm
by Greenlaw
I tried the other Run As command but getting the same result: Windows is asking for permission before allowing the script to run. It only allows it to proceed automatically if I set UAC to never notify.

I suspect my old computer probably had UAC set to never notify. If that's the case, I guess it's just the way it has to be. Will check on this tonight.

Re: Autohotkey and Moho

Posted: Mon Feb 11, 2019 11:06 pm
by synthsin75
There's an off chance that calling the AHK from an already privilege-elevated program might work. If that's the case, you can alter the advanced properties of the Moho shortcut you use to make Moho always launch as admin. If that fails, you might try making a shortcut with admin privileges for the AHK exe and calling that from Moho.

Or maybe Moho is already running elevated, by default, and UAC is just trying to keep AHK from messing with it. If so, elevating the AHK script might work.

Some ideas to try anyway.

Re: Autohotkey and Moho

Posted: Mon Feb 11, 2019 11:24 pm
by Greenlaw
Thanks! Yes, it's possible I elevated Moho on the old computer when I first started working with AHK. Will check if I did that.

Even if not, will try it on the new computer and see what happens.

Re: Autohotkey and Moho

Posted: Wed Feb 13, 2019 4:19 pm
by Greenlaw
Ugh...busy week but finally got back to this.

I tried elevating Moho to run as admin but all that did was bring up the annoying permissions window, and the AHK script still couldn't control Moho unless it too had elevated privileges.

So for now, I dropped Moho back down to user, elevated the tool to run as admin, and am leaving UAC at its lowest setting. I still need to check if this is how it's set up on my old computer but I suspect it is. TBD.

At work, we're using Windows 7 and it all seems to work fine with regular user privileges. Sigh...Windows 10...

Re: Autohotkey and Moho

Posted: Wed Feb 13, 2019 4:23 pm
by synthsin75
Greenlaw wrote:Sigh...Windows 10...
Yeah, that's why I'm not looking to upgrade from 8.1 any time soon.