Page 1 of 1

Help with FUNCTION

Posted: 07 Mar 2018, 06:45
by Tomer
im trying to display the the total lines of some file in a tooltip

just a text works fine but a variable doesnt :(

Code: Select all

#NoEnv
#SingleInstance Force

loop, read, c:\file.txt
total = %a_index%

Gui Add, Button, x95 y13 w90 h23, &this not works
Gui Add, Button, x1 y13 w90 h23, &this works

Gui Show, w186 h46, test123

IfWinActive, test123
{
hCurs:=DllCall("LoadCursor","UInt",NULL,"Int",32649,"UInt") ;IDC_HAND
OnMessage(0x200,"WM_MOUSEMOVE")
Return
}

WM_MOUSEMOVE(wParam, lParam, Msg)
{
Global hCurs
MouseGetPos,,,,ctrl
If ctrl in Button1
ToolTip % total
If ctrl in Button2
WM_MOUSEMOVE := "test text"
ToolTip % WM_MOUSEMOVE
If ctrl in Button1,Button2
DllCall("SetCursor","UInt",hCurs)
Return
}

Return

GuiEscape:
GuiClose:
    ExitApp

Re: Help with FUNCTION

Posted: 07 Mar 2018, 07:54
by wolf_II
Try this with braces, also total should be accessible:

Code: Select all

Global ;hCurs
; ...
If ctrl in Button2
{
    WM_MOUSEMOVE := "test text"
    ToolTip % WM_MOUSEMOVE
}
I hope that helps.

Re: Help with FUNCTION

Posted: 07 Mar 2018, 13:55
by Tomer
did you test it?
not working for me :(
still button1 not showing the tooltip while mouse over on it...

Re: Help with FUNCTION  Topic is solved

Posted: 07 Mar 2018, 14:08
by wolf_II
yes, it works for me, when the file exists.
Try this:

Code: Select all

#NoEnv
#SingleInstance Force

loop, read, % A_ScriptFullPath
total = %a_index%

Gui Add, Button, x95 y13 w90 h23, &this not works
Gui Add, Button, x1 y13 w90 h23, &this works

Gui Show, w186 h46, test123

IfWinActive, test123
{
hCurs:=DllCall("LoadCursor","UInt",NULL,"Int",32649,"UInt") ;IDC_HAND
OnMessage(0x200,"WM_MOUSEMOVE")
Return
}

WM_MOUSEMOVE(wParam, lParam, Msg)
{
Global ;hCurs
MouseGetPos,,,,ctrl
If ctrl in Button1
ToolTip % total
If ctrl in Button2
{
    WM_MOUSEMOVE := "test text"
    ToolTip % WM_MOUSEMOVE
}
If ctrl in Button1,Button2
DllCall("SetCursor","UInt",hCurs)
Return
}

Return

GuiEscape:
GuiClose:
    ExitApp
I hope that helps.

Re: Help with FUNCTION

Posted: 08 Mar 2018, 13:37
by Tomer
thanks wolf!

Re: Help with FUNCTION

Posted: 11 Mar 2018, 01:59
by Tomer
just noticed a problem now,
in this method the tooltip not disappear when you move off the mouse cursor from the buttons :(

EDIT:
ok manged to solve it with https://github.com/hi5/TF: :D

Code: Select all

#Include, tf.ahk
 Global hCurs
  WM_MOUSEMOVE := TF_CountLines(A_ScriptFullPath)
    ToolTip % WM_MOUSEMOVE