Indicate on the screen Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Amanda
Posts: 18
Joined: 16 May 2018, 11:01

Indicate on the screen

25 Nov 2018, 14:49

Hi, I'm a Brazilian girl who does not speak English, so if something is written wrong, I'm sorry.

I wrote this message with 'Google Translate' and I already asked this question in the Portuguese forum, which is my language, but I did not get a satisfactory answer and I came here to ask in English.

My question

"Caps Lock", "Num Lock" and "Scroll Lock" are keys that light up lights on the keyboard to demonstrate when they are active, basically what I need is some visual indication on the computer screen when I press a key that has more than a function in the script.

Example:
  • Enter key maintains normal send function when "Scroll Lock" is off
  • Enter key writes a certain letter when "Scroll Lock" is active
I want to put a visual indication on the screen, very discreet and small, so I can know when the keys changed function, similar to the light that lights on the keyboard, but would be a visual indication on the screen.

I hope you can understand my doubt, thank you for reading.
🍀
User avatar
AlphaBravo
Posts: 467
Joined: 29 Sep 2013, 22:59

Re: Indicate on the screen

25 Nov 2018, 15:36

I suggest changing the script icon based on "Scroll Lock" state

Code: Select all

~CapsLock::
if GetKeyState("CapsLock", "T")
	Menu, Tray, Icon, icon1.ico
else
	Menu, Tray, Icon, icon2.ico
return
https://www.autohotkey.com/docs/commands/Menu.htm#Icon
Amanda
Posts: 18
Joined: 16 May 2018, 11:01

Re: Indicate on the screen

25 Nov 2018, 16:19

Hi, this appeared:

Error: Can't load icon.

Specifically: icon1.ico

Line#

001: Return
002: if GetKeyState("ScrollLock",'T')
---> 003: menu, Tray, Icon, icon1.ico
004: Else
005: Menu, Tray, Icon, icon2.ico
006: Return
007: Exit
008: Exit
008: Exit

The current thread will exit.
Last edited by Amanda on 26 Nov 2018, 16:31, edited 1 time in total.
🍀
Pepineros
Posts: 15
Joined: 16 Apr 2018, 17:26
Location: Ireland

Re: Indicate on the screen

25 Nov 2018, 16:41

Hi Amanda,

Your English is fine :)

You need the files called icon1.ico and icon2.ico in the working_dir of your script in order for AlphaBravo's code to work. You can make your own icons using MS Paint or download them online.

EDIT: you can name the .ico files whatever you want of course, just change the code accordingly.
Amanda
Posts: 18
Joined: 16 May 2018, 11:01

Re: Indicate on the screen

26 Nov 2018, 11:07

Thank you for your kindness and patience. ;)

From what I could understand, Pepineros, I can create my own icons and that's very cool.

AlphaBravo left a link in the above comment explaining the use of the Menu with AutoHotKey. I'm reading, but I'm not sure how to position the icon on the screen. Can I choose any place on the computer screen to place the icon?
🍀
User avatar
AlphaBravo
Posts: 467
Joined: 29 Sep 2013, 22:59

Re: Indicate on the screen

26 Nov 2018, 11:34

Amanda wrote:
26 Nov 2018, 11:07
Thank you for your kindness and patience. ;)

From what I could understand, Pepineros, I can create my own icons and that's very cool.

AlphaBravo left a link in the above comment explaining the use of the Menu with AutoHotKey. I'm reading, but I'm not sure how to position the icon on the screen. Can I choose any place on the computer screen to place the icon?
The icon is the main scrip icon in your desk top tray (usually bottom right) the little AHK (H).
CyL0N
Posts: 210
Joined: 27 Sep 2018, 09:58

Re: Indicate on the screen

26 Nov 2018, 12:38

Here's how AlphaBravo's script was meant to work...

Code: Select all

~CapsLock::
if GetKeyState(LTrim(A_ThisHotkey,"~"),"T")
	Menu, Tray, Icon, C:\Windows\System32\shell32.dll, 100
else
	Menu, Tray, Icon, C:\Windows\System32\shell32.dll, 3
return
But if that doesn't float your boat & you need a slightly more proactive signal on the screen,here...Script below flashes the entire taskbar on hotkey press...

Code: Select all

~CapsLock::FlashTaskBar()
~Ctrl::FlashTaskBar(2)

FlashTaskBar(reps:=1){
	BL := A_BatchLines
	SetBatchLines, -1
	Loop % reps{
		fadeIn := 250,fadeOut := 0
		Loop
			Winset, Transparent, % fadeIn--, ahk_class Shell_TrayWnd
		Until A_Index = 251
		Loop
			Winset, Transparent, % fadeOut++, ahk_class Shell_TrayWnd
		Until A_Index = 251
	}
	SetBatchLines, % BL
}
live ? long & prosper : regards
swagfag
Posts: 2981
Joined: 11 Jan 2017, 17:59

Re: Indicate on the screen

26 Nov 2018, 12:41

i mean strictly technically speaking u can place an icon on the screen anywhere u want:

Code: Select all

#NoEnv
#SingleInstance Force
SetBatchLines -1
CoordMode Mouse

Gui New, +AlwaysOnTop -Caption +Hwndhwnd
Gui Color, % color := 111000
Gui Add, Picture, , % A_AhkPath
Gui Show
WinSet TransColor, % color, % "ahk_id " hwnd

SetTimer Move, 10
Return

Move:
    MouseGetPos x, y
    Gui %hwnd%: Show, x%x% y%y%
Return

Escape::
GuiClose:
GuiEscape:
    ExitApp
CyL0N
Posts: 210
Joined: 27 Sep 2018, 09:58

Re: Indicate on the screen

26 Nov 2018, 12:46

swagfag wrote:
26 Nov 2018, 12:41
i mean strictly technically speaking u can place an icon on the screen anywhere u want:
:lol: :crazy: :lol: Oh,technicalities, whimsical little things...
live ? long & prosper : regards
Amanda
Posts: 18
Joined: 16 May 2018, 11:01

Re: Indicate on the screen

26 Nov 2018, 16:29

CyL0N, the correction you made in the AlphaBravo script is exactly what I'm looking for.
You understood my doubt. :)

Is it possible to take it out of the taskbar and choose another place on the screen?
The taskbar already helps me, but if I can choose the position would be perfect.
🍀
CyL0N
Posts: 210
Joined: 27 Sep 2018, 09:58

Re: Indicate on the screen

27 Nov 2018, 00:49

Rather basic, but You can move the icons anywhere,it should remember where the icons were last moved...just drag & drop...

EDIT: fixed win10 issue.

Code: Select all

~F2::
~NumLock::
if GetKeyState(LTrim(A_ThisHotkey,"~"),"T"){
	Menu, Tray, Icon, C:\Windows\System32\shell32.dll, 100
	ShowShell32Icon(100)
}else{
	Menu, Tray, Icon, C:\Windows\System32\shell32.dll, 3
	ShowShell32Icon(3)
}
return

ShowShell32Icon(iconIndex,xx:="", yy:=""){
	Static
	Global icIndex := iconIndex
	If (!xx || !yy){
		IniRead, xNy, %A_Temp%\persistentPos.ini, pPos, posLog%iconIndex%
		( xNy = "ERROR" || xNy = "|"? (xx:=100) & (yy:=100) : (xx:=StrSplit(xNy,"|")[1]) & (yy:=StrSplit(xNy,"|")[2]) )
	}
	Gui Destroy	;using it for least hastle...
	Gui +AlwaysOnTop -Caption +LastFound +ToolWindow
	Gui Color, Grey
	Gui Add, Picture, Icon%iconIndex%, %A_WinDir%\system32\SHELL32.dll
	WinSet, TransColor, Grey	;set gui transparency offscreen
	gui, show, x%xx% y%yy%, shell32iconGui
	OnMessage(0x201, "WM_LBUTTONDOWN")	;to allow mouse to drag gui
	Return
}

WM_LBUTTONDOWN(){	;to allow dragging icon
	Global icIndex
	PostMessage, 0xA1, 2
	While GetKeyState("LButton")
		sleep 10
	SoundBeep
	WinGetPos wX, wY,,, shell32iconGui
	IniWrite, % wX "|" wY, %A_Temp%\persistentPos.ini, pPos, posLog%icIndex%
}
Last edited by CyL0N on 28 Nov 2018, 07:49, edited 1 time in total.
live ? long & prosper : regards
Amanda
Posts: 18
Joined: 16 May 2018, 11:01

Re: Indicate on the screen

27 Nov 2018, 10:38

Yeah, CyL0N.

It worked on Windows 7 Ultimate 64 bits.

But...

In Windows 10 64 bits it is not working. :( I am using the latest version 1809 of Windows 10.
🍀
CyL0N
Posts: 210
Joined: 27 Sep 2018, 09:58

Re: Indicate on the screen  Topic is solved

28 Nov 2018, 07:50

Amanda wrote:
27 Nov 2018, 10:38
Yeah, CyL0N.

It worked on Windows 7 Ultimate 64 bits.

But...

In Windows 10 64 bits it is not working. :( I am using the latest version 1809 of Windows 10.
Fixed.

Code: Select all

~F2::
~NumLock::
if GetKeyState(LTrim(A_ThisHotkey,"~"),"T"){
	Menu, Tray, Icon, C:\Windows\System32\shell32.dll, 100
	ShowShell32Icon(100)
}else{
	Menu, Tray, Icon, C:\Windows\System32\shell32.dll, 3
	ShowShell32Icon(3)
}
return

ShowShell32Icon(iconIndex,xx:="", yy:=""){
	Static
	Global icIndex := iconIndex
	If (!xx || !yy){
		IniRead, xNy, %A_Temp%\persistentPos.ini, pPos, posLog%iconIndex%
		( xNy = "ERROR" || xNy = "|"? (xx:=100) & (yy:=100) : (xx:=StrSplit(xNy,"|")[1]) & (yy:=StrSplit(xNy,"|")[2]) )
	}
	Gui Destroy	;using it for least hastle...
	Gui +AlwaysOnTop -Caption +LastFound +ToolWindow
	Gui Color, Grey
	Gui Add, Picture, Icon%iconIndex%, %A_WinDir%\system32\SHELL32.dll
	WinSet, TransColor, Grey	;set gui transparency offscreen
	gui, show, x%xx% y%yy%, shell32iconGui
	OnMessage(0x201, "WM_LBUTTONDOWN")	;to allow mouse to drag gui
	Return
}

WM_LBUTTONDOWN(){	;to allow dragging icon
	Global icIndex
	PostMessage, 0xA1, 2
	While GetKeyState("LButton")
		sleep 10
	SoundBeep
	WinGetPos wX, wY,,, shell32iconGui
	IniWrite, % wX "|" wY, %A_Temp%\persistentPos.ini, pPos, posLog%icIndex%
}

Here's a script to select the icons from within the system,you really just need icon number it generates,plug that into the script as you need to...

Code: Select all

iconPath  = %A_WinDir%\System32\shell32.dll

MsgBox % clipboard := iconPath  . ", " . PickIconDlg() "`n`n COPIED TO CLIPBOARD!" 

PickIconDlg(IconPath:=""){		;gives dialog box to select icon and returns icon number upon selection
	shell32path = %A_WinDir%\System32\Shell32.dll
	IconPath := IconPath ? IconPath : shell32path    ;Path to any Dll
	;Index := 1                                  ;Pre-selected icon number
	Dlg := DllCall("Shell32.dll\PickIconDlg", "UInt", hWnd, "UInt*", "IconPath", "UInt", "PathSize", "Int*", Index)
	Return % Index += 1
}
live ? long & prosper : regards
Amanda
Posts: 18
Joined: 16 May 2018, 11:01

Re: Indicate on the screen

28 Nov 2018, 14:03

Thank you, CyL0N!

When can, if you want to take a look at another question of mine, please.
Forum: Screen margin (with scale change)
It is related to this indication indication on the screen with an icon, but in another way.

I say this because you have been able to help me once and maybe you can help me again.
Even if you can not help me again, I want to tell you that you were incredible in this answer! Thank you so much.

Image
🍀

Return to “Ask For Help”

Who is online

Users browsing this forum: aldrinjohnom, Bing [Bot], Bort P, DRocks, PENpal and 54 guests