OSD display trick!!!

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
howiesun
Posts: 13
Joined: 15 Dec 2017, 15:35

OSD display trick!!!

15 Dec 2017, 15:46

Taran is awesome.. but I couldn't figure out how to duplicate it..
https://www.youtube.com/watch?v=gF-f25d ... gPCJWft4QZ

Basically he was able to turn OSD to read a text file, and based on his key presses, finds in the text file the corrisponding function of premiere pro (or anything else for that matter)
and displays it on the second line.. watch the video u know what i mean..

For the last few days I have been trying.. but basically I was able to take the original SHOWOFF.AHK , move the window down, change the text color, make the background transparent... and that's it..

can someone be kind enough to help me out here? thx~~~~~~~
John316
Posts: 13
Joined: 15 Dec 2017, 08:53

Re: OSD display trick!!!

16 Dec 2017, 07:59

[This is not my code] Here's a working example I found on the same GitHub link. It does't show the actual task being done though like the video.

Code: Select all

; KeypressOSD.ahk
; Written by VarunJhajharia, then heavily modified by Victor Uribe! (Not scripted by Taran at all!)
;THIS IS A SIMPLER ALTERNATIVE TO KEYSTROKE VIZ.AHK. THE TWO SHOULD NOT BE USED AT THE SAME TIME.
;This visualizer does not show associated commands.

#SingleInstance force
#NoEnv
SetBatchLines, -1
ListLines, Off
CoordMode, Mouse, Screen

; Settings
maxOnScreenChars := 60 ; Maximum number of characters that will be displayed
fontCharWidth := 27    ; Depends on resolution needs to be changed if 
textFont = Consolas     ; NOT WORKING Make sure to set fontCharWidth correclty and only use monospace fonts
bgColor = Black        ; background color of the gui
spaceStr := " "     ; This is the string that will appear when pressing the space key
counterPrefix := " x"

transN        := 100    ; 0=transparent, 255=opaque
ShowSingleKey := True  ; dislay A-Z, Enter and other keys pressed without modifier (Ctr, Alt, ...)
DisplayTime   := 500  ; time to fade, in milliseconds
DisplayTime2  := 2500

; Create GUI
Gui, +AlwaysOnTop -Caption +Owner +LastFound +E0x20
Gui, Margin, 0, 0
Gui, Color, bgColor
Gui, Font, cWhite s30 bold, Consolas
Gui, Add, Text, vHotkeyText Left x2
WinSet, Transparent, %transN%
Winset, AlwaysOnTop, On
SetTimer, ShowHotkey, 1

; Create hotkey

;get //
Loop, 95
    Hotkey, % "~*" Chr(A_Index + 31), Display
Loop, 24 ; F1-F24
    Hotkey, % "~*F" A_Index, Display
Loop, 10 ; Numpad0 - Numpad9
    Hotkey, % "~*Numpad" A_Index - 1, Display

Otherkeys := "NumpadDiv|NumpadMult|NumpadAdd|NumpadSub|Tab|Enter|Esc|BackSpace|Del|Insert|Home|End|PgUp|PgDn|Up|Down|Left|Right|ScrollLock|CapsLock|NumLock|Pause|Space|NumpadDot|NumpadEnter|Media_Play_Pause|Launch_Mail|Launch_Media|Launch_App1|Launch_App2|Volume_Mute|Volume_Up|Volume_Down|Browser_Home|AppsKey|PrintScreen|Sleep|LButton|RButton|MButton|XButton1|XButton2|WheelDown|WheelUp|WheelLeft|WheelRight"

Loop, parse, Otherkeys, |
    Hotkey, % "~*" A_LoopField, Display
return

Count(H, N) {
	Pos := 0, Count := 0
	Loop
		If (Pos := InStr(H, N, False, Pos + 1))
			Count++
		else
			break
	return Count
}

CountInString( ByRef Haystack , Needle = "" ,pVal=0) {
  StringReplace, Haystack, Haystack, %Needle%, %Needle%, UseErrorLevel
  Return ErrorLevel+pVal
}

; Display
;
PreviousKeys := ""
counter=1
lastKeyPress := ""

Display:
	actualkey := SubStr(A_ThisHotkey, 3)
	
	if (StrLen(PreviousKeys) > maxOnScreenChars){
		PreviousKeys := " " prefix lastKeyPress
		counter=1
	}
	
    If (A_ThisHotkey = "")
        Return
		
	;declare modifiers
    mods := "Ctrl|Shift|Alt|LWin|RWin"
    
	;declare prefix for mod keys
	prefix := ""
    
	;parse for modifier keys
	Loop, Parse, mods, |
        if GetKeyState(A_LoopField){
            prefix .= A_LoopField "+"
		}
    if (!prefix && !ShowSingleKey)
        return
	
	;check for special keys and mouse buttons (tab, space, medai etc)
	oKey := InStr(Otherkeys, actualkey)
	
	if ((StrLen(prefix)> 0 or oKey > 0 and StrLen(actualkey) > 1) and prefix <> "Shift+"){	
		if (lastKeyPress = actualkey){
			if (counter > 1){
				StringTrimRight, PreviousKeys, key, 4
			}				
			counter+=1
			if (StrLen(prefix) > 0){
				key := PreviousKeys counterPrefix counter " "
			}
			else {
				key := PreviousKeys prefix counterPrefix counter " "
			}
			key := StrReplace(key,"  "," ")
		}
		else{
			counter = 1
			key := PreviousKeys " " prefix actualkey " " 
			key := StrReplace(key,"  "," ")
		}
	}
	else{
		; replace spaces with spaceStr from settings
		hotk := StrReplace(actualkey," ",spaceStr)
		;actual key to display
		key := PreviousKeys prefix hotk
    }
    
	if (prefix = "Shift+")
		key := PreviousKeys actualkey
		
    ;looping with modifiers
	PreviousKeys := key
	lastKeyPress := actualkey
	key := StrReplace(key,"Numpad","")
	key := StrReplace(key,"&","&&")

	LastHotkeyPressedTime := A_TickCount
Return

; Show Gui element with the hotkeys, move with mouse and fade into transparency
ShowHotkey:
    prev_X := -999
    prev_Y := -999
    prev_LastHotkeyPressedTime := "999"
    Gui, +LastFound
    Loop {
        Elapsed := A_TickCount - LastHotkeyPressedTime
        Faded := 1 - Elapsed/DisplayTime
        if (prev_LastHotkeyPressedTime != LastHotkeyPressedTime) {
            WinSet, Transparent, % transN
        } else if (Faded > 0.1) {
            WinSet, Transparent, % transN * 1
        }
        MouseGetPos, X, Y
        if (prev_LastHotkeyPressedTime != LastHotkeyPressedTime or (((abs(prev_X - X) > 1 or abs(prev_Y - Y) > 1) or Faded < 0) and PreviousKeys != "")) {
            text_w := StrLen(key) * fontCharWidth + 7
            
			if (Faded < 0.1) {
                adjusted_X := 20
                adjusted_Y := A_ScreenHeight - 100
                WinSet, Transparent, % 50
                PreviousKeys := ""
				lastKeyPress := ""
				counter := 1
            } else {
                adjusted_X := 20
                adjusted_Y := A_ScreenHeight - 100
            }
			
            GuiControl,, HotkeyText, %key%
            GuiControl, Move, HotkeyText, +AlwaysOnTop w%text_w%
            WinSet, Region, 0-0 W%text_w% H60 R10-10
            Gui, Show, NoActivate x%adjusted_X% y%adjusted_Y% w%text_w%
            prev_X := X
            prev_Y := Y
            prev_LastHotkeyPressedTime := LastHotkeyPressedTime
			SetTimer, HideGUI, % -1 * DisplayTime2
        }
        Sleep, 20
    }
Return

HideGUI() {
	Gui, Hide
}
howiesun
Posts: 13
Joined: 15 Dec 2017, 15:35

Re: OSD display trick!!!

16 Dec 2017, 22:01

I got the osd working already
what I need to find out is how it links to a text file to display the function
howiesun
Posts: 13
Joined: 15 Dec 2017, 15:35

Re: OSD display trick!!!

16 Dec 2017, 22:11

John316 wrote:[This is not my code] Here's a working example I found on the same GitHub link. It does't show the actual task being done though like the video.

Code: Select all

; KeypressOSD.ahk
; Written by VarunJhajharia, then heavily modified by Victor Uribe! (Not scripted by Taran at all!)
;THIS IS A SIMPLER ALTERNATIVE TO KEYSTROKE VIZ.AHK. THE TWO SHOULD NOT BE USED AT THE SAME TIME.
;This visualizer does not show associated commands.

#SingleInstance force
#NoEnv
SetBatchLines, -1
ListLines, Off
CoordMode, Mouse, Screen

; Settings
maxOnScreenChars := 60 ; Maximum number of characters that will be displayed
fontCharWidth := 27    ; Depends on resolution needs to be changed if 
textFont = Consolas     ; NOT WORKING Make sure to set fontCharWidth correclty and only use monospace fonts
bgColor = Black        ; background color of the gui
spaceStr := " "     ; This is the string that will appear when pressing the space key
counterPrefix := " x"

transN        := 100    ; 0=transparent, 255=opaque
ShowSingleKey := True  ; dislay A-Z, Enter and other keys pressed without modifier (Ctr, Alt, ...)
DisplayTime   := 500  ; time to fade, in milliseconds
DisplayTime2  := 2500

; Create GUI
Gui, +AlwaysOnTop -Caption +Owner +LastFound +E0x20
Gui, Margin, 0, 0
Gui, Color, bgColor
Gui, Font, cWhite s30 bold, Consolas
Gui, Add, Text, vHotkeyText Left x2
WinSet, Transparent, %transN%
Winset, AlwaysOnTop, On
SetTimer, ShowHotkey, 1

; Create hotkey

;get //
Loop, 95
    Hotkey, % "~*" Chr(A_Index + 31), Display
Loop, 24 ; F1-F24
    Hotkey, % "~*F" A_Index, Display
Loop, 10 ; Numpad0 - Numpad9
    Hotkey, % "~*Numpad" A_Index - 1, Display

Otherkeys := "NumpadDiv|NumpadMult|NumpadAdd|NumpadSub|Tab|Enter|Esc|BackSpace|Del|Insert|Home|End|PgUp|PgDn|Up|Down|Left|Right|ScrollLock|CapsLock|NumLock|Pause|Space|NumpadDot|NumpadEnter|Media_Play_Pause|Launch_Mail|Launch_Media|Launch_App1|Launch_App2|Volume_Mute|Volume_Up|Volume_Down|Browser_Home|AppsKey|PrintScreen|Sleep|LButton|RButton|MButton|XButton1|XButton2|WheelDown|WheelUp|WheelLeft|WheelRight"

Loop, parse, Otherkeys, |
    Hotkey, % "~*" A_LoopField, Display
return

Count(H, N) {
	Pos := 0, Count := 0
	Loop
		If (Pos := InStr(H, N, False, Pos + 1))
			Count++
		else
			break
	return Count
}

CountInString( ByRef Haystack , Needle = "" ,pVal=0) {
  StringReplace, Haystack, Haystack, %Needle%, %Needle%, UseErrorLevel
  Return ErrorLevel+pVal
}

; Display
;
PreviousKeys := ""
counter=1
lastKeyPress := ""

Display:
	actualkey := SubStr(A_ThisHotkey, 3)
	
	if (StrLen(PreviousKeys) > maxOnScreenChars){
		PreviousKeys := " " prefix lastKeyPress
		counter=1
	}
	
    If (A_ThisHotkey = "")
        Return
		
	;declare modifiers
    mods := "Ctrl|Shift|Alt|LWin|RWin"
    
	;declare prefix for mod keys
	prefix := ""
    
	;parse for modifier keys
	Loop, Parse, mods, |
        if GetKeyState(A_LoopField){
            prefix .= A_LoopField "+"
		}
    if (!prefix && !ShowSingleKey)
        return
	
	;check for special keys and mouse buttons (tab, space, medai etc)
	oKey := InStr(Otherkeys, actualkey)
	
	if ((StrLen(prefix)> 0 or oKey > 0 and StrLen(actualkey) > 1) and prefix <> "Shift+"){	
		if (lastKeyPress = actualkey){
			if (counter > 1){
				StringTrimRight, PreviousKeys, key, 4
			}				
			counter+=1
			if (StrLen(prefix) > 0){
				key := PreviousKeys counterPrefix counter " "
			}
			else {
				key := PreviousKeys prefix counterPrefix counter " "
			}
			key := StrReplace(key,"  "," ")
		}
		else{
			counter = 1
			key := PreviousKeys " " prefix actualkey " " 
			key := StrReplace(key,"  "," ")
		}
	}
	else{
		; replace spaces with spaceStr from settings
		hotk := StrReplace(actualkey," ",spaceStr)
		;actual key to display
		key := PreviousKeys prefix hotk
    }
    
	if (prefix = "Shift+")
		key := PreviousKeys actualkey
		
    ;looping with modifiers
	PreviousKeys := key
	lastKeyPress := actualkey
	key := StrReplace(key,"Numpad","")
	key := StrReplace(key,"&","&&")

	LastHotkeyPressedTime := A_TickCount
Return

; Show Gui element with the hotkeys, move with mouse and fade into transparency
ShowHotkey:
    prev_X := -999
    prev_Y := -999
    prev_LastHotkeyPressedTime := "999"
    Gui, +LastFound
    Loop {
        Elapsed := A_TickCount - LastHotkeyPressedTime
        Faded := 1 - Elapsed/DisplayTime
        if (prev_LastHotkeyPressedTime != LastHotkeyPressedTime) {
            WinSet, Transparent, % transN
        } else if (Faded > 0.1) {
            WinSet, Transparent, % transN * 1
        }
        MouseGetPos, X, Y
        if (prev_LastHotkeyPressedTime != LastHotkeyPressedTime or (((abs(prev_X - X) > 1 or abs(prev_Y - Y) > 1) or Faded < 0) and PreviousKeys != "")) {
            text_w := StrLen(key) * fontCharWidth + 7
            
			if (Faded < 0.1) {
                adjusted_X := 20
                adjusted_Y := A_ScreenHeight - 100
                WinSet, Transparent, % 50
                PreviousKeys := ""
				lastKeyPress := ""
				counter := 1
            } else {
                adjusted_X := 20
                adjusted_Y := A_ScreenHeight - 100
            }
			
            GuiControl,, HotkeyText, %key%
            GuiControl, Move, HotkeyText, +AlwaysOnTop w%text_w%
            WinSet, Region, 0-0 W%text_w% H60 R10-10
            Gui, Show, NoActivate x%adjusted_X% y%adjusted_Y% w%text_w%
            prev_X := X
            prev_Y := Y
            prev_LastHotkeyPressedTime := LastHotkeyPressedTime
			SetTimer, HideGUI, % -1 * DisplayTime2
        }
        Sleep, 20
    }
Return

HideGUI() {
	Gui, Hide
}

btw
I have tried this code
it does not display at all for me
could it be because I have a 3 screen set up?
but the original show off.ahk works for me
Guest

Re: OSD display trick!!!

17 Dec 2017, 06:05

He's looping through a text file that has the keys he uses in Premiere. Here's what I came up with.. (Iteration and Arrays aren't my strong suite)

Code: Select all

FileRead, commands, %A_ScriptDir%\Command.txt   ; store the commands from the file into a variable
Loop, Parse, commands, `n                       ; splits the variable into each line using "`n" as a delimeter
{
  key2 = %A_LoopField%                          ; save each file line to keys2 variable
  StringSplit, commandT, key2, =                ; split the keys2 var into 2 sections--> Function | Hotkey
  cmd = %commandT1%                             ; commandT[N] is now an array. commandT1 = Function
  keys = %commandT2%                            ; commandT2 = Hotkey
  MsgBox, %cmd% = %keys%
  ; You can check for keys and states here
}
The text file contents..

Code: Select all

NewProject=LCtrl Alt N
Sequence=LCtrl N
Title=LCtrl T
OpenProject=LCtrl O
BrowseAdobeBridge=LCtrl Alt O
CloseProject=LCtrl Shift W
I played around with the ShowOff.ahk and added a second text variable to show a "function" happening when you left click. It also changes color, is transparent, and is one line lower like in the youtube video. I added the second text var to the settings file so you can customize it like the first text. What I added is in RED. This code will work but you'll have to add every key combo line for line with IF statements. There's a better way for sure but hopefully this will get you started.

Code: Select all

;ShowOff.ahk
; Shows pushed down keys and buttons
;Skrommel @2005

#SingleInstance,Force
CoordMode,Mouse,Screen

applicationname=ShowOff

Gosub,TRAYMENU
Gosub,READINI
  
shiftkeys=
keys=

Gui,+Owner +AlwaysOnTop -Resize -SysMenu -MinimizeBox -MaximizeBox -Disabled -Caption -Border -ToolWindow
Gui,Margin,0,0
Gui,Color,%backcolor%
Gui,Font,C%fontcolor% S%fontsize% W%boldness%,%font%
Gui,Add,Text,Vtext,MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
[color=#FF0000]Gui,Font
Gui,Font,C%fontcolor2% S%fontsize2% W%boldness2%,%font2%
Gui,Add,Text,Vtext2,`nMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
Gui,Show,X%statusx% Y%statusy% W%statuswidth% H%statusheight% NoActivate,%applicationname%[/color]
GuiControl,,text,
[color=#FF0000]GuiControl,,text2,[/color]
[color=#FF0000]WinSet,TransColor,000000,%applicationname% ; change TransColor to Transparent if you want that option in the INI settings file. TransColor allows the text to show up.[/color]

Loop
{
  oldkeys=%keys%
  keys=
  Loop,%keyarray0%
  {
    key:=keyarray%A_Index%
    StringTrimRight,key,key,1
    GetKeyState,state,%key%,P
    If state=D
	{
		keys=%keys% %key%
		[color=#FF0000]if key = LButton
		{
			GuiControl,,text2,LButton does this action
			SetTimer,STATUSOFF,%timetoshow%
		}[/color]
	}
  }
  StringTrimRight,keys,keys,0
  If keys=%oldkeys%
    Continue

  oldshiftkeys=%shiftkeys%
  shiftkeys=%keys%
  StringReplace,shiftkeys,shiftkeys,LWin
  StringReplace,shiftkeys,shiftkeys,RWin
  StringReplace,shiftkeys,shiftkeys,LCtrl
  StringReplace,shiftkeys,shiftkeys,RCtrl
  StringReplace,shiftkeys,shiftkeys,LShift
  StringReplace,shiftkeys,shiftkeys,RShift
  StringReplace,shiftkeys,shiftkeys,LAlt
  StringReplace,shiftkeys,shiftkeys,RAlt
  StringReplace,shiftkeys,shiftkeys,AltGr
  StringReplace,shiftkeys,shiftkeys,%A_SPACE%,,All  
  If shiftkeys=
  If oldshiftkeys<>
    Continue

  If keys<>
  {
    GuiControl,,text,%keys%
    SetTimer,STATUSOFF,%timetoshow%
  }

  GetKeyState,mstate,LButton,P
  If mstate=D
  {
    MouseGetPos,mx1,my1,mid
    WinGetTitle,stitle,ahk_id %mid%
    If stitle=%applicationname%
    {
      Loop
      {
        MouseGetPos,mx2,my2
        WinGetPos,sx,sy,,,ahk_id %mid%
        sx:=sx-mx1+mx2
        sy:=sy-my1+my2
        WinMove,ahk_id %mid%,,%sx%,%sy%      
        mx1:=mx2
        my1:=my2
        GetKeyState,mstate,LButton,P
        If mstate=U
          Break
      } 
    }
  }
}


STATUSOFF:
GuiControl,,text,
[color=#FF0000]GuiControl,,text2,[/color]
SetTimer,STATUSOFF,Off
Return


READINI:
IfNotExist,%applicationname%.ini
{
  inifile=;%applicationname%.ini
  inifile=%inifile%`n`;[Settings]
  inifile=%inifile%`n`;backcolor    000000-FFFFFF 
  inifile=%inifile%`n`;fontcolor    000000-FFFFFF
  inifile=%inifile%`n`;fontsize
  inifile=%inifile%`n`;boldness     1-1000   `;400=normal 700=bold
  inifile=%inifile%`n`;font
  inifile=%inifile%`n`;statusheight
  inifile=%inifile%`n`;statuswidth
  inifile=%inifile%`n`;statusx
  inifile=%inifile%`n`;statusy
  inifile=%inifile%`n`;relative     0-1       `;relative to 0=screen 1=active window
  inifile=%inifile%`n`;transparency 0-255,Off
  inifile=%inifile%`n`;timetohide             `;time in ms
  inifile=%inifile%`n
  inifile=%inifile%`n[Settings]
  inifile=%inifile%`nbackcolor=000000
  inifile=%inifile%`nfontcolor=FFFFFF
  inifile=%inifile%`nfontsize=20
  inifile=%inifile%`nboldness=800
  inifile=%inifile%`nfont=Arial
  inifile=%inifile%`nstatusheight=120
  inifile=%inifile%`nstatuswidth=500
  inifile=%inifile%`nstatusx=10
  inifile=%inifile%`nstatusy=10
  inifile=%inifile%`nrelative=1
[color=#FF0000]  ;inifile=%inifile%`ntransparency=On *** LEAVE OFF TO HAVE A TRANSPARENT GUI BACKGROUND ***[/color]
  inifile=%inifile%`ntimetoshow=1000
  inifile=%inifile%`n
  [color=#FF0000]inifile=%inifile%`nfontcolor2=FFAAAA
  inifile=%inifile%`nfontsize2=20
  inifile=%inifile%`nboldness2=800
  inifile=%inifile%`nfont2=Arial[/color]
  inifile=%inifile%`n
  inifile=%inifile%`nAppsKey`nLWin`nRWin`nLCtrl`nRCtrl`nLShift`nRShift`nLAlt`nRAlt`nAltGr
  inifile=%inifile%`nPrintScreen`nCtrlBreak`nPause`nBreak`nHelp`nBrowser_Back`nBrowser_Forward`nBrowser_Refresh`nBrowser_Stop`nBrowser_Search`nBrowser_Favorites`nBrowser_Home`nVolume_Mute`nVolume_Down`nVolume_Up`nMedia_Next`nMedia_Prev`nMedia_Stop`nMedia_Play_Pause`nLaunch_Mail`nLaunch_Media`nLaunch_App1`nLaunch_App2
  inifile=%inifile%`nF1`nF2`nF3`nF4`nF5`nF6`nF7`nF8`nF9`nF10`nF11`nF12`nF13`nF14`nF15`nF16`nF17`nF18`nF19`nF20`nF21`nF22`nF23`nF24
  inifile=%inifile%`nJoy1`nJoy2`nJoy3`nJoy4`nJoy5`nJoy6`nJoy7`nJoy8`nJoy9`nJoy10`nJoy11`nJoy12`nJoy13`nJoy14`nJoy15`nJoy16`nJoy17`nJoy18`nJoy19`nJoy20`nJoy21`nJoy22`nJoy23`nJoy24`nJoy25`nJoy26`nJoy27`nJoy28`nJoy29`nJoy30`nJoy31`nJoy32`nJoyX`nJoyY`nJoyZ`nJoyR`nJoyU`nJoyV`nJoyPOV
  inifile=%inifile%`nSpace`nTab`nEnter`nEscape`nBackspace`nDelete`nInsert`nHome`nEnd`nPgUp`nPgDn`nUp`nDown`nLeft`nRight`nScrollLock`nCapsLock
  inifile=%inifile%`nNumLock`nNumpadDiv`nNumpadMult`nNumpadAdd`nNumpadSub`nNumpadEnter`nNumpadDel`nNumpadIns`nNumpadClear`nNumpadDot`nNumpad0`nNumpad1`nNumpad2`nNumpad3`nNumpad4`nNumpad5`nNumpad6`nNumpad7`nNumpad8`nNumpad9
  inifile=%inifile%`nA`nB`nC`nD`nE`nF`nG`nH`nI`nJ`nK`nL`nM`nN`nO`nP`nQ`nR`nS`nT`nU`nV`nW`nX`nY`nZ`nÆ`nØ`nÅ`n1`n2`n3`n4`n5`n6`n7`n8`n9`n0`n```n`,`n`%`n+`n-`n*`n\`n/`n|`n_`n<`n^`n>`n!`n"`n#`n¤`n&`n(`n)`n=`n?`n´`n'`n¨`n~`n;`n:`n.`n@`n£`n$`n€`n§`nµ
  inifile=%inifile%`nLButton`nRButton`nMButton`nWheelDown`nWheelUp`nXButton1`nXButton2`n
  FileAppend,%inifile%,%applicationname%.ini
}

IniRead,backcolor,%applicationname%.ini,Settings,backcolor
IniRead,fontcolor,%applicationname%.ini,Settings,fontcolor
IniRead,fontsize,%applicationname%.ini,Settings,fontsize
IniRead,boldness,%applicationname%.ini,Settings,boldness
IniRead,font,%applicationname%.ini,Settings,font
[color=#FF0000]IniRead,fontcolor2,%applicationname%.ini,Settings,fontcolor2
IniRead,fontsize2,%applicationname%.ini,Settings,fontsize2
IniRead,boldness2,%applicationname%.ini,Settings,boldness2
IniRead,font2,%applicationname%.ini,Settings,font2[/color]
IniRead,statusheight,%applicationname%.ini,Settings,statusheight
IniRead,statuswidth,%applicationname%.ini,Settings,statuswidth
IniRead,statusx,%applicationname%.ini,Settings,statusx
IniRead,statusy,%applicationname%.ini,Settings,statusy
IniRead,relative,%applicationname%.ini,Settings,relative
IniRead,transparency,%applicationname%.ini,Settings,transparency
IniRead,timetoshow,%applicationname%.ini,Settings,timetoshow
FileRead,inifile,%applicationname%.ini
StringSplit,keyarray,inifile,`n
inifile=
Return


TRAYMENU:
Menu,Tray,NoStandard
Menu,Tray,Add,%applicationname%,SETTINGS
Menu,Tray,Add,
Menu,Tray,Add,&Settings...,SETTINGS
Menu,Tray,Add,&About...,ABOUT
Menu,Tray,Add,E&xit,EXIT
Menu,Tray,Default,%applicationname%
Menu,Tray,Tip,%applicationname%
Return


SETTINGS:
Gosub,READINI
Run,%applicationname%.ini
Return


EXIT:
GuiClose:
ExitApp


ABOUT:
Gui,99:Destroy
Gui,99:Margin,20,20
Gui,99:Add,Picture,xm Icon1,%applicationname%.exe
Gui,99:Font,Bold
Gui,99:Add,Text,x+10 yp+10,%applicationname% v1.0
Gui,99:Font
Gui,99:Add,Text,y+10,Shows pushed down keys and buttons
Gui,99:Add,Text,y+5,- To change the look of the status window, edit the %applicationname%.ini
Gui,99:Add,Text,y+0,by rightclicking the tray menu and selecting Settings

Gui,99:Add,Picture,xm y+20 Icon5,%applicationname%.exe
Gui,99:Font,Bold
Gui,99:Add,Text,x+10 yp+10,1 Hour Software by Skrommel
Gui,99:Font
Gui,99:Add,Text,y+10,For more tools, information and donations, please visit 
Gui,99:Font,CBlue Underline
Gui,99:Add,Text,y+5 G1HOURSOFTWARE,www.1HourSoftware.com
Gui,99:Font

Gui,99:Add,Picture,xm y+20 Icon7,%applicationname%.exe
Gui,99:Font,Bold
Gui,99:Add,Text,x+10 yp+10,DonationCoder
Gui,99:Font
Gui,99:Add,Text,y+10,Please support the contributors at
Gui,99:Font,CBlue Underline
Gui,99:Add,Text,y+5 GDONATIONCODER,www.DonationCoder.com
Gui,99:Font

Gui,99:Add,Picture,xm y+20 Icon6,%applicationname%.exe
Gui,99:Font,Bold
Gui,99:Add,Text,x+10 yp+10,AutoHotkey
Gui,99:Font
Gui,99:Add,Text,y+10,This tool was made using the powerful
Gui,99:Font,CBlue Underline
Gui,99:Add,Text,y+5 GAUTOHOTKEY,www.AutoHotkey.com
Gui,99:Font

Gui,99:Show,,%applicationname% About
hCurs:=DllCall("LoadCursor","UInt",NULL,"Int",32649,"UInt") ;IDC_HAND
OnMessage(0x200,"WM_MOUSEMOVE") 
Return

1HOURSOFTWARE:
  Run,http://www.1hoursoftware.com,,UseErrorLevel
Return

DONATIONCODER:
  Run,http://www.donationcoder.com,,UseErrorLevel
Return

AUTOHOTKEY:
  Run,http://www.autohotkey.com,,UseErrorLevel
Return

99GuiClose:
  Gui,99:Destroy
  OnMessage(0x200,"")
  DllCall("DestroyCursor","Uint",hCur)
Return

WM_MOUSEMOVE(wParam,lParam)
{
  Global hCurs
  MouseGetPos,,,,ctrl
  If ctrl in Static9,Static13,Static17
    DllCall("SetCursor","UInt",hCurs)
  Return
}
Return
John316
Posts: 13
Joined: 15 Dec 2017, 08:53

Re: OSD display trick!!!

17 Dec 2017, 06:19

He's looping through a text file that has the keys he uses in Premiere. . Here's what I came up with.. (Iteration and Arrays aren't my strong suite)

Code: Select all

FileRead, commands, %A_ScriptDir%\Command.txt   ; store the commands from the file into a variable
Loop, Parse, commands, `n                       ; splits the variable into each line using "`n" as a delimeter
{
  key2 = %A_LoopField%                          ; save each file line to keys2 variable
  StringSplit, commandT, key2, =                ; split the keys2 var into 2 sections--> Function | Hotkey
  cmd = %commandT1%                             ; commandT[N] is now an array. commandT1 = Function
  keys = %commandT2%                            ; commandT2 = Hotkey
  MsgBox, %cmd% = %keys%
  ; You can check for keys and states here
}
The text file contents..

Code: Select all

NewProject=LCtrl Alt N
Sequence=LCtrl N
Title=LCtrl T
OpenProject=LCtrl O
BrowseAdobeBridge=LCtrl Alt O
CloseProject=LCtrl Shift W
I played around with the ShowOff.ahk and added a second text variable to show a "function" happening when you left click. It also changes color, is transparent, and is one line lower like in the youtube video. I added the second text var to the settings file so you can customize it like the first text. This code will work but you'll have to add every key combo line for line with IF statements. There's a better way for sure but hopefully this will get you started.

Code: Select all

;ShowOff.ahk
; Shows pushed down keys and buttons
;Skrommel @2005

#SingleInstance,Force
CoordMode,Mouse,Screen

applicationname=ShowOff

Gosub,TRAYMENU
Gosub,READINI
  
shiftkeys=
keys=

Gui,+Owner +AlwaysOnTop -Resize -SysMenu -MinimizeBox -MaximizeBox -Disabled -Caption -Border -ToolWindow
Gui,Margin,0,0
Gui,Color,%backcolor%
Gui,Font,C%fontcolor% S%fontsize% W%boldness%,%font%
Gui,Add,Text,Vtext,MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
Gui,Font
Gui,Font,C%fontcolor2% S%fontsize2% W%boldness2%,%font2%
Gui,Add,Text,Vtext2,`nMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
Gui,Show,X%statusx% Y%statusy% W%statuswidth% H%statusheight% NoActivate,%applicationname%
GuiControl,,text,
GuiControl,,text2,
WinSet,TransColor,000000,%applicationname% ; change TransColor to Transparent if you want that option in the INI settings file. TransColor allows the text to show up.

Loop
{
  oldkeys=%keys%
  keys=
  Loop,%keyarray0%
  {
    key:=keyarray%A_Index%
    StringTrimRight,key,key,1
    GetKeyState,state,%key%,P
    If state=D
	{
		keys=%keys% %key%
		if key = LButton
		{
			GuiControl,,text2,LButton does this action
			SetTimer,STATUSOFF,%timetoshow%
		}
	}
  }
  StringTrimRight,keys,keys,0
  If keys=%oldkeys%
    Continue

  oldshiftkeys=%shiftkeys%
  shiftkeys=%keys%
  StringReplace,shiftkeys,shiftkeys,LWin
  StringReplace,shiftkeys,shiftkeys,RWin
  StringReplace,shiftkeys,shiftkeys,LCtrl
  StringReplace,shiftkeys,shiftkeys,RCtrl
  StringReplace,shiftkeys,shiftkeys,LShift
  StringReplace,shiftkeys,shiftkeys,RShift
  StringReplace,shiftkeys,shiftkeys,LAlt
  StringReplace,shiftkeys,shiftkeys,RAlt
  StringReplace,shiftkeys,shiftkeys,AltGr
  StringReplace,shiftkeys,shiftkeys,%A_SPACE%,,All  
  If shiftkeys=
  If oldshiftkeys<>
    Continue

  If keys<>
  {
    GuiControl,,text,%keys%
    SetTimer,STATUSOFF,%timetoshow%
  }

  GetKeyState,mstate,LButton,P
  If mstate=D
  {
    MouseGetPos,mx1,my1,mid
    WinGetTitle,stitle,ahk_id %mid%
    If stitle=%applicationname%
    {
      Loop
      {
        MouseGetPos,mx2,my2
        WinGetPos,sx,sy,,,ahk_id %mid%
        sx:=sx-mx1+mx2
        sy:=sy-my1+my2
        WinMove,ahk_id %mid%,,%sx%,%sy%      
        mx1:=mx2
        my1:=my2
        GetKeyState,mstate,LButton,P
        If mstate=U
          Break
      } 
    }
  }
}


STATUSOFF:
GuiControl,,text,
GuiControl,,text2,
SetTimer,STATUSOFF,Off
Return


READINI:
IfNotExist,%applicationname%.ini
{
  inifile=;%applicationname%.ini
  inifile=%inifile%`n`;[Settings]
  inifile=%inifile%`n`;backcolor    000000-FFFFFF 
  inifile=%inifile%`n`;fontcolor    000000-FFFFFF
  inifile=%inifile%`n`;fontsize
  inifile=%inifile%`n`;boldness     1-1000   `;400=normal 700=bold
  inifile=%inifile%`n`;font
  inifile=%inifile%`n`;statusheight
  inifile=%inifile%`n`;statuswidth
  inifile=%inifile%`n`;statusx
  inifile=%inifile%`n`;statusy
  inifile=%inifile%`n`;relative     0-1       `;relative to 0=screen 1=active window
  inifile=%inifile%`n`;transparency 0-255,Off
  inifile=%inifile%`n`;timetohide             `;time in ms
  inifile=%inifile%`n
  inifile=%inifile%`n[Settings]
  inifile=%inifile%`nbackcolor=000000
  inifile=%inifile%`nfontcolor=FFFFFF
  inifile=%inifile%`nfontsize=20
  inifile=%inifile%`nboldness=800
  inifile=%inifile%`nfont=Arial
  inifile=%inifile%`nstatusheight=120
  inifile=%inifile%`nstatuswidth=500
  inifile=%inifile%`nstatusx=10
  inifile=%inifile%`nstatusy=10
  inifile=%inifile%`nrelative=1
  ;inifile=%inifile%`ntransparency=On *** LEAVE OFF TO HAVE A TRANSPARENT GUI BACKGROUND ***
  inifile=%inifile%`ntimetoshow=1000
  inifile=%inifile%`n
  inifile=%inifile%`nfontcolor2=FFAAAA
  inifile=%inifile%`nfontsize2=20
  inifile=%inifile%`nboldness2=800
  inifile=%inifile%`nfont2=Arial
  inifile=%inifile%`n
  inifile=%inifile%`nAppsKey`nLWin`nRWin`nLCtrl`nRCtrl`nLShift`nRShift`nLAlt`nRAlt`nAltGr
  inifile=%inifile%`nPrintScreen`nCtrlBreak`nPause`nBreak`nHelp`nBrowser_Back`nBrowser_Forward`nBrowser_Refresh`nBrowser_Stop`nBrowser_Search`nBrowser_Favorites`nBrowser_Home`nVolume_Mute`nVolume_Down`nVolume_Up`nMedia_Next`nMedia_Prev`nMedia_Stop`nMedia_Play_Pause`nLaunch_Mail`nLaunch_Media`nLaunch_App1`nLaunch_App2
  inifile=%inifile%`nF1`nF2`nF3`nF4`nF5`nF6`nF7`nF8`nF9`nF10`nF11`nF12`nF13`nF14`nF15`nF16`nF17`nF18`nF19`nF20`nF21`nF22`nF23`nF24
  inifile=%inifile%`nJoy1`nJoy2`nJoy3`nJoy4`nJoy5`nJoy6`nJoy7`nJoy8`nJoy9`nJoy10`nJoy11`nJoy12`nJoy13`nJoy14`nJoy15`nJoy16`nJoy17`nJoy18`nJoy19`nJoy20`nJoy21`nJoy22`nJoy23`nJoy24`nJoy25`nJoy26`nJoy27`nJoy28`nJoy29`nJoy30`nJoy31`nJoy32`nJoyX`nJoyY`nJoyZ`nJoyR`nJoyU`nJoyV`nJoyPOV
  inifile=%inifile%`nSpace`nTab`nEnter`nEscape`nBackspace`nDelete`nInsert`nHome`nEnd`nPgUp`nPgDn`nUp`nDown`nLeft`nRight`nScrollLock`nCapsLock
  inifile=%inifile%`nNumLock`nNumpadDiv`nNumpadMult`nNumpadAdd`nNumpadSub`nNumpadEnter`nNumpadDel`nNumpadIns`nNumpadClear`nNumpadDot`nNumpad0`nNumpad1`nNumpad2`nNumpad3`nNumpad4`nNumpad5`nNumpad6`nNumpad7`nNumpad8`nNumpad9
  inifile=%inifile%`nA`nB`nC`nD`nE`nF`nG`nH`nI`nJ`nK`nL`nM`nN`nO`nP`nQ`nR`nS`nT`nU`nV`nW`nX`nY`nZ`nÆ`nØ`nÅ`n1`n2`n3`n4`n5`n6`n7`n8`n9`n0`n```n`,`n`%`n+`n-`n*`n\`n/`n|`n_`n<`n^`n>`n!`n"`n#`n¤`n&`n(`n)`n=`n?`n´`n'`n¨`n~`n;`n:`n.`n@`n£`n$`n€`n§`nµ
  inifile=%inifile%`nLButton`nRButton`nMButton`nWheelDown`nWheelUp`nXButton1`nXButton2`n
  FileAppend,%inifile%,%applicationname%.ini
}

IniRead,backcolor,%applicationname%.ini,Settings,backcolor
IniRead,fontcolor,%applicationname%.ini,Settings,fontcolor
IniRead,fontsize,%applicationname%.ini,Settings,fontsize
IniRead,boldness,%applicationname%.ini,Settings,boldness
IniRead,font,%applicationname%.ini,Settings,font
IniRead,fontcolor2,%applicationname%.ini,Settings,fontcolor2
IniRead,fontsize2,%applicationname%.ini,Settings,fontsize2
IniRead,boldness2,%applicationname%.ini,Settings,boldness2
IniRead,font2,%applicationname%.ini,Settings,font2
IniRead,statusheight,%applicationname%.ini,Settings,statusheight
IniRead,statuswidth,%applicationname%.ini,Settings,statuswidth
IniRead,statusx,%applicationname%.ini,Settings,statusx
IniRead,statusy,%applicationname%.ini,Settings,statusy
IniRead,relative,%applicationname%.ini,Settings,relative
IniRead,transparency,%applicationname%.ini,Settings,transparency
IniRead,timetoshow,%applicationname%.ini,Settings,timetoshow
FileRead,inifile,%applicationname%.ini
StringSplit,keyarray,inifile,`n
inifile=
Return


TRAYMENU:
Menu,Tray,NoStandard
Menu,Tray,Add,%applicationname%,SETTINGS
Menu,Tray,Add,
Menu,Tray,Add,&Settings...,SETTINGS
Menu,Tray,Add,&About...,ABOUT
Menu,Tray,Add,E&xit,EXIT
Menu,Tray,Default,%applicationname%
Menu,Tray,Tip,%applicationname%
Return


SETTINGS:
Gosub,READINI
Run,%applicationname%.ini
Return


EXIT:
GuiClose:
ExitApp


ABOUT:
Gui,99:Destroy
Gui,99:Margin,20,20
Gui,99:Add,Picture,xm Icon1,%applicationname%.exe
Gui,99:Font,Bold
Gui,99:Add,Text,x+10 yp+10,%applicationname% v1.0
Gui,99:Font
Gui,99:Add,Text,y+10,Shows pushed down keys and buttons
Gui,99:Add,Text,y+5,- To change the look of the status window, edit the %applicationname%.ini
Gui,99:Add,Text,y+0,by rightclicking the tray menu and selecting Settings

Gui,99:Add,Picture,xm y+20 Icon5,%applicationname%.exe
Gui,99:Font,Bold
Gui,99:Add,Text,x+10 yp+10,1 Hour Software by Skrommel
Gui,99:Font
Gui,99:Add,Text,y+10,For more tools, information and donations, please visit 
Gui,99:Font,CBlue Underline
Gui,99:Add,Text,y+5 G1HOURSOFTWARE,www.1HourSoftware.com
Gui,99:Font

Gui,99:Add,Picture,xm y+20 Icon7,%applicationname%.exe
Gui,99:Font,Bold
Gui,99:Add,Text,x+10 yp+10,DonationCoder
Gui,99:Font
Gui,99:Add,Text,y+10,Please support the contributors at
Gui,99:Font,CBlue Underline
Gui,99:Add,Text,y+5 GDONATIONCODER,www.DonationCoder.com
Gui,99:Font

Gui,99:Add,Picture,xm y+20 Icon6,%applicationname%.exe
Gui,99:Font,Bold
Gui,99:Add,Text,x+10 yp+10,AutoHotkey
Gui,99:Font
Gui,99:Add,Text,y+10,This tool was made using the powerful
Gui,99:Font,CBlue Underline
Gui,99:Add,Text,y+5 GAUTOHOTKEY,www.AutoHotkey.com
Gui,99:Font

Gui,99:Show,,%applicationname% About
hCurs:=DllCall("LoadCursor","UInt",NULL,"Int",32649,"UInt") ;IDC_HAND
OnMessage(0x200,"WM_MOUSEMOVE") 
Return

1HOURSOFTWARE:
  Run,http://www.1hoursoftware.com,,UseErrorLevel
Return

DONATIONCODER:
  Run,http://www.donationcoder.com,,UseErrorLevel
Return

AUTOHOTKEY:
  Run,http://www.autohotkey.com,,UseErrorLevel
Return

99GuiClose:
  Gui,99:Destroy
  OnMessage(0x200,"")
  DllCall("DestroyCursor","Uint",hCur)
Return

WM_MOUSEMOVE(wParam,lParam)
{
  Global hCurs
  MouseGetPos,,,,ctrl
  If ctrl in Static9,Static13,Static17
    DllCall("SetCursor","UInt",hCurs)
  Return
}
Return

With the multiple displays you can try to specify which one to use with https://autohotkey.com/docs/commands/SysGet.htm
That seems like a Gui, Show, X Y issue though. I would set the ShowOff.ahk settings to something like X=500 Y=500 and shoot for the middle of your screen. I hope this helps.

EDIT:
Sorry about the double post.
howiesun
Posts: 13
Joined: 15 Dec 2017, 15:35

Re: OSD display trick!!!

18 Dec 2017, 11:30

can you help me piece these together?
Sorry i am not a programmer :P

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: doodles333, iamMG, Theda and 176 guests