Position GUI next to cursor

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
leuce
Posts: 4
Joined: 25 May 2018, 16:18

Position GUI next to cursor

25 May 2018, 16:31

Hello everyone

I'm new to AHK (again), having watched 2 videos and then googling.

I'm trying to create a script that will pop up a little menu at the mouse position, for use in a program that doesn't allow one to add options to its right-click menu. The first time the GUI shows, the GUI is at the current mouse position, but all subsequent times the GUI alternates between two places, namely a seemingly random location and the top left corner of the active window. When I move my mouse to another location, and press the hotkey, I want the GUI to show at that new location (i.e. where the mouse cursor is). The GUI pops up at the new cursor position only if the Desktop is the active "window", but not if some other window is active window. What am I doing wrong?

Thanks
Samuel

Code: Select all

#SingleInstance, Force

!RButton::

MouseGetPos, xpos, ypos

Gui, Add, Button, gScript1, Script 1
Gui, Add, Button, gScript2, Script 2
Gui, Add, Button, gScript3, Script 3
Gui, Show, x%xpos% y%ypos%
return

Script1:
Gui, Hide
Run Notepad.exe
return

Script2:
Gui, Hide
Run Notepad.exe
return

Script3:
Gui, Hide
Run Notepad.exe
return

return
leuce
Posts: 4
Joined: 25 May 2018, 16:18

Re: Position GUI next to cursor

26 May 2018, 05:35

I've since discovered that the GUi does pop up at the correct position in most programs, but if the most recent active program is/was a plain text editor (e.g. Metapad, Akelpad).
gregster
Posts: 8990
Joined: 30 Sep 2013, 06:48

Re: Position GUI next to cursor

26 May 2018, 08:25

I guess it could help to look at Coordmode.
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Position GUI next to cursor

26 May 2018, 09:43

to expand on gregsters comment

try adding

CoordMode, mouse, screen

right after your hotkey

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], LepG, mapcarter, mikeyww, OrangeCat and 268 guests