Help with FUNCTION Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
User avatar
Tomer
Posts: 261
Joined: 21 Aug 2016, 05:11

Help with FUNCTION

07 Mar 2018, 06:45

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
wolf_II
Posts: 2303
Joined: 08 Feb 2015, 20:55

Re: Help with FUNCTION

07 Mar 2018, 07:54

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.
User avatar
Tomer
Posts: 261
Joined: 21 Aug 2016, 05:11

Re: Help with FUNCTION

07 Mar 2018, 13:55

did you test it?
not working for me :(
still button1 not showing the tooltip while mouse over on it...
wolf_II
Posts: 2303
Joined: 08 Feb 2015, 20:55

Re: Help with FUNCTION  Topic is solved

07 Mar 2018, 14:08

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.
User avatar
Tomer
Posts: 261
Joined: 21 Aug 2016, 05:11

Re: Help with FUNCTION

08 Mar 2018, 13:37

thanks wolf!
User avatar
Tomer
Posts: 261
Joined: 21 Aug 2016, 05:11

Re: Help with FUNCTION

11 Mar 2018, 01:59

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

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], lareous, newbieforever and 27 guests