Logout macro for Mac

Introduction

Due to my country being at war, I promptly decided to flee it (we call it a vacation) and only had mac at my availability. POE is one of the few sources of entertainment I have right now, but I only enjoy Hardcore. While I found an adaptation of POB (https://www.pathofexile.com/forum/view-thread/3009944) for Mac, I didn't find a logout macro, so I decided to create my own. This is a minimal implementation and you might have to tweak a few numbers, but it works!


Installation

1. Install and launch Hammerspoon: https://www.hammerspoon.org/. This is an analogue to AutoHotKey.

2. Click "Open Config" and paste the following code:

Spoiler
-- This is a shitty implementation of double click. It's a utility function, you probably don't need to tweak it. But maybe try increasing the sleep time if the logout macro only opens the menu but does not click the logout button.

function doubleLeftClick(point)
local clickState = hs.eventtap.event.properties.mouseEventClickState
hs.eventtap.event.newMouseEvent(hs.eventtap.event.types["leftMouseDown"], point):setProperty(clickState, 1):post()
hs.eventtap.event.newMouseEvent(hs.eventtap.event.types["leftMouseUp"], point):setProperty(clickState, 1):post()
hs.timer.usleep(150000)
hs.eventtap.event.newMouseEvent(hs.eventtap.event.types["leftMouseDown"], point):setProperty(clickState, 2):post()
hs.eventtap.event.newMouseEvent(hs.eventtap.event.types["leftMouseUp"], point):setProperty(clickState, 2):post()
end




-- The main logic is here. Here you can choose a different key (replace § with something else in the next line) and fine-tune the location of the click (I hardcoded the location for my screen and it might not work for different resolutions).

hs.hotkey.bind({ }, "§", function()
hs.eventtap.keyStroke({}, "escape", 1000)
local point = {x= 900, y= 450}
doubleLeftClick(point)
end)


3. Click "Reload Config".

4. Try it! By default, the logout is bound to the § key (that is just below Escape on my keyboard). For binding a different key or troubleshooting, refer to the next section or the comments in the code. Or ask me in the comments!


How it works

As I said, this is a minimal implementation. The code binds to a single key a simple sequence of clicking Escape and double-clicking (to be sure) the Logout button. Possible changes and fixes:

- To rebind a different key, just replace the symbol § in the code with the symbol of your choice. The line is the 5th line in the code counting from the end.

- To fix the clicking location (since I hardcoded it to my resolution), try different x and y numbers until you hit the correct numbers. This is in the 3d line in the code counting from the end.

- Note that the macro rebinds the key regardless of POE being launched.

- Note that every time you change the code, you need to reload the config (by pressing the corresponding button in the Hammerspoon UI).

- Note that the logout macro won't work in-game if you have any menu open. This can be easily fixed by first pressing an additional key that closes all menus but I don't have problems with that (I don't have menus open during battles).

- A technical detail is about the sleeping time between the button presses. Obviously, the lower the sleeping time, the faster you should log out. However, there are limits to how low this time can be. As far as I can tell, it first takes a few moments for the menu to open, then takes a few moments to register that the mouse is located above the logout button (which is when the macro clicks the first time), and finally, you can logout (but clicking the second time). So you can try to make the macro faster by reducing the sleeping time, but be aware of the risks of making it less consistent. Vice versa, if the macro only opens the main menu but does not click the logout button, try increasing the sleeping time after pressing Escape and between the clicks.

Last bumped on Jan 24, 2023, 11:09:25 AM
Thank you!

About: try different x and y numbers until you hit the correct numbers.

use the built-in screen capture function. Press Command-Shift-4 to take a picture of part of the screen. The cursor switches to a crosshairs cursor that includes the x/y screen coordinates.

Report Forum Post

Report Account:

Report Type

Additional Info