:*:]a::, :*:]b::, :*:c]::, ect. , without it counting as a hotkey. (Duplicate Hotkey Issue)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
hopit
Posts: 13
Joined: 11 May 2018, 19:59

:*:]a::, :*:]b::, :*:c]::, ect. , without it counting as a hotkey. (Duplicate Hotkey Issue)

26 May 2018, 13:29

I am making a script to type messages to my team faster in a particular game so that I can just push a letter and have it auto type the message. [Note I would prefer to use ControlSend if possible or some other option that locks it to the game window]. However i need some keys to have multiple options which would be toggleable with either shift and tab or a gui. I know how to set up both of those options but when I add in the hotkeys, regardless of the fact that they are in different gui button actions, it doesnt work and only uses the first one. Thus I need some way to have it replace a character with a short string of characters but not use a hotkeys for the individual letters them selves.
gregster
Posts: 9002
Joined: 30 Sep 2013, 06:48

Re: :*:]a::, :*:]b::, :*:c]::, ect. , without it counting as a hotkey. (Duplicate Hotkey Issue)

26 May 2018, 13:40

Please show your current code to illustrate the problem and describe the outcome you want to achieve referring to your actual code. This will usually speed up the problem solving process. It is not clear to me which "gui button actions" you refer to in this context.
Btw, what you are showing in the thread title are actually Hotstrings, not Hotkeys.
hopit
Posts: 13
Joined: 11 May 2018, 19:59

Re: :*:]a::, :*:]b::, :*:c]::, ect. , without it counting as a hotkey. (Duplicate Hotkey Issue)

26 May 2018, 13:54

gregster wrote:Please show your current code to illustrate the problem and describe the outcome you want to achieve referring to your actual code. This will usually speed up the problem solving process. It is not clear to me which "gui button actions" you refer to in this context.
Btw, what you are showing in the thread title are actually Hotstrings, not Hotkeys.

Code: Select all

sub1:
{
Gui, Destroy
IfWinExist %wintitle% 
loop
{
:*:a:: msg 1

}
}
return
;=============================================================================================
sub2:
{
Gui, Destroy
:*:a:: msg 2

}
return
;=============================================================================================
the problem is it ignores the button sub's entirely and runs when the script is run regardless of the button pressed, I have tested the button gui part with a simple msgbox and that works fine.
gregster
Posts: 9002
Joined: 30 Sep 2013, 06:48

Re: :*:]a::, :*:]b::, :*:c]::, ect. , without it counting as a hotkey. (Duplicate Hotkey Issue)

26 May 2018, 14:06

I am afraid that this snippet doesn't clear much up. I still see no GUI buttons anywhere. I guess that there might be more problems in the rest of the code.
But there seem to be structural problems in your script - trying to define hotstrings in a loop or in a subroutine doesn't make sense and will cause problems. There are created once for global use - as long as you don't define context-sensitive variants via #If directives, like #IfWinExist . It seems, you are trying to do something similar.

Under wihich circumstances should a send what?

Did you already have a look at the tutorial (the concept of context-sensitivity is mentioned there briefly) and the Usage and Syntax (left side) part of the docs? I would recommend to read - and work - through that. Also, looking at the code of solved threads could help to get a feeling for the general concepts of this script language.

But, I think you could still do better in describing your actual problem and the expected outcome, so that potential helpers have a better chance to understand what you are trying to do :!:
hopit
Posts: 13
Joined: 11 May 2018, 19:59

Re: :*:]a::, :*:]b::, :*:c]::, ect. , without it counting as a hotkey. (Duplicate Hotkey Issue)

26 May 2018, 14:34

gregster wrote:I am afraid that this snippet doesn't clear much up. I still see no GUI buttons anywhere. I guess that there might be more problems in the rest of the code.
But there seem to be structural problems in your script - trying to define hotstrings in a loop or in a subroutine doesn't make sense and will cause problems. There are created once for global use - as long as you don't define context-sensitive variants via #If directives, like #IfWinExist . It seems, you are trying to do something similar.

Under wihich circumstances should a send what?

Did you already have a look at the tutorial (the concept of context-sensitivity is mentioned there briefly) and the Usage and Syntax (left side) part of the docs? I would recommend to read - and work - through that. Also, looking at the code of solved threads could help to get a feeling for the general concepts of this script language.

But, I think you could still do better in describing your actual problem and the expected outcome, so that potential helpers have a better chance to understand what you are trying to do :!:
uh... yes I know i dont have the gui part included, the entire code is almost 400 lines so i only posted a small snippet. I need a way to make it so what when a specific button is pushed (and only then) every time a letter is pushed it is replaced with a message( eg: push a type message, puch b, type message. My entire script has alot of different functions and basically is just a large selection window to choose which one I want. I am trying to combine alot of scripts into one, however this one apparently requires some modifications.

edit: im not actualy sure what I was thinking about the loop part it was just for a test bit :D
gregster
Posts: 9002
Joined: 30 Sep 2013, 06:48

Re: :*:]a::, :*:]b::, :*:c]::, ect. , without it counting as a hotkey. (Duplicate Hotkey Issue)

26 May 2018, 15:10

Perhaps you mean something like this:

Code: Select all

Gui, new, +alwaysontop 
Gui, Add, Button, gSub1, Button 1
Gui, Add, Button, gSub2, Button 2
Gui, Show, x200 y200 w200 h200
Return 

sub1:
sub2:
toggle := A_thisLabel		; depending on the button that was pressed, the variable toggle gets a different value
;msgbox % toggle		; optional: check what is going on 
return

#If (toggle = "sub1")		; starts context-sensitivity
:*:a::msg 1
#If (toggle = "sub2")		; another context
:*:a::msg 2
#If					; stops context-sensitivity
Pushing button 1 or 2 has different effects on the text the hotstring a will create. If you are using just one character anyway, context-sensitive hotkeys and Send (or SendInput or another option) can be an alternative.
The existence of a window, for example, could be another context that could be defined.
hopit
Posts: 13
Joined: 11 May 2018, 19:59

Re: :*:]a::, :*:]b::, :*:c]::, ect. , without it counting as a hotkey. (Duplicate Hotkey Issue)

26 May 2018, 15:22

gregster wrote:Perhaps you mean something like this:

Code: Select all

Gui, new, +alwaysontop 
Gui, Add, Button, gSub1, Button 1
Gui, Add, Button, gSub2, Button 2
Gui, Show, x200 y200 w200 h200
Return 

sub1:
sub2:
toggle := A_thisLabel		; depending on the button that was pressed, the variable toggle gets a different value
;msgbox % toggle		; optional: check what is going on 
return

#If (toggle = "sub1")		; starts context-sensitivity
:*:a::msg 1
#If (toggle = "sub2")		; another context
:*:a::msg 2
#If					; stops context-sensitivity
Pushing button 1 or 2 has different effects on the text the hotstring a will create. If you are using just one character anyway, context-sensitive hotkeys and Send (or SendInput or another option) can be an alternative.
The existence of a window, for example, could be another context that could be defined.
hum that could work however I already have most of the other parts made already. Is their any way I could incorporate that in a way that it would work just under one of the sub's and not require me to change the other subs?

EDIT: so I could have hotstrings under just one of the subs

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: doodles333, mikeyww and 224 guests