mouse button not recognized in gui hotkey

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

mouse button not recognized in gui hotkey

Post by ibieel » 27 Jan 2022, 17:33

hey guys, when i press XButton1 or XButton2 or WheelUp or WheelDown in interface "GUI, Add, Hotkey" is not recognized as a Hotkey.
is there any way I can make the GUI recognize the mouse as hotkey buttons?

User avatar
boiler
Posts: 16931
Joined: 21 Dec 2014, 02:44

Re: mouse button not recognized in gui hotkey

Post by boiler » 27 Jan 2022, 17:41

Gui, Add, Hotkey documentation wrote:The Hotkey control has limited capabilities. For example, it does not support mouse/joystick hotkeys or Win (LWin and RWin). One way to work around this is to provide one or more checkboxes as a means for the user to enable extra modifiers such as Win.

Besides the checkboxes for modifiers as suggested in the documentation quoted above, you could list other hotkeys such as the mouse buttons you mentioned in a DropDownList or other control.

amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: mouse button not recognized in gui hotkey

Post by amateur+ » 27 Jan 2022, 17:45

Code: Select all

#if MouseIsOverHotkeyControl()
WheelUp::
...
return

WheelDown::
...
return
...
#if

MouseIsOverHotkeyControl() {
	MouseGetPos...
	...
	return true or false
}
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.

User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

Re: mouse button not recognized in gui hotkey

Post by ibieel » 27 Jan 2022, 17:48

boiler wrote:
27 Jan 2022, 17:41
Gui, Add, Hotkey documentation wrote:The Hotkey control has limited capabilities. For example, it does not support mouse/joystick hotkeys or Win (LWin and RWin). One way to work around this is to provide one or more checkboxes as a means for the user to enable extra modifiers such as Win.

Besides the checkboxes for modifiers as suggested in the documentation quoted above, you could list other hotkeys such as the mouse buttons you mentioned in a DropDownList or other control.
I was wondering what would be the best way to do this...
maybe create a "Tab" in the GUI with a "RemapKeys Mouse"?
or else, always put a DropDownList next to each "Gui, Hotkey"?

what would be your idea?

User avatar
boiler
Posts: 16931
Joined: 21 Dec 2014, 02:44

Re: mouse button not recognized in gui hotkey

Post by boiler » 27 Jan 2022, 19:16

This is how I have done it before, with checkboxes for all of the modifier keys, a hotkey control for the main hotkey, and a dropdown list for mouse buttons and other keys not covered by the hotkey control:
hotkey settings.png
hotkey settings.png (7.63 KiB) Viewed 1245 times

User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

Re: mouse button not recognized in gui hotkey

Post by ibieel » 27 Jan 2022, 22:24

boiler wrote:
27 Jan 2022, 19:16
This is how I have done it before, with checkboxes for all of the modifier keys, a hotkey control for the main hotkey, and a dropdown list for mouse buttons and other keys not covered by the hotkey control:

hotkey settings.png
WOOOW, SUPER !!! :clap:
could you share your script? :shifty:

User avatar
boiler
Posts: 16931
Joined: 21 Dec 2014, 02:44

Re: mouse button not recognized in gui hotkey

Post by boiler » 27 Jan 2022, 23:31

It’s part of a much larger proprietary script, and if I pull that part out, it will just be some non-working controls. It wouldn’t be any more helpful than the picture and not worth the effort.

User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

Re: mouse button not recognized in gui hotkey

Post by ibieel » 27 Jan 2022, 23:36

boiler wrote:
27 Jan 2022, 23:31
It’s part of a much larger proprietary script, and if I pull that part out, it will just be some non-working controls. It wouldn’t be any more helpful than the picture and not worth the effort.
I already finished hehe, thank you very much. :dance:
image.png
image.png (4.35 KiB) Viewed 1164 times
would you have any tips to give me when building my GUI? I have a basic notion.
for example, I really liked putting the text in "Bold". it was a great idea

Code: Select all

Gui, font, bold
Gui, Add, Text, x50 y30 w25 h15 Center, Shift
Gui, Add, CheckBox, x55 y50 w25 h15 Center, 	;first checkbox Shift

Gui, font, bold
Gui, Add, Text, x80 y30 w25 h15 Center, Ctrl
Gui, Add, CheckBox, x85 y50 w25 h15 Center, 	;first checkbox Ctrl

Gui, font, bold
Gui, Add, Text, x110 y30 w25 h15 Center, Alt
Gui, Add, CheckBox, x115 y50 w25 h15 , 	;first checkbox Alt

Gui, font, bold
Gui, Add, Text, x140 y30 w60 h15 Center, Spell
Gui, font, norm
Gui, Add, Hotkey, x140 y48 w60 h20 , 	;first Hotkey Spell


Gui, font, bold
Gui, Add, Text, x205 y30 w60 h15 Center, Potions
Gui, font, norm
Gui, Add, Hotkey, x205 y48 w60 h20 , 	;first Hotkey Potion


Gui, Add, Text, x275 y50 w15 h15 Center, `or
Gui, font, bold
Gui, Add, Text, x295 y30 w80 h15 Center, Mouse/Others
Gui, font, norm
Gui, Add, DropDownList, x295 y48 w80 h20 r4, WheelUp|WheelDown|XButton1|XButton2

;GUI SHOW
Gui, Show, x409 y220 h379 w479, New GUI Window
Return

GuiClose:
ExitApp

User avatar
boiler
Posts: 16931
Joined: 21 Dec 2014, 02:44

Re: mouse button not recognized in gui hotkey

Post by boiler » 27 Jan 2022, 23:58

Unless I am totally missing what you are trying to do, I can’t see how what you have laid out makes sense logically. It looks like you want one hotkey for spells and another for potions, correct? If so, then how would you define one hotkey to be Ctrl+F1 and another to be Shift+Right Mouse Button? The way you have it, which one would the drop down list apply to? How could you choose separate items from the drop down list for both? How could you choose different modifier keys for each?

You would need separate rows for each like in the picture I showed. Each row is used to assign a hotkey for a different function. I just cut off the labels to the left of the controls in my picture. That’s where you would label one row “Spells” and another one “Potions.”

User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

Re: mouse button not recognized in gui hotkey

Post by ibieel » 28 Jan 2022, 00:39

boiler wrote:
27 Jan 2022, 23:58
Unless I am totally missing what you are trying to do, I can’t see how what you have laid out makes sense logically. It looks like you want one hotkey for spells and another for potions, correct? If so, then how would you define one hotkey to be Ctrl+F1 and another to be Shift+Right Mouse Button? The way you have it, which one would the drop down list apply to? How could you choose separate items from the drop down list for both? How could you choose different modifier keys for each?

You would need separate rows for each like in the picture I showed. Each row is used to assign a hotkey for a different function. I just cut off the labels to the left of the controls in my picture. That’s where you would label one row “Spells” and another one “Potions.”
it was just a draft hehe

User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

Re: mouse button not recognized in gui hotkey

Post by ibieel » 28 Jan 2022, 03:44

boiler wrote:
27 Jan 2022, 19:16
This is how I have done it before, with checkboxes for all of the modifier keys, a hotkey control for the main hotkey, and a dropdown list for mouse buttons and other keys not covered by the hotkey control:

hotkey settings.png
I won't need to use the "CheckBox" of Alt, Shift, Control.
I created a function to "format" the GUI Hotkey string so that ControlSend understands, take a look:
would change anything?

Code: Select all


#SingleInstance, Force
Gui, Add, Hotkey, w90 h20 vHotkeyGuiButton, +!F5
Gui, Show, w200 h200 Center,
GuiControlGet, HotkeyGuiButton
fix_Hotkey_to_ControlSend(HotkeyGuiButton, HotkeyControlSend)
;ControlSend,, %HotkeyControlSend%, ahk_id 0x010101
MsgBox, HotkeyGuiButton is: %HotkeyGuiButton% `nHotkeyControlSend is: %HotkeyControlSend%
RETURN


; returns a string correctly to insert into "ControlSend"
fix_Hotkey_to_ControlSend(HotkeyGuiButton, ByRef HotkeyControlSend) {
;Global
	;StringGetPos, pos, Haystack, %Needle%
	ShiftString := "+"
	ControlString := "^"
	AltString := "!"
	
	PosTransformHotkeyControlSend := 0
	;[Search for a String Shift]
	StringGetPos, SearchShiftString, HotkeyGuiButton, %ShiftString%	;position start ZERO	
	if (SearchShiftString >= 0) {			;if found string
		PosTransformHotkeyControlSend++		;usage in transform string
	}
	
	;[Search for a String Control]
	StringGetPos, SearchControlString, HotkeyGuiButton, %ControlString%
	if (SearchControlString >= 0) {
		PosTransformHotkeyControlSend++		;usage in transform string
	}
	
	;[Search for a String Alt]
	StringGetPos, SearchAltString, HotkeyGuiButton, %AltString%
	if (SearchAltString >= 0) {
		PosTransformHotkeyControlSend++ 	;usage in transform string
	}
	
	;[Transform em String]
	if (PosTransformHotkeyControlSend > 0) {
		HotkeyControlSend := SubStr(HotkeyGuiButton, 1, PosTransformHotkeyControlSend) . "{" . SubStr(HotkeyGuiButton, PosTransformHotkeyControlSend+1, StrLen(HotkeyGuiButton)) . "}"
		return
	} else {
		HotkeyControlSend := "{" . HotkeyGuiButton . "}"
		return
	}
	
}



User avatar
boiler
Posts: 16931
Joined: 21 Dec 2014, 02:44

Re: mouse button not recognized in gui hotkey

Post by boiler » 28 Jan 2022, 06:29

Yes, I would use the return value of the function instead of ByRef, and I would use RegEx:

Code: Select all

#SingleInstance, Force
Gui, Add, Hotkey, w90 h20 vHotkeyGuiButton, +!F5
Gui, Show, w200 h200 Center,
GuiControlGet, HotkeyGuiButton
HotkeyControlSend := fix_Hotkey_to_ControlSend(HotkeyGuiButton)
;ControlSend,, %HotkeyControlSend%, ahk_id 0x010101
MsgBox, HotkeyGuiButton is: %HotkeyGuiButton% `nHotkeyControlSend is: %HotkeyControlSend%
RETURN

; returns a string correctly to insert into "ControlSend"
fix_Hotkey_to_ControlSend(hotkeyGB) {
	return RegExReplace(hotkeyGB, "([!+^]*)(.+)", "$1{$2}")
}

User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

Re: mouse button not recognized in gui hotkey

Post by ibieel » 28 Jan 2022, 06:56

boiler wrote:
28 Jan 2022, 06:29
Yes, I would use the return value of the function instead of ByRef, and I would use RegEx:

Code: Select all

#SingleInstance, Force
Gui, Add, Hotkey, w90 h20 vHotkeyGuiButton, +!F5
Gui, Show, w200 h200 Center,
GuiControlGet, HotkeyGuiButton
HotkeyControlSend := fix_Hotkey_to_ControlSend(HotkeyGuiButton)
;ControlSend,, %HotkeyControlSend%, ahk_id 0x010101
MsgBox, HotkeyGuiButton is: %HotkeyGuiButton% `nHotkeyControlSend is: %HotkeyControlSend%
RETURN

; returns a string correctly to insert into "ControlSend"
fix_Hotkey_to_ControlSend(hotkeyGB) {
	return RegExReplace(hotkeyGB, "([!+^]*)(.+)", "$1{$2}")
}
wtf?! its a magic
I didn't understand how the "Haystack" was used. where can i learn about?


amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: mouse button not recognized in gui hotkey

Post by amateur+ » 28 Jan 2022, 10:26

boiler wrote:
28 Jan 2022, 06:29

Code: Select all

fix_Hotkey_to_ControlSend(hotkeyGB) {
	return RegExReplace(hotkeyGB, "([!+^]*)(.+)", "$1{$2}")
}
Ahahah! That is called "experience".
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.

User avatar
boiler
Posts: 16931
Joined: 21 Dec 2014, 02:44

Re: mouse button not recognized in gui hotkey

Post by boiler » 28 Jan 2022, 10:43

amateur+ wrote: Ahahah! That is called "experience".
Aka, "old". :D

Post Reply

Return to “Ask for Help (v1)”