Sets of hotkeys. Old clipboards.

Post your working scripts, libraries and tools for AHK v1.1 and older
drozdman
Posts: 78
Joined: 05 Dec 2015, 01:07

Sets of hotkeys. Old clipboards.

23 Jun 2018, 13:02

I have used this for long, but I didn't post it. This may be useful for someone.
Those scripts are something necessary for me. It was one of the first things for me to use AHK for.

Sets of hotkeys

● The script creates a set of hotkeys.
● Each hotkey has a set of texts to send
● can go through the set of texts which are shown in tooltip
● For instance:
hotkey: "LAlt & a"
while pressing the left "Alt" key, press "a" key repeatedly to go through the list shown in a tooltip.
To paste the chosen text release the left "Alt" key



Save the files in Unicode or UTF-8 with signature (not in UTF-8 as it is chosen with the download feature here - it messes up unicode characters).

Code: Select all

#SingleInstance force
Menu, Tray, Icon, Shell32.dll, 177 
;Menu, Tray,Tip , ✔ Script #2 ❷
Menu, Tray,Tip , Script #2
;#NoTrayIcon

/* 
	● Save script in unicode
	● The script creates a set of hotkeys. 
	● Each hotkey has a set of texts to send
	● can go through the set of texts which are shown in tooltip
	● "MyHotkeys" array is a set of hotkeys. like "LAlt & z", "LAlt & a", etc.
	● "hotkeys_texts" arrays contain the texts assigned to each hotkey respectively
	● For instance: 
		hotkey: "LAlt & a" 
		while pressing the left "Alt" key, press "a" key repeatedly to go through the list shown in a tooltip. 
		To paste the chosen text release the left "Alt" key
*/

;***********************   ***************************************
; Send_texts

; q w e r t 
; a s d f
; z x c v

MyHotkeys := ["LAlt & z","LAlt & a","LAlt & s","LAlt & x"]

hotkeys_texts := Object()



hotkeys_texts[1] := [ "•", "●", "✔", " $T","? ∕ ∶∖","àéü","*.*",""] 
hotkeys_texts[2] := ["Rome","Berlin","Cracovia","Madrid","Athens","Paris",""] 
hotkeys_texts[3] :=["Barcelona","Real","Bayern","Wisła",""] 
hotkeys_texts[4] :=["Maradona","Ronaldinho","Messi","Ronaldo",""] 





Loop, % MyHotkeys.Length(){
	HotKey, % MyHotkeys[A_Index] , Send_text
}


 
Send_text:
    Loop, % MyHotkeys.MaxIndex(){
        TempHotkey := MyHotkeys[A_Index]          
        If (TempHotkey = A_ThisHotkey){
			Hot_keys := StrSplit(MyHotkeys[A_Index], "&", A_Space)
			key_1 := Hot_keys[1]
			key_2 := Hot_keys[2]
			texts := hotkeys_texts[A_Index]
			gosub, Send_texts
            Break                                   
        }

    }

return
 
Send_texts: 
	Loop, % texts.MaxIndex(){
		tip_text:= tip_text . " `n  " texts[A_Index] 
		if((A_Index==3 || A_Index==6 || A_Index==9) && texts[1]!="• "){
		tip_text:= tip_text . "`n`   ---------- "
		}
	}
	tip_text := "   ¯¯¯¯" . tip_text
	
	index=1
	Paste:=tip_text
	ToolTip, % Paste
	KeyWait, % key_2
	SetTimer, 2_Key_Down_Timer, 5 
	
	KeyWait, % key_1
	SetTimer, 2_Key_Down_Timer, off
	ToolTip
	if !InStr(Paste, "¯¯¯¯"){	

	clipboard_backup := clipboard
	if(RegExMatch(Paste, "i)\$T")){
		Clipboard:=Paste
	}else{
		Clipboard:=Paste " "
	}
	Send ^v
	clipboard := clipboard_backup

	;SendInput % Paste " " ; too slow  
	;SendInput % WinActive("ahk_class CabinetWClass") ?  RegExReplace(Paste,"i)•","") " " : Paste " " 
	}
	tip_text=
return


2_Key_Down_Timer:
	if (GetKeyState(key_2, "P") = 1){				
		if (index> texts.MaxIndex()){
			index:=1 
		}
		Paste:=texts[index]
		
		Loop, % texts.MaxIndex(){
		  if((A_Index==4 || A_Index==7 || A_Index==10)){
		  tip_text:= tip_text . "`n`   ---------- "
		  }	
		  
		  if(A_Index==index && A_Index!=texts.MaxIndex()){
		  tip_text:= tip_text . " `n  " texts[A_Index] " ✔"
		  }else
		  tip_text:= tip_text . " `n  " texts[A_Index] 
		}
			
		ToolTip, % tip_text	
		index+=1
		KeyWait, %key_2%
	} 
	tip_text := ""
 return		
 

 
;===================================================
;===================================================

;~Esc:: ExitApp


Old clipboards.

This script saves old clipboard entries.
In short:
● while pressing the left Win or Shift key, press "Space" key repeatedly to go through past clipboards
● LWin & Space - go through past clipboards and paste when "Space" key is released
● LShift & Space - go through past clipboards for viewing (two at a time)
● Ctrl & Space - Show all past clipboards (shows for a while, until mouse is not over tooltip)
● LWin - copy to clipboard
● press RWin = Copy , double press RWin = Paste (this key double press is from old AHK help)
● AppsKey = append to clipboard


Code: Select all


#SingleInstance force
Menu, Tray, Icon, Shell32.dll, 177 
;Menu, Tray,Tip , ✔ Script #1 ❶
Menu, Tray,Tip , Script #1
;#NoTrayIcon

/* 
	● while pressing the left Win or Shift key, press "Space" key repeatedly to go through past clipboards
	● LWin & Space  - go through past clipboards and paste when "Space" key is released
	● LShift & Space - go through past clipboards for viewing (two at a time)
	● Ctrl & Space - Show all past clipboards (shows for a while, until mouse is not over tooltip)
	● LWin - copy to clipboard 
	● press RWin = Copy , double press RWin = Paste  (this key double press is from old AHK help)
	● AppsKey = append to clipboard 
	● 
	● 
	● 
*/


;*********************** Old Clipboard ********************************** 


global toggle, ClipOld, ClipNew
toggle=1
ClipNew := clipboard
ClipOld11 := Chr(216) ;"Ø"
ClipOld :=" "
number_of_clips=11



OnClipboardChange:
 if(toggle=0 || WinActive("Save As")){
	return
	; }else if RegExMatch(ClipNew, "mi)<html>|vlc-record"){
	 ;return 
	; }else if (StrLen(clipboard)>2000){
	;  return 
 }else{
	 if(ClipOld1 == clipboard OR clipboard == ClipNew OR ClipOld == clipboard){			
			 return
	}else	if(RegExMatch(clipboard,"i)r\d---sn-|^<!DOCTYPE html>")){ ; YT video link			 
			 return
		}else{	
			ClipOld10 := ClipOld9
			ClipOld9 := ClipOld8
			ClipOld8 := ClipOld7
			ClipOld7 := ClipOld6
			ClipOld6 := ClipOld5
			ClipOld5 := ClipOld4
			ClipOld4 := ClipOld3
			ClipOld3 := ClipOld2
			ClipOld2 := ClipOld1
	   
 
/*
; working only as a separate script
	Loop %number_of_clips% { 
		step := number_of_clips  - A_Index
				 if (step<=1)
					break					
			prev:= step - 1				
			if (Clip_Old%step% != Clip_Old%prev%){
				Clip_Old%step% := Clip_Old%prev%
			} 
		}
		
	   */
	
		ClipOld1 := ClipNew
		ClipOld:=ClipOld1	;ClipOld := ClipNew
		ClipNew := clipboard
	}
}
return


/* #c::
			clip_change:=clipboard
			Send, ^c
	 	Gosub, old_clipboards_
			clip_change:=""
return
  */
		
~LWin & LCtrl:: SendInput %ClipOld% 



switch_last_clipboard:
		toggle=0		

if(RegExMatch(clipboard,"i)^<!DOCTYPE html>")){ 
			ClipTemp:="Nope"
			clipboard:=""	
			
		}else{
			ClipTemp := clipboard
			clipboard:=ClipOld1
			ClipOld1:=ClipTemp
			ClipTemp:=SubStr(clipboard, 1, 50)	
		}		

		ToolTip % "● SWITCH clip`n" ClipTemp
		Sleep 2000
		ToolTip 
		ClipTemp=
		;Gosub, Show_Clipboard5
		toggle=1
return


del_clipboard:
	toggle=0
/* 		if(RegExMatch(clipboard,"i)r\d---sn-|^<!DOCTYPE html>")){ ; YT video link		r4---sn-8xgp1vo-xfgee.googlevideo.com	
			clipboard:=""
		}
		*/
		clipboard:=""
			ToolTip % "DEL clipboard "
			Sleep 400
			ToolTip 
	toggle=1
return


;_________________________________________ LWin & Space::


LWin & Space:: 
	index=1
	CoordMode,ToolTip,Screen
	
	Clip1 := SubStr(clipboard, 1, 100) "`n" SubStr(clipboard, 101, 100) "`n" SubStr(clipboard, 201, 100) "`n" SubStr(clipboard, 301, 100) "`n" SubStr(clipboard, 401, 100)	
	Clip1 :=  RegExReplace(Clip1, "`n`n","") 
	
	if (StrLen(clipboard)<=470){
	ToolTip, %  "Clipboard (" StrLen(clipboard ) " long) `n¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯`n" Clip1 "`n ̢"  
	}else

	ToolTip, %  "Clipboard (" StrLen(clipboard ) " long) `n¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯`n" Clip1 "`n ̢" ,500, 330 
	KeyWait, Space
	SetTimer, 2_Key_Down_Timer, 100 
	ClipPaste:=clipboard
	
	KeyWait, LWin
	SetTimer, 2_Key_Down_Timer, off
	ToolTip
	clipboard_backup := clipboard
	Clipboard:=ClipPaste
	Send ^v
	; SendInput % special_keys_send(ClipPaste) ; too slow 
	clipboard := clipboard_backup

2_Key_Down_Timer:			
		if (GetKeyState("Space", "P") = 1)	{	
			if index> 11
				return
		ClipPaste:=ClipOld%index%
		CoordMode,ToolTip,Screen
	
	Clip2 := SubStr(ClipPaste, 1, 100) "`n"SubStr(ClipPaste, 101, 100)"`n"SubStr(ClipPaste, 201, 100)"`n"SubStr(ClipPaste, 301, 100)"`n"SubStr(ClipPaste, 401, 100)		
	Clip2 :=  RegExReplace(Clip2, "`n`n","") 
	
 	if (StrLen(ClipPaste)<=70){
	ToolTip, %  "#" index " ("StrLen(ClipPaste) ")" "`n¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯`n" Clip2  "`n ̢" 
	}else	
 
	ToolTip, % "#" index " ("StrLen(ClipPaste) ") " "`n¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯`n" Clip2 "`n ̢" ,500, 330
	
		index+=1
		}
		KeyWait, Space		 
 return		
return

;^b:: SendInput %ClipOld%
;LAlt & Space:: Gosub, Show_Clipboard    ;SendInput %clipboard%

;---------------------------------------------- LShift & Space::

LShift & Space::
;LCtrl & Space::
	index_Clip=2
	CoordMode,ToolTip,Screen
	Clip1 := SubStr(clipboard, 1, 100) "`n" SubStr(clipboard, 101, 100) "`n" SubStr(clipboard, 201, 100) "`n" SubStr(clipboard, 301, 100) "`n" SubStr(clipboard, 401, 100) 		
	Clip1 :=  RegExReplace(Clip1, "`n`n`n","") 
	
	Clip3 := (StrLen(ClipOld1)>0) ? SubStr(ClipOld1, 1, 100) "`n" SubStr(ClipOld1, 201, 100) "`n" SubStr(ClipOld1, 301, 100) "`n" SubStr(ClipOld1, 401, 100) "`n" SubStr(ClipOld1, 501, 100) : "" 		
	Clip3 :=  RegExReplace(Clip3, "`n`n`n","") 
	
	ToolTip, %  "Clipboard ("StrLen(clipboard)"): `n¯¯¯¯¯¯¯¯¯¯¯`n" Clip1 "`n`n_________________________________________   	`n¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯   `n#1 (" StrLen(ClipOld1)"): `n¯¯¯¯¯¯¯¯¯¯¯`n" Clip3 "`n ̢",500, 330 	
	
	KeyWait, Space
	SetTimer, 2_Key_Down_Timer_2, 100 
	ClipPaste:=clipboard
	
	KeyWait, LShift   ;KeyWait, LCtrl
	SetTimer, 2_Key_Down_Timer_2, off
	ToolTip

2_Key_Down_Timer_2:			
		if (GetKeyState("Space", "P") = 1)	{	
			if index_Clip> 10
				return
		ClipPaste:=ClipOld%index_Clip%
		index_Clip2:=index_Clip +1
		ClipPaste2:=ClipOld%index_Clip2%
		CoordMode,ToolTip,Screen
	Clip2 := SubStr(ClipPaste, 1, 100) "`n" SubStr(ClipPaste, 101, 100) "`n" SubStr(ClipPaste, 201, 100) "`n" SubStr(ClipPaste, 301, 100)"`n"SubStr(ClipPaste, 401, 100)		
	Clip2 :=  RegExReplace(Clip2, "`n`n","") 
	
	Clip4 := SubStr(ClipPaste2, 1, 100) "`n" SubStr(ClipPaste2, 201, 100) "`n" SubStr(ClipPaste2, 301, 100) "`n" SubStr(ClipPaste2, 401, 100) "`n" SubStr(ClipPaste2, 501, 100)	
	Clip4 :=  RegExReplace(Clip4, "`n`n","") 
	ToolTip, % "#" index_Clip " (" StrLen(ClipPaste)"): `n‾‾‾‾‾‾‾‾‾‾`n" Clip2 "`n_________________________________________   `n‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾   `n#" index_Clip2 " (" StrLen(ClipPaste2) "): `n‾‾‾‾‾‾‾‾‾‾`n" Clip4 "`n ̢" ,500, 330 
	
		index_Clip+=2	
		}
		KeyWait, Space		
 return		
return




;======================= Ctrl & Space Show_Clips_All

^Space:: Gosub, Show_Clips_All    

Show_Clips_All:               
	AutoTrim, On       
  Clips1 := "#0 (" StrLen(clipboard)"):  `n" SubStr(Clipboard, 1, 50) "`n______________________`n"  "#1 (" StrLen(ClipOld)"):  `n" SubStr(ClipOld1, 1, 50) "`n______________________`n" "#2 (" StrLen(ClipOld2)"):  `n"  SubStr(ClipOld2, 1, 50)"`n______________________`n" "#3 (" StrLen(ClipOld3)"):  `n"  SubStr(ClipOld3, 1, 50)"`n______________________`n" "#4 (" StrLen(ClipOld4)"):  `n"  SubStr(ClipOld4, 1, 50)"`n______________________`n" "#5 (" StrLen(ClipOld5)"):  `n"  SubStr(ClipOld5, 1, 50)	  
  Clips2 := "#6 (" StrLen(ClipOld6)"):  `n"  SubStr(ClipOld6, 1, 50) "`n______________________`n" "#7 (" StrLen(ClipOld7)"):  `n" SubStr(ClipOld7, 1, 100) "`n______________________`n" "#8 (" StrLen(ClipOld8)"):  `n"  SubStr(ClipOld8, 1, 50)"`n______________________`n" "#9 (" StrLen(ClipOld9)"):  `n"  SubStr(ClipOld9, 1, 50)"`n______________________`n" "#10 (" StrLen(ClipOld10)"):  `n" SubStr(ClipOld10, 1, 50)	  
		
		
  CoordMode,ToolTip,Screen
  ToolTip %Clips1%`n______________________`n%Clips2%`n______________________`nSecond clipboard:`n%Second_clipboard%,500, 200  		

  loop {
		Sleep 2000
		If !MouseIsOver("ahk_class tooltips_class32") 
		break
  }
  ToolTip  
return



;************************ LWin

LWin:: ; copy to clipboard 
	Gosub, Close_Context_Menu 
  Send, ^c   
	Gosub, Show_Clipboard4 	
 return
 
Show_Clipboard4: 	
	ToolTip % SubStr(clipboard, 1, 50)
  Sleep 400
  ToolTip  
return

Close_Context_Menu:
 Send {Ctrl down}{Alt down}{Alt up}{Ctrl up}
return

;************************ RWin - Copy/Paste - single, double press ************************


RWin::
if (key_presses > 0) {    
	key_presses += 1
	return
}
key_presses = 1
SetTimer, KeyWinC, 400 
return

KeyWinC:
	SetTimer, KeyWinC, off
	if (key_presses = 1) {         
			Gosub, Close_Context_Menu
			;Sleep,80
			Send, ^c                          
			Gosub, Show_Clipboard4 
	} 
	else if (key_presses = 2) {  
			Send, ^v  
	}
	else if (key_presses > 2){
		Gosub, Close_Context_Menu
			Send, ^c
			Clip3 := RegExReplace(RegExReplace(clipboard, "`r`n"," ") , """","'")
			zzClip3 := RegExReplace(RegExReplace(Clip3, "”","'") , "“","'")  
			;Clip3 := RegExReplace(Clip3, ".”\s?$", "'.")  ;RegExReplace(Clip3, ".'","'.")   \s
			;SendInput %Clip3%
			clipboard = %Clip3%  
			CoordMode,ToolTip,Screen
			ToolTip ` %Clip5%_,600, 300                 
			Sleep 1500
			ToolTip 
	}

	key_presses = 0
return


;=========================

AppsKey:: Gosub, Append_to_Clipboard 


Append_to_Clipboard:
 toggle=0
 Gosub, Close_Context_Menu  
 last_clipboard = %clipboard% 
 last_clipboard:=Trim(last_clipboard)
 Send, ^c 	
 clipboard:=Trim(clipboard)
 clipboard = %last_clipboard%` %clipboard% 
 Gosub, Show_Clipboard4   
 toggle=1
return

;=========================



MouseIsOver(WinTitle) {
    MouseGetPos,,, Win
    return WinExist(WinTitle . " ahk_id " . Win)
}

MouseIsOverControl(ClassNN) {
    MouseGetPos,,,,control
    return (ClassNN = control)
}


#IfWinActive ahk_class MozillaWindowClass
	~LButton & WheelUp:: SendInput {PgUp}
	~LButton & Wheeldown:: SendInput {PgDn}
#IfWinActive 



;~Esc:: ExitApp

drozdman
Posts: 78
Joined: 05 Dec 2015, 01:07

Re: Sets of hotkeys. Old clipboards.

17 Aug 2018, 11:22

I added color for the tooltip (ToolTipColor). Although it works only with SendInput (using clipboard causes problems)

Code: Select all


#SingleInstance force
Menu, Tray, Icon, Shell32.dll, 177 
;Menu, Tray,Tip , ✔ Script #2 ❷
Menu, Tray,Tip , Script #2
;#NoTrayIcon

/* 
	● Save script in unicode
	● The script creates a set of hotkeys. 
	● Each hotkey has a set of texts to send
	● can go through the set of texts which are shown in tooltip
	● "MyHotkeys" array is a set of hotkeys. like "LAlt & z", "LAlt & a", etc.
	● "hotkeys_texts" arrays contain the texts assigned to each hotkey respectively
	● For instance: 
		hotkey: "LAlt & a" 
		while pressing the left "Alt" key, press "a" key repeatedly to go through the list shown in a tooltip. 
		To paste the chosen text release the left "Alt" key
*/

;***********************   ***************************************
; Send_texts

; q w e r t 
; a s d f
; z x c v

MyHotkeys := ["LAlt & z","LAlt & a","LAlt & s","LAlt & x"]

hotkeys_texts := Object()



hotkeys_texts[1] := [ "•", "●", "✔", "?|","∕ ∶∖","àéü","*.*",""] 
hotkeys_texts[2] := ["Rome","Berlin","Cracovia","Madrid","Athens","Paris",""] 
hotkeys_texts[3] :=["Barcelona","Real","Bayern","Wisła",""] 
hotkeys_texts[4] :=["Maradona","Ronaldinho","Messi","Ronaldo",""] 





Loop, % MyHotkeys.Length(){
	HotKey, % MyHotkeys[A_Index] , Send_text
}


 
Send_text:
    Loop, % MyHotkeys.MaxIndex(){
        TempHotkey := MyHotkeys[A_Index]          
        If (TempHotkey = A_ThisHotkey){
					Hot_keys := StrSplit(MyHotkeys[A_Index], "&", A_Space)
					key_1 := Hot_keys[1]
					key_2 := Hot_keys[2]
					texts := hotkeys_texts[A_Index]
					gosub, Send_texts
            Break                                   
        }

    }
		
	ToolTipFont("s9", "Segoe UI Semibold")
	ToolTipColor("F2EEDC", "800000")
	;ToolTipColor("F2EEDC", "000000")
return
 
Send_texts: 
	Loop, % texts.MaxIndex(){
		tip_text:= tip_text . " `n  " texts[A_Index] 
		if((A_Index==3 || A_Index==6 || A_Index==9) && texts[1]!="• "){
		tip_text:= tip_text . "`n`  ───── "
		}
	}
	tip_text := "  ¯¯¯¯" . tip_text
	
	index=1
	Paste:=tip_text
	ToolTip, % Paste
	KeyWait, % key_2
	SetTimer, 2_Key_Down_Timer, 5 
	
	KeyWait, % key_1
	SetTimer, 2_Key_Down_Timer, off
	ToolTip
	if !InStr(Paste, "¯¯¯¯"){	
/* 	clipboard_backup := clipboard
		;Clipboard:=Paste
	Clipboard:=Paste " "

	Send ^v
	clipboard := clipboard_backup
 */
	SendInput % (Paste!="") ? Paste " " : "" ; too slow
	
	}
	tip_text=
return


2_Key_Down_Timer:
	if (GetKeyState(key_2, "P") = 1){				
		if (index> texts.MaxIndex()){
			index:=1 
		}
		Paste:=texts[index]
		
		Loop, % texts.MaxIndex(){
		  if((A_Index==4 || A_Index==7 || A_Index==10)){
		  tip_text:= tip_text . "`n`  ───── "
		  }	
		  
		  if(A_Index==index && A_Index!=texts.MaxIndex()){
		  tip_text:= tip_text . " `n  " texts[A_Index] " ✔"
		  }else
		  tip_text:= tip_text . " `n  " texts[A_Index] 
		}
			
		ToolTip, % tip_text	
		index+=1
		KeyWait, %key_2%
	} 
	tip_text := ""
 return		
 

 
;===================================================
;===================================================

;~Esc:: ExitApp


 
ToolTipFont(Options := "", Name := "", hwnd := ""){ ;lexikos https://autohotkey.com/boards/viewtopic.php?t=4777
    static hfont := 0
    if (hwnd = "")
        hfont := Options="Default" ? 0 : _TTG("Font", Options, Name), _TTHook()
    else
        DllCall("SendMessage", "ptr", hwnd, "uint", 0x30, "ptr", hfont, "ptr", 0)
}
 
ToolTipColor(Background := "", Text := "", hwnd := ""){
    static bc := "", tc := ""
    if (hwnd = "") {
        if (Background != "")
            bc := Background="Default" ? "" : _TTG("Color", Background)
        if (Text != "")
            tc := Text="Default" ? "" : _TTG("Color", Text)
        _TTHook()
    }
    else {
        VarSetCapacity(empty, 2, 0)
        DllCall("UxTheme.dll\SetWindowTheme", "ptr", hwnd, "ptr", 0
            , "ptr", (bc != "" && tc != "") ? &empty : 0)
        if (bc != "")
            DllCall("SendMessage", "ptr", hwnd, "uint", 1043, "ptr", bc, "ptr", 0)
        if (tc != "")
            DllCall("SendMessage", "ptr", hwnd, "uint", 1044, "ptr", tc, "ptr", 0)
    }
}
 
_TTHook(){
    static hook := 0
    if !hook
        hook := DllCall("SetWindowsHookExW", "int", 4
            , "ptr", RegisterCallback("_TTWndProc"), "ptr", 0
            , "uint", DllCall("GetCurrentThreadId"), "ptr")
}
 
_TTWndProc(nCode, _wp, _lp) {
    Critical 999
   ;lParam  := NumGet(_lp+0*A_PtrSize)
   ;wParam  := NumGet(_lp+1*A_PtrSize)
    uMsg    := NumGet(_lp+2*A_PtrSize, "uint")
    hwnd    := NumGet(_lp+3*A_PtrSize)
    if (nCode >= 0 && (uMsg = 1081 || uMsg = 1036)) {
        _hack_ = ahk_id %hwnd%
        WinGetClass wclass, %_hack_%
        if (wclass = "tooltips_class32") {
            ToolTipColor(,, hwnd)
            ToolTipFont(,, hwnd)
        }
    }
    return DllCall("CallNextHookEx", "ptr", 0, "int", nCode, "ptr", _wp, "ptr", _lp, "ptr")
}
 
_TTG(Cmd, Arg1, Arg2 := "") {
    static htext := 0, hgui := 0
    if !htext {
        Gui _TTG: Add, Text, +hwndhtext
        Gui _TTG: +hwndhgui +0x40000000
    }
    Gui _TTG: %Cmd%, %Arg1%, %Arg2%
    if (Cmd = "Font") {
        GuiControl _TTG: Font, %htext%
        SendMessage 0x31, 0, 0,, ahk_id %htext%
        return ErrorLevel
    }
    if (Cmd = "Color") {
        hdc := DllCall("GetDC", "ptr", htext, "ptr")
        SendMessage 0x138, hdc, htext,, ahk_id %hgui%
        clr := DllCall("GetBkColor", "ptr", hdc, "uint")
        DllCall("ReleaseDC", "ptr", htext, "ptr", hdc)
        return clr
    }
}

;==================================



Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: gwarble and 61 guests