Stop label/send keystrokes Topic is solved

Ask gaming related questions (AHK v1.1 and older)
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Stop label/send keystrokes

08 Aug 2021, 06:46

This does not seem to be your real script. In any case, you can fix the flow. Read: #IfWinActive. It applies only to hotkeys & hotstrings. You would not have two of these directives on consecutive lines, because the first one would not have any effect. Shorten your script so that you can test the specific problem and fix it. You can expand from there.

Here is an example of how to use the directive: https://www.autohotkey.com/boards/viewtopic.php?p=414145#p414145
Hajdes
Posts: 38
Joined: 30 Jul 2021, 17:29

Re: Stop label/send keystrokes

09 Aug 2021, 07:56

Hajdes wrote:
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

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

#SingleInstance, Force
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?
I have made a mistake with copy secound script I saw it now, I repaird it
Hajdes
Posts: 38
Joined: 30 Jul 2021, 17:29

Re: Stop label/send keystrokes

09 Aug 2021, 08:03

mikeyww wrote:
08 Aug 2021, 06:46
This does not seem to be your real script. In any case, you can fix the flow. Read: #IfWinActive. It applies only to hotkeys & hotstrings. You would not have two of these directives on consecutive lines, because the first one would not have any effect. Shorten your script so that you can test the specific problem and fix it. You can expand from there.

Here is an example of how to use the directive: https://www.autohotkey.com/boards/viewtopic.php?p=414145#p414145
I can't post full code here because it has got 400 lines
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Stop label/send keystrokes

09 Aug 2021, 08:27

It sounds like you are all set for now. If you have follow-up questions, providing the following information will help at that time.

1. Relevant portion of the script, so that the reader can test it
2. Description of what actually happens when you run the script
3. Description of what should happen when you run the script (desired output, actions, effects, etc.)

I will let others reply to the new post, in case additional solutions are offered.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 63 guests