Stop label/send keystrokes Topic is solved

Ask gaming related questions (AHK v1.1 and older)
Hajdes
Posts: 38
Joined: 30 Jul 2021, 17:29

Stop label/send keystrokes

06 Aug 2021, 09:45

Hello, I have in my script label which send keystrokes. Is it possible to after clicking F7 my label will stop or sending keystrokes in label will stop ? I will add that I tried to reload script after clicking F7 but after it my label was bugged is it any other way to do it ?
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Stop label/send keystrokes

06 Aug 2021, 09:49

You can reload, or add conditional statements that cause the routine to act according to a variable set by the hotkey.

You can post your script for feedback about it.
Hajdes
Posts: 38
Joined: 30 Jul 2021, 17:29

Re: Stop label/send keystrokes

06 Aug 2021, 10:45

mikeyww wrote:
06 Aug 2021, 09:49
You can reload, or add conditional statements that cause the routine to act according to a variable set by the hotkey.

You can post your script for feedback about it.
Can you write example how to do it with conditional statements?
Here is my code

Code: Select all

~F7::

return

Hotkey, %LabelKey%, Label

Label:
SoundBeep, 300, 100
Send {Down 5}{Enter}{Up 5}{Right}{Enter}
return
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Stop label/send keystrokes

06 Aug 2021, 11:15

Example of a hotkey toggle via different keys:

Code: Select all

LabelKey = F7
Gosub, F4

F3::   ; Disable F7
Hotkey, %LabelKey%, Off
SoundBeep, 1000
Return

F4::   ; Enable F7
Hotkey, %LabelKey%, Label, On
SoundBeep, 1500
Return

Label: ; Activated by F7
Send x
Return
Hajdes
Posts: 38
Joined: 30 Jul 2021, 17:29

Re: Stop label/send keystrokes

06 Aug 2021, 15:42

mikeyww wrote:
06 Aug 2021, 11:15
Example of a hotkey toggle via different keys:

Code: Select all

LabelKey = F7
Gosub, F4

F3::   ; Disable F7
Hotkey, %LabelKey%, Off
SoundBeep, 1000
Return

F4::   ; Enable F7
Hotkey, %LabelKey%, Label, On
SoundBeep, 1500
Return

Label: ; Activated by F7
Send x
Return

Ok but it will work (stop the label) during the label is sending keystrokes (turned on)?
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Stop label/send keystrokes

06 Aug 2021, 16:20

No, but here is a working approach to reloading.

Code: Select all

LabelKey = F7 ; F7 = Start the loop
Hotkey, %LabelKey%, Label, On
SoundBeep, 1500

F3::Reload    ; F3 = Stop the loop

Label:        ; Activated by F7
Loop {
 Send x
 Sleep, 100
}
Return
Hajdes
Posts: 38
Joined: 30 Jul 2021, 17:29

Re: Stop label/send keystrokes

06 Aug 2021, 17:50

mikeyww wrote:
06 Aug 2021, 16:20
No, but here is a working approach to reloading.

Code: Select all

LabelKey = F7 ; F7 = Start the loop
Hotkey, %LabelKey%, Label, On
SoundBeep, 1500

F3::Reload    ; F3 = Stop the loop

Label:        ; Activated by F7
Loop {
 Send x
 Sleep, 100
}
Return
But when I start label and during it is sending keystrokes I reload the script and when again I start the label it is sending random keystrokes what is the problem with it ?
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Stop label/send keystrokes

06 Aug 2021, 18:26

This script alone sends random key strokes? No other scripts are running? This is your exact code? What is an example of your output?
Hajdes
Posts: 38
Joined: 30 Jul 2021, 17:29

Re: Stop label/send keystrokes

07 Aug 2021, 08:08

mikeyww wrote:
06 Aug 2021, 18:26
This script alone sends random key strokes? No other scripts are running? This is your exact code? What is an example of your output?
Maybe not random but it isn't sending my combination (Send {Down 5}{Enter}{Up 5}{Right}{Enter}) it send only 2 last/ 1 last key/s no full combination, any ideas ? No other scripts on only it.

I run script,
1 time start label, during it reload script, 2 time start label it sends 1/2 last key/s from the combination not all keys. I write it if you don't understand line above :D
Last edited by Hajdes on 07 Aug 2021, 08:13, edited 1 time in total.
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Stop label/send keystrokes

07 Aug 2021, 08:12

Post your script here.
Hajdes
Posts: 38
Joined: 30 Jul 2021, 17:29

Re: Stop label/send keystrokes

07 Aug 2021, 08:19

mikeyww wrote:
07 Aug 2021, 08:12
Post your script here.

Code: Select all


LabelKey = Numpad0
LabelNumber = 10

#IfWinActive ahk_class grcWindow 
#IfWinActive, ahk_exe GTA5.exe

Hotkey, %LabelKey%, Label

Label:
SoundBeep, 300, 100
PhoneUp()		
Send {Right}{Up}{Enter}
a := 0
while(LabelNumber>a)
{
	Send {Up}
 	a := a+1
}
Send {Enter}
return

~BackSpace::
Reload
return

~RButton::
Reload
return

~Escape::
Reload
return

~m:: ;idk why it is black not red in code view
Reload
return

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Stop label/send keystrokes

07 Aug 2021, 08:31

I do not see a function here. You could try something like this:

Code: Select all

LabelKey := "Numpad0", LabelNumber := 10
Hotkey, If, WinActive("ahk_class grcWindow") || WinActive("ahk_exe GTA5.exe")
Hotkey, %LabelKey%, Label, On
Hotkey, If

~BackSpace::
~RButton::
~Escape::
~m::Reload

Label:
SoundBeep, 300, 100
PhoneUp()
Send {Right}{Up}{Enter}{Up %LabelNumber%}{Enter}
Return

#If WinActive("ahk_class grcWindow") || WinActive("ahk_exe GTA5.exe")
Hajdes
Posts: 38
Joined: 30 Jul 2021, 17:29

Re: Stop label/send keystrokes

07 Aug 2021, 08:39

mikeyww wrote:
07 Aug 2021, 08:31
I do not see a function here. You could try something like this:

Code: Select all

LabelKey := "Numpad0", LabelNumber := 10
Hotkey, If, WinActive("ahk_class grcWindow") || WinActive("ahk_exe GTA5.exe")
Hotkey, %LabelKey%, Label, On
Hotkey, If

~BackSpace::
~RButton::
~Escape::
~m::Reload

Label:
SoundBeep, 300, 100
PhoneUp()
Send {Right}{Up}{Enter}{Up %LabelNumber%}{Enter}
Return

#If WinActive("ahk_class grcWindow") || WinActive("ahk_exe GTA5.exe")
Oh yes I forgot about the function:

Code: Select all

Global PhoneDelay := 500

PhoneUp(){
Send {Up}
sleep, %PhoneDelay% 
} 
return
I will try and tell you is it work or no :D
Hajdes
Posts: 38
Joined: 30 Jul 2021, 17:29

Re: Stop label/send keystrokes

07 Aug 2021, 09:08

mikeyww wrote:
07 Aug 2021, 08:31
I do not see a function here. You could try something like this:

Code: Select all

LabelKey := "Numpad0", LabelNumber := 10
Hotkey, If, WinActive("ahk_class grcWindow") || WinActive("ahk_exe GTA5.exe")
Hotkey, %LabelKey%, Label, On
Hotkey, If

~BackSpace::
~RButton::
~Escape::
~m::Reload

Label:
SoundBeep, 300, 100
PhoneUp()
Send {Right}{Up}{Enter}{Up %LabelNumber%}{Enter}
Return

#If WinActive("ahk_class grcWindow") || WinActive("ahk_exe GTA5.exe")
First problem is that script work when the game is turned off, secound problem is that it do not reload script but open new (the same) script, but it is crazy because I have:

Code: Select all

#SingleInstance, Force
any ideas, I will add photo of it.
PHOTO OF START MENU BAR : https://zapodaj.net/5d0cce6799968.png.html

EDIT: When game is turned off rmb/esc/m/backspace reloads script but in game no
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Stop label/send keystrokes

07 Aug 2021, 09:22

If you want the context to apply to everything, you can do something like this. Adjust as needed.

Code: Select all

LabelKey := "Numpad0", LabelNumber := 10
Hotkey, %LabelKey%, Label, On

#If WinActive("ahk_class grcWindow") || WinActive("ahk_exe GTA5.exe")
~BackSpace::
~RButton::
~Escape::
~m::Reload

Label:
SoundBeep, 300, 100
PhoneUp()
Send {Right}{Up}{Enter}{Up %LabelNumber%}{Enter}
Return
Hajdes
Posts: 38
Joined: 30 Jul 2021, 17:29

Re: Stop label/send keystrokes

07 Aug 2021, 15:34

mikeyww wrote:
07 Aug 2021, 09:22
If you want the context to apply to everything, you can do something like this. Adjust as needed.

Code: Select all

LabelKey := "Numpad0", LabelNumber := 10
Hotkey, %LabelKey%, Label, On

#If WinActive("ahk_class grcWindow") || WinActive("ahk_exe GTA5.exe")
~BackSpace::
~RButton::
~Escape::
~m::Reload

Label:
SoundBeep, 300, 100
PhoneUp()
Send {Right}{Up}{Enter}{Up %LabelNumber%}{Enter}
Return
Ok now script work only in game but also it reloads until I click Numpad0, when I click it, and next RButton/esc/backspace/m label isn't stop working but script is opening the same script (again the same what above), and when the label is done, script is opening 2 * open scripts (if 3 scripts are open after label is done and if I reload it, it open another 3 scripts and now is 6 scripts open) where is problem? I thinked about clone this file but change name and after clicking rmb/esc/backspace/m it will be opening another file one and vice versa. What do you think about it if you understand it?
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Stop label/send keystrokes  Topic is solved

07 Aug 2021, 20:19

I do not understand it and cannot test it. My advice is to test your script in Notepad to see whether it works there. That will help you to understand whether the problem is the script or the game.

Of course, closing this script with the tray icon is tricky, because your right button is mapped. You might need a different method to close the script. It also seems apparent that you are not showing your entire script here.
Hajdes
Posts: 38
Joined: 30 Jul 2021, 17:29

Re: Stop label/send keystrokes

08 Aug 2021, 05:48

mikeyww wrote:
07 Aug 2021, 20:19
I do not understand it and cannot test it. My advice is to test your script in Notepad to see whether it works there. That will help you to understand whether the problem is the script or the game.

Of course, closing this script with the tray icon is tricky, because your right button is mapped. You might need a different method to close the script. It also seems apparent that you are not showing your entire script here.
Ok I made it and it work like that:

Code: Select all

#SingleInstance, Force
LabelKey = Numpad0
LabelNumber = 10

#IfWinActive ahk_class grcWindow 
#IfWinActive, ahk_exe GTA5.exe

Hotkey, %LabelKey%, Label

Label:
abc=1
SoundBeep, 300, 100
PhoneUp()		
Send {Right}{Up}{Enter}
a := 0
while(LabelNumber>a)
{
	Send {Up}
 	a := a+1
}
Send {Enter}
return

~RButton:: ;esc/backspace is the same code
if(abc=1) || (abc=2){
Run script.ahk
eksit()
return
}
return

eksit(){
	ExitApp
}
But I have got problem with my secound label it is more complicated and my idea don't work in it:

Code: Select all

Global PhoneDelay := 500
global k
global c:= false
global abc:= 0
LabelKeyB = Numpad1
LabelKeyC = Numpad2

Hotkey, %LabelKeyB%, LabelB
Hotkey, %LabelKeyC%, LabelC
return

#IfWinActive ahk_class grcWindow 
#IfWinActive, ahk_exe GTA5.exe

LabelB:
abc=2
SoundBeep, 300, 100
if(c=true){
if (true=k){ 
InteractionMenu()
Send {Down 5}{Enter}{Up 5}{Right}{Enter}
Send {m}    
}
else{
InteractionMenu()
Send {Down 4}{Enter}{Up 5}{Right}{Enter}
Send {m}    
}
}
else
MsgBox,, Script, ERROR, first use key: %LabelKeyC%

return	

LabelC:
SoundBeep, 300, 100
KMSS()
return

;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
KMSS(){
APZ()
MSGBox, 4, Script, Yes/No? 
IfMsgBox Yes
k := true
else
k := false
}
return
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
APZ(){
	c:=true
}
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
InteractionMenu(){
Send {m}
sleep, %PhoneDelay% 
} 
return
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
~RButton:: 
if(abc=1) || (abc=2){
Run script.ahk
eksit()
return
}
return

eksit(){
	ExitApp
}
Any ideas to repair it?
Last edited by Hajdes on 09 Aug 2021, 08:02, edited 4 times in total.
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Stop label/send keystrokes

08 Aug 2021, 06:10

What happens when you run the script? What should happen instead?
Hajdes
Posts: 38
Joined: 30 Jul 2021, 17:29

Re: Stop label/send keystrokes

08 Aug 2021, 06:26

mikeyww wrote:
08 Aug 2021, 06:10
What happens when you run the script? What should happen instead?
It is running normaly but the rmb/esc/backspace/m don't work, but when I put abc=2 1/2/3 line/s down script is going crazy he is sending msgbox after starting label

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 59 guests