4strid / mouse-control.autohotkey

AutoHotKey script for controlling the mouse with the keyboard. Fast & easy-to-use, full-fledged software replacement for a physical mouse. WASD / vim movement and vim-inspired key bindings. Better alternative to Numpad Mouse.
MIT License
83 stars 16 forks source link

different message box style #12

Closed Automaetic-official closed 7 months ago

Automaetic-official commented 7 months ago

Hi Astrid!

I want to change the position of the message box (down left with a bit of margin), and change up the style so it matches my Windows 11 "Sound-Change-Notification": image Also, I'm curious, how does your project work? I can't seem to identify what programming language you used, but my wild guess is that it's C?? Does the .exe file read the .ahk file as a configuration file?

Kind regards, Automaetic

4strid commented 7 months ago

it's written with a tool called Autohotkey . the source file is mouse-control.ahk which you can run by installing the Autohotkey program .

the part of the code we'd be interested in changing is the ShowModePopup function around line ~160

ShowModePopup(msg) {
  ; clean up any lingering popups
  ClosePopup()
  center := MonitorLeftEdge() + (A_ScreenWidth // 2)
  popx := center - 150
  popy := (A_ScreenHeight // 2) - 28
  Progress, b x%popx% y%popy% zh0 w300 h56 fm24,, %msg%,,SimSun
  SetTimer, ClosePopup, -1600
  POP_UP := true
}

i happen to use the center of the screen but you could calculate your own coordinates however you like

hope this helps

Automaetic-official commented 7 months ago

That's extremely helpful, thanks a lot :) Have a great day!

Automaetic-official commented 7 months ago

To save y'all some time, here's how I did it:

ShowModePopup(msg) {
  ; clean up any lingering popups
  ClosePopup()

  ; get current window information to re-focus it after popup was shown
  WinGetActiveTitle, ActiveWindowTitle

  ; style and show popup
  popup_height := 48
  popup_width := 192
  popup_leftMargin := A_ScreenWidth - 242
  popup_bottomMargin := A_ScreenHeight - 122
  spaces := "      "
  Gui +AlwaysOnTop -Resize -SysMenu -Caption +ToolWindow +OwnDialogs
  Gui, Margin, 0-62+62
  Gui, Color, 2c2d36                            ; background color
  Gui, Font, s14 cCBCBCB                        ; font size and color
  Gui, Add, Text, Center y+12, %spaces%%msg%    ; centered text (don't judge)

  ; show popup (includes popup dimensions and focus-related settings)
  Gui, Show, x%popup_leftMargin% y%popup_bottomMargin% w%popup_width% h%popup_height%

  ; re-focus active window
  WinActivate, %ActiveWindowTitle%

  ; set popup deletion timer
  SetTimer, ClosePopup, -1600
  POP_UP := true
}

ClosePopup() {
  Gui, Destroy
  POP_UP := false
}

I had to make some stopgaps/workarounds since I just learned the program, and I didn't want to spend too much time on it yet. So, my implementation doesn't have rounded corners or a border (I certainly tried), BUT it does have transparency :o