Script works only if msgbox prints the variable

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Groosha
Posts: 1
Joined: 20 Jun 2017, 09:24

Script works only if msgbox prints the variable

20 Jun 2017, 09:37

I have a VERY strange problem with my script. But first let me describe the problem:
I have a "smartbook" which is basically a tablet in a form of laptop. It has a keyboard and touchpad. However, that touchpad has some "special" abilities like: swipe from left side to activate "Start" button and swipe from right side to activate notification panel in Windows 10. It's called Edge UI, but it has no settings in Windows since it thinks that there's no touchpad and touchpad behaves like a keyboard+mouse. (Yeah, such a chinese device).

So, I decided to use the power of AHK to filter "Left Windows" button on a specific keyboard (which is a touchpad) and then somehow disable button if "pressed" on touchpad.
I have successfully filtered button press using AHKHID (https://github.com/jleb/AHKHID), however, I don't know how to temporarly disable a certain button in case of (condition).
So I'm using a global variable "allowWin" and set it to 1 or 0 after Win button is pressed on any of 2 keyboards.

LWin::
msgbox, %allowWin%
if (allowWin = 1) {
SendInput, {LWin}
} else if (allowWin = 0) {
Return
}

If I have msgbox present in this piece of code, it produces nasty message boxes (obviously) however it blocks "Start" menu to appear (so it basically blocks Win button).
But if I remove that "msgbox, %allowWin%" string the code "breaks" and stops blocking Start menu.

The full script code is here: https://gist.github.com/MasterGroosha/a ... 15b64081bd
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Script works only if msgbox prints the variable

25 Jun 2017, 21:12

It is not the fault of your device, chinese or not. It is your script, producing errors, by triggering the hotkey itself.
Try this:

Code: Select all

$LWin::
if (allowWin = 1) {
SendInput, {LWin}
} else if (allowWin = 0) {
Return
}
The $-prefix will prevent this behaviour. With the $-prefix, only physically pressed keys are accepted.
Look here at the reference Hotkey for further information.
Einfach nur ein toller Typ. :mrgreen:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: RussF and 369 guests