Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Remove tooltip on keystate


  • Please log in to reply
3 replies to this topic
Xx7
  • Members
  • 672 posts
  • Last active: Aug 31 2014 07:55 PM
  • Joined: 19 Apr 2011
This copies a file to the Clipboard and while it is on the Clipboard it shows a tool tip saying "Saved to Clipboard"

However, when I paste the file, I would like the tooltip to disappear. I cannot get this to work using GetKeyState for Control and v??? See Orange
:*:uuii::
path_2 := "C:\Users\BD\Desktop\tester.xlsx"

if InvokeVerb(path_2, "Copy")
{ 
   ToolTip, Saved to Clipboard
    Process,Exist
    hwnd:=WinExist("ahk_class tooltips_class32 ahk_pid " Errorlevel)
    Loop
       ToolTip_UpdatePos(hwnd)
}


;---------- Notifies when pasted ---------------
Loop, 
{
GetKeyState, state1, Control
GetKeyState, state2, v
if(state1 = "D" and state2 = "D")
{
          [color=#FF4000];**********I would like to remove the tool tip here *************
          ;*********** I can't get the keystate when the tooltip is showing???? *****[/color]
        MsgBox You pasted it
	break
}
}
return

;----------- Tooltip function -------------

ToolTip_UpdatePos(hwnd,x="",y=""){
   static TTM_TRACKPOSITION := 0x412
   VarSetCapacity(xc, 20, 0), xc := Chr(20),DllCall("GetCursorInfo", "Uint", &xc)
   ,yc := NumGet(xc,16), xc := NumGet(xc,12),xc+=10,yc+=10
   If x
      xc:=x
   If y
      yc:=y
   DllCall("SendMessage", A_PtrSize ? "UPTR" : "UInt", hwnd
                                    , "Uint", TTM_TRACKPOSITION
                                    , A_PtrSize ? "UPTR" : "UInt", 0
                                    , A_PtrSize ? "UPTR" : "UInt", (xc & 0xFFFF)|(yc & 0xFFFF)<<16)
}


;----------- Copy file function ------------

InvokeVerb(path, menu, validate=True) {
   ;by A_Samurai
   ;v 1.0.1 http://sites.google.com/site/ahkref/custom-functions/invokeverb
    objShell := ComObjCreate("Shell.Application")
    if InStr(FileExist(path), "D") || InStr(path, "::{") {
        objFolder := objShell.NameSpace(path)   
        objFolderItem := objFolder.Self
    } else {
        SplitPath, path, name, dir
        objFolder := objShell.NameSpace(dir)
        objFolderItem := objFolder.ParseName(name)
    }
    if validate {
        colVerbs := objFolderItem.Verbs   
        loop % colVerbs.Count {
            verb := colVerbs.Item(A_Index - 1)
            retMenu := verb.name
            StringReplace, retMenu, retMenu, &       
            if (retMenu = menu) {
                verb.DoIt
                Return True
            }
        }
        Return False
    } else
        objFolderItem.InvokeVerbEx(Menu)
}


0x150--ISO
  • Members
  • 657 posts
  • Last active: Apr 07 2012 09:06 PM
  • Joined: 01 Jan 2011
Switch
Loop,

{

GetKeyState, state1, Control

GetKeyState, state2, v

if(state1 = "D" and state2 = "D")

{

          ;**********I would like to remove the tool tip here *************

          ;*********** I can't get the keystate when the tooltip is showing???? *****

        MsgBox You pasted it

   break

}

}
To
While !st

  If (st:=GetKeyState( "Ctrl", "P" ) && GetKeyState( "v", "P" )) {

    Tooltip [color=#008000]; blank Tooltip command clears it.[/color]

    MsgBox You pasted it

  }


Lexikos
  • Administrators
  • 9449 posts
  • Last active:
  • Joined: 17 Oct 2006
There's a chance that the loop will miss the keystroke. I would recommend the following approach:
Clipboard := "sample data"

Hotkey ~^v, CtrlV, On
ToolTip Waiting for Ctrl+V...
return

CtrlV:
ToolTip
Hotkey ~^v, CtrlV, Off
ExitApp  ; You'll probably want to remove this line.
return


Xx7
  • Members
  • 672 posts
  • Last active: Aug 31 2014 07:55 PM
  • Joined: 19 Apr 2011
Great, thanks... here it is. Changes in RED
path_2 := "C:\Users\BD\Desktop\test columns.xlsx"

:*:uuii::
[color=#FF0000]Hotkey, ~^v, MyLabel, On  [/color]
if InvokeVerb(path_2, "Copy")
{ 
   ToolTip, Saved to Clipboard
    Process,Exist
    hwnd:=WinExist("ahk_class tooltips_class32 ahk_pid " Errorlevel)
    Loop
       ToolTip_UpdatePos(hwnd)
}
return


[color=#FF0000]MyLabel:
ToolTip
Hotkey ~^v, MyLabel, Off ;Off disables the Hotkey
return[/color]


;----------- Tooltip function -------------

ToolTip_UpdatePos(hwnd,x="",y=""){
   static TTM_TRACKPOSITION := 0x412
   VarSetCapacity(xc, 20, 0), xc := Chr(20),DllCall("GetCursorInfo", "Uint", &xc)
   ,yc := NumGet(xc,16), xc := NumGet(xc,12),xc+=10,yc+=10
   If x
      xc:=x
   If y
      yc:=y
   DllCall("SendMessage", A_PtrSize ? "UPTR" : "UInt", hwnd
                                    , "Uint", TTM_TRACKPOSITION
                                    , A_PtrSize ? "UPTR" : "UInt", 0
                                    , A_PtrSize ? "UPTR" : "UInt", (xc & 0xFFFF)|(yc & 0xFFFF)<<16)
}

;----------- Copy file function ------------

InvokeVerb(path, menu, validate=True) {
   ;by A_Samurai
   ;v 1.0.1 http://sites.google.com/site/ahkref/custom-functions/invokeverb
    objShell := ComObjCreate("Shell.Application")
    if InStr(FileExist(path), "D") || InStr(path, "::{") {
        objFolder := objShell.NameSpace(path)   
        objFolderItem := objFolder.Self
    } else {
        SplitPath, path, name, dir
        objFolder := objShell.NameSpace(dir)
        objFolderItem := objFolder.ParseName(name)
    }
    if validate {
        colVerbs := objFolderItem.Verbs   
        loop % colVerbs.Count {
            verb := colVerbs.Item(A_Index - 1)
            retMenu := verb.name
            StringReplace, retMenu, retMenu, &       
            if (retMenu = menu) {
                verb.DoIt
                Return True
            }
        }
        Return False
    } else
        objFolderItem.InvokeVerbEx(Menu)
}