tooltip/closing window script Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
[m]
Posts: 21
Joined: 05 May 2020, 14:12

tooltip/closing window script

12 May 2021, 09:41

I have multiple questions.
I'm using 2 scripts:

Code: Select all

#SingleInstance Force
Loop 600
{
ToolTip, % 601 - A_Index ; if you just use A_Index it starts at 1 2 3 etc
Sleep 1000
}
Tooltip, 0
and

Code: Select all

#Persistent

#NoEnv
#SingleInstance Force
SetBatchLines -1
SetWorkingDir %A_ScriptDir%
p0:="red.png",p1:="green.png"
UrlDownloadToFile, https://www.autohotkey.com/boards/download/file.php?id=12973,% p0
UrlDownloadToFile, https://www.autohotkey.com/boards/download/file.php?id=12972,% p1

Run %A_AhkPath% "C:\[path]\[script].ahk"

SetTimer Countdown,600000
Grd:=[1,1,0,0,1                   ;Initial board matrix/layout.
     ,0,1,1,1,0
     ,1,0,0,1,0
     ,1,0,0,0,1
     ,0,1,1,0,0]

Gui Brd:New,+ToolWindow          ;Create/display board Gui.
ct:=1
Loop 5{
  ly:=(A_Index-1)*31
  Loop 5{
    lx:=(A_Index-1)*31
    Gui Add,Picture,x%lx% y%ly% w30 h30 gClk v%ct%,% Grd[ct]?p1:p0
    ct++
  }
}
Gui Show,w154 h154
Return

Countdown:
  ExitApp

Clk:                               ;Get what was clicked:
  pr:=A_GuiControl
  If (pr=1)                        ;Top Lft
    cc:="00111"
  Else If (pr=5)                   ;Top Rgt
    cc:="01101"
  Else If (pr=21)                  ;Bot Lft
    cc:="10110"
  Else If (pr=25)                  ;Bot Rgt
    cc:="11100"
  Else If (pr>1 && pr<5)           ;Top Mid
    cc:="01111"
  Else If (pr>21 && pr<25)         ;Bot Mid
    cc:="11110"
  Else If (Mod(pr-1,5)=0)          ;Lft Mid
    cc:="10111"
  Else If (Mod(pr,5)=0)            ;Rgt Mid
    cc:="11101"
  Else                             ;Mid Mid
    cc:="11111"

; cc = "Top/Left/Middle/Right/Bottom"

  Loop Parse,cc
  {
    If (A_Index=1 && A_LoopField=1){
      Grd[pr-5]:=!Grd[pr-5]
      GuiControl ,,% pr-5,% Grd[pr-5]?p1:p0
    }
    If (A_Index=2 && A_LoopField=1){
      Grd[pr-1]:=!Grd[pr-1]
      GuiControl ,,% pr-1,% Grd[pr-1]?p1:p0
    }
    If (A_Index=3 && A_LoopField=1){
      Grd[pr]:=!Grd[pr]
      GuiControl ,,% pr,% Grd[pr]?p1:p0
    }
    If (A_Index=4 && A_LoopField=1){
      Grd[pr+1]:=!Grd[pr+1]
      GuiControl ,,% pr+1,% Grd[pr+1]?p1:p0
    }
    If (A_Index=5 && A_LoopField=1){
      Grd[pr+5]:=!Grd[pr+5]
      GuiControl ,,% pr+5,% Grd[pr+5]?p1:p0
    }
  }
Return

BrdGuiClose:
  ExitApp

!5::Reload

1) I want to close (ExitApp) the GUI (so the grid window) along with the tooltip script whenever i hit the red X on the GUI.
Well preferably these 2 scripts can be made into 1 instead i think but I don't know how.

2) The other thing is, I noticed that the tooltip on the mouse covers the GUI meaning it prevents the click on the grid window. So I came up with an idea that attaches the tooltip next to the red X of the grid window (shown in file attachment)
Unbenannt.PNG
Unbenannt.PNG (17.68 KiB) Viewed 324 times
If the tooltip was attached to the window instead of the mouse and is movable around so the tooltip stays on that spot next to the X , that would be nice.

And I'll be forever thankful of anyone providing a solution!
User avatar
mikeyww
Posts: 26857
Joined: 09 Sep 2014, 18:38

Re: tooltip/closing window script

12 May 2021, 09:48

Since a tooltip can be directly positioned, and you know the GUI's width, you can include the ToolTip parameters for positioning.
User avatar
[m]
Posts: 21
Joined: 05 May 2020, 14:12

Re: tooltip/closing window script

12 May 2021, 10:07

Yeah the problem at the tooltip is that whenever i put down coordinates, it destroys the countdown for it and it just displays the x y z instead unless i'm doing it wrong.
User avatar
mikeyww
Posts: 26857
Joined: 09 Sep 2014, 18:38

Re: tooltip/closing window script  Topic is solved

12 May 2021, 11:26

This is a demonstration for your main script.

Code: Select all

CoordMode, ToolTip
Gui, Add, Text,, Test
Gui Show, w154 h154
WM_MOVE(), OnMessage(0x0003, "WM_MOVE"), count := 7
Loop, %count%
{
 ToolTip, % count - A_Index + 1, x + width + 10, y
 Sleep, 1000
}
Tooltip, 0

WM_MOVE(wParam := 0, lParam := 0) {
 Global
 WinGetPos, x, y, width,, ahk_class AutoHotkeyGUI
}
User avatar
[m]
Posts: 21
Joined: 05 May 2020, 14:12

Re: tooltip/closing window script

12 May 2021, 12:30

Thanks for the help!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], mikeyww, OrangeCat, ShatterCoder and 80 guests