Help/ is it possible?

Ask gaming related questions (AHK v1.1 and older)
LuckyS1337
Posts: 55
Joined: 20 Mar 2023, 12:59

Help/ is it possible?

Post by LuckyS1337 » 01 Apr 2023, 21:28

hey, is it possible to connect the gui to the game window from the left side of the window right after i open script? I tried many times, but I only managed to put it on the window, I would like to connect from the side and not directly on the game window. Here example down below
example.png
example.png (129.73 KiB) Viewed 414 times

[Mod action: Moved topic to the “Gaming” section. Please post in the correct section.]

User avatar
mikeyww
Posts: 26602
Joined: 09 Sep 2014, 18:38

Re: Help/ is it possible?

Post by mikeyww » 02 Apr 2023, 05:43

Code: Select all

; This script shows a GUI adjacent to a target window.
#Requires AutoHotkey v1.1.33
game     := "ahk_exe notepad.exe"
guiWidth := 120
offsetX  :=  10
offsetH  :=  -8
Gui +AlwaysOnTop +HwndhWnd
Gui Font, s10
Gui Add, Text, w100, Test
If WinExist(game) {
 WinActivate
 WinGetPos x, y,, height
 Gui Show, % "NA x" Max(0, x - guiWidth + offsetX) "y" y
 WinMove % "ahk_id" hWnd,,,, guiWidth, height + offsetH
}
Concepts of this script:
1. The width option of Gui, Show, not used here, indicates the width of the window's client area, which excludes the window's borders.
2. DPI scaling is enabled by default. If DPI scaling is enabled, coordinates and sizes passed to or retrieved from the Gui sub-commands and related variables are automatically scaled based on screen DPI.
3. A feature of Microsoft Windows, some windows have dimensions that appear to be slightly different from dimensions of visible areas.
4. When you create a post, including a script helps the forum readers to understand the issue at hand. Create a thread subject to match! Describe the topic or problem, not your wish to get help with it. See the forum dashboard for examples.

image230402-0659-001_cr2.png
Output
image230402-0659-001_cr2.png (40.64 KiB) Viewed 364 times

LuckyS1337
Posts: 55
Joined: 20 Mar 2023, 12:59

Re: Help/ is it possible?

Post by LuckyS1337 » 02 Apr 2023, 20:05

@mikeyww Hey. It works very well! Thanks! is it also possible to make script gui follow game window? Tried to make it with settimer but i can't even click anywhere because it refreshes position

User avatar
mikeyww
Posts: 26602
Joined: 09 Sep 2014, 18:38

Re: Help/ is it possible?

Post by mikeyww » 02 Apr 2023, 20:40

Code: Select all

; This script shows a GUI adjacent to a target window.
#Requires AutoHotkey v1.1.33
Process Priority,, B
Gui +AlwaysOnTop +HwndhWnd
Gui Font, s10
Gui Add, Text, w100, Test
Global game := "ahk_exe notepad.exe"
     , gui  := "ahk_id" hWnd
If WinExist(game)
 WinActivate
Loop {
 WinWait % game
 SetTimer move, 400
 move()
 SoundBeep 1500
 WinWaitClose
 SetTimer move, Off
 SoundBeep 1000
}

move() {
 Static guiWidth := 120
      , offsetX  :=  10
      , offsetH  :=  -8
      , lastX    :=   0
      , lastY    :=   0
      , lastH    :=   0
      , x        := ""
      , y        := ""
      , height   := ""
 If WinExist(game) {
  lastX := x, lastY := y, lastH := height
  WinGetPos x, y,, height
  If (x != lastX || y != lastY || height != lastH) {
   gx := Max(0, x - guiWidth + offsetX)
   If !WinExist(gui)
    Gui Show, % "NA x" gx "y" y
   WinMove % gui,, gx, y, guiWidth, height + offsetH
   SoundBeep 2000
  }
 }
}

LuckyS1337
Posts: 55
Joined: 20 Mar 2023, 12:59

Re: Help/ is it possible?

Post by LuckyS1337 » 03 Apr 2023, 04:39

@mikeyww Thanks a lot for real!

Post Reply

Return to “Gaming Help (v1)”