Jump to content

Close the current or active window via XButton2


kgibbs
 Share

Recommended Posts

Hi,

I’m currently using Autohotkey for simple GUI control via XButton mouse commands.

I’m curious if Autoit can close the current or active window via XButton2 and also close the child window via Shift+XButton2.

Has anyone written this type of a simple script yet?

I’m not really a seasoned scriptwriter but I can get through most of the basics with a little head start here and there.

Any help appreciated!

Kurt

Link to comment
Share on other sites

I appreciate your kind response! However, I didn’t see any references to specific XButtons, only XButton as a single entity:

- Can Autoit directly target (XButton1 - XButton16)?

- If yes, how do I directly target each XButton with a specific action?

For a better understanding of my needs: My profession is video and website production where I make use of a 7 button mouse and would like to make better use of the extra buttons without having to use restrictive drivers that came with it. I was hoping for a working script close enough for a few tweaks here and there.

As a newbie, I can see Autoit is more flexible and efficient compared to Autohotkey and Macro Express, which I am currently familiar with. However, comparatively, there is a bigger learning curve jumping in here, am I correct?

Thanks,

Kurt

Link to comment
Share on other sites

I've never used the UDF personally, but it seems to have done everything people needed it to in the past.

From a quick glance it looks like it uses WM_XBUTTONUP, which would explain the single message. Is there maybe a parameter which tells you whether its X1 or 2?

The following is not the prettiest solution, but is very simple and works ok:

#include <misc.au3>

HotkeySet("{ESC}", "_Exit")

Local $x1Pressed = False
Local $x2Pressed = False

While 1
    If _IsPressed("05") Then
        $x1Pressed = True
    ElseIf $x1Pressed Then
        $x1Pressed = False
        _OnX1Pressed()
    EndIf

    If _IsPressed("06") Then
        $x2Pressed = True
    ElseIf $x2Pressed Then
        $x2Pressed = False
        _OnX2Pressed()
    EndIf

    Sleep(10)
WEnd

Func _Exit()
    Exit
EndFunc

Func _OnX1Pressed()
    MsgBox(0, "Test", "X1 Pressed")
EndFunc

Func _OnX2Pressed()
    MsgBox(0, "Test", "X2 Pressed")
EndFunc

Edit: In response to your other questions, AutoIt is far more like a normal procedural programming language. Skills you learn in AutoIt are applicable to most other mainstream languages, so a larger learning curve is probably worth it. I can't actually remember the last time I used AutoIt for hotkeys or automation, I use it as a general purpose, easy to use, scripting language. Autohotkey is far more specialized, and macro recorders and languages even more so.

Edited by Mat
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...