Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monitor Off/On Button? #295

Closed
Raychan87 opened this issue Apr 27, 2023 · 9 comments
Closed

Monitor Off/On Button? #295

Raychan87 opened this issue Apr 27, 2023 · 9 comments

Comments

@Raychan87
Copy link

Thank you for the nice tool.

Unfortunately, the G14 does not have a standard button to turn the monitor on and off.

Currently I use "Dekisoft Monitor Off" with a button combination. Is it possible to add such a function for the M3/M4 button?

If it is not possible or too complicated. How do I put a key combination like "CTRL+ALT+Y" on M3?

@seerge
Copy link
Owner

seerge commented Apr 27, 2023

@Raychan87 - since you already use app for that, i think it will be easier to bind a key. You can't bind a combination at the moment, but what you can do - is trigger some exotic keypress for M3/M4 like F13 (that doesn't even exist on default keyboard)

It's explained at https://github.com/seerge/g-helper#custom-hotkey-actions

Full list of codes that you can use is here https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes

Then you can setup your Dekisoft Monitor Off to listen for that combination i think ? :)

@Raychan87
Copy link
Author

Thank you very much for your answer.

Unfortunately, in Dekisoft Monitor Off you can't set F keys.
I also wanted to use the script function, but unfortunately the custom function does not work.
When I type "notepad" as in your example, Notepad also opens, but any path with an "exe" or "bat" does not work.

i use the g-helper v0,55.

config.json:
"m3_custom": "C:\Windows-Extras\Programme\MonitorOff.Bat",
"m3": "custom",
"m4_custom": ""

@seerge
Copy link
Owner

seerge commented Apr 29, 2023

Cause to run bat you need to tell windows with what to execute it, try

cmd.exe /c C:\Windows-Extras\Programme\MonitorOff.Bat

@Raychan87
Copy link
Author

Raychan87 commented Apr 29, 2023

Unfortunately, does not work either.

even if I only enter "cmd.exe" nothing happens.

here is the log:
29.04.2023 11:00:29: WMI event 56
29.04.2023 11:00:42: WMI event 124
29.04.2023 11:00:49: WMI event 56
29.04.2023 11:00:50: WMI event 56
29.04.2023 11:00:52: WMI event 124
29.04.2023 11:00:53: WMI event 124
29.04.2023 11:00:54: WMI event 124
29.04.2023 11:00:54: WMI event 124
29.04.2023 11:00:54: WMI event 124
29.04.2023 11:01:18: WMI event 124
29.04.2023 11:01:18: Failed to run cmd.exe /c C:\Windows-Extras\Programme\MonitorOff.Bat
29.04.2023 11:01:19: WMI event 124
29.04.2023 11:01:19: Failed to run cmd.exe /c C:\Windows-Extras\Programme\MonitorOff.Bat
29.04.2023 11:01:20: WMI event 56
29.04.2023 11:01:20: WMI event 124
29.04.2023 11:01:20: Failed to run cmd.exe /c C:\Windows-Extras\Programme\MonitorOff.Bat
29.04.2023 11:01:21: WMI event 124
29.04.2023 11:01:21: Failed to run cmd.exe /c C:\Windows-Extras\Programme\MonitorOff.Bat

@seerge
Copy link
Owner

seerge commented Apr 29, 2023

@Raychan87 this build should fix cmd running

Also i have simply added Laptop Screen option in dropdown that should toggle screen on / off

GHelper.zip

@Raychan87
Copy link
Author

Raychan87 commented Apr 29, 2023

cmd works now, thanks :)

The new function "Laptop Screen" does not work on my Asus G14 GA401QM 2021 with Windows 11 22H2.
What kind of command do you use?

My batch file has the command:

powershell (Add-Type '[DllImport("user32.dll")]^public static extern int PostMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::PostMessage(-1,0x0112,0xF170,2)

@seerge
Copy link
Owner

seerge commented Apr 29, 2023

@Raychan87 i use same, strange it doesn't work

    public const int WM_SYSCOMMAND = 0x0112;
    public const int SC_MONITORPOWER = 0xF170;
    public const int MONITOR_ON = -1;
    public const int MONITOR_OFF = 2;
    public const int MONITOR_STANDBY = 1;

    public static void ToggleMonitor()
    {
        SendMessage(-1, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF);
    }

@seerge
Copy link
Owner

seerge commented Apr 29, 2023

GHelper.zip
Try this one

@Raychan87
Copy link
Author

Yes, now it works. Thanks a lot :)

Wish you still a nice weekend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants