Stop label/send keystrokes Topic is solved
Stop label/send keystrokes
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 ?
Re: Stop label/send keystrokes
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.
You can post your script for feedback about it.
Re: Stop label/send keystrokes
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
Re: Stop label/send keystrokes
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
Re: Stop label/send keystrokes
mikeyww wrote: ↑06 Aug 2021, 11:15Example 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)?
Re: Stop label/send keystrokes
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
Re: Stop label/send keystrokes
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 ?mikeyww wrote: ↑06 Aug 2021, 16:20No, 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
Re: Stop label/send keystrokes
This script alone sends random key strokes? No other scripts are running? This is your exact code? What is an example of your output?
Re: Stop label/send keystrokes
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
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
Last edited by Hajdes on 07 Aug 2021, 08:13, edited 1 time in total.
Re: Stop label/send keystrokes
Post your script here.
Re: Stop label/send keystrokes
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
Re: Stop label/send keystrokes
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")
Re: Stop label/send keystrokes
Oh yes I forgot about the function:mikeyww wrote: ↑07 Aug 2021, 08:31I 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")
Code: Select all
Global PhoneDelay := 500
PhoneUp(){
Send {Up}
sleep, %PhoneDelay%
}
return
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
Re: Stop label/send keystrokes
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:mikeyww wrote: ↑07 Aug 2021, 08:31I 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")
Code: Select all
#SingleInstance, Force
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
Re: Stop label/send keystrokes
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
Re: Stop label/send keystrokes
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?mikeyww wrote: ↑07 Aug 2021, 09:22If 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
Re: Stop label/send keystrokes Topic is solved
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.
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.
Re: Stop label/send keystrokes
Ok I made it and it work like that:mikeyww wrote: ↑07 Aug 2021, 20:19I 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.
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
}
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
}
Last edited by Hajdes on 09 Aug 2021, 08:02, edited 4 times in total.
Re: Stop label/send keystrokes
What happens when you run the script? What should happen instead?
Who is online
Users browsing this forum: blackbook7777, Google [Bot] and 83 guests