Join 3 Scripts in one multi container. Topic is solved
Join 3 Scripts in one multi container.
Good morning, is possible join 3 Scripts in one multi script container and activate each one with Left arrow, Up arrow and Right arrow.
The 3 Scripts are similar, the main function of each differs only in time execution.
I like activate: Left Arrow (activate Script 1), Up Arrow (activate Script 2), Right Arrow (activate Script 3). Thanks.
Suspend
#NoEnv
#SingleInstance force
~LButton::RButton [[[ SCRIPT 1]]]
return
Home::Suspend
End::ExitApp
---------------
suspend
#NoEnv
#SingleInstance force
[[[ SCRIPT 2]]]
return
Home::Suspend
End::ExitApp
------------
suspend
#NoEnv
#SingleInstance force
[[[ SCRIPT 3]]]
return
Home::Suspend
End::ExitApp
The 3 Scripts are similar, the main function of each differs only in time execution.
I like activate: Left Arrow (activate Script 1), Up Arrow (activate Script 2), Right Arrow (activate Script 3). Thanks.
Suspend
#NoEnv
#SingleInstance force
~LButton::RButton [[[ SCRIPT 1]]]
return
Home::Suspend
End::ExitApp
---------------
suspend
#NoEnv
#SingleInstance force
[[[ SCRIPT 2]]]
return
Home::Suspend
End::ExitApp
------------
suspend
#NoEnv
#SingleInstance force
[[[ SCRIPT 3]]]
return
Home::Suspend
End::ExitApp
Last edited by AutoX on 15 May 2022, 20:26, edited 1 time in total.
Re: Helpl please, join 3 Scripts in one multi container. Topic is solved
Code: Select all
Left:: script = 1
Up:: script = 2
Right::script = 3
#If (script = 1)
LButton::RButton
#If (script = 2)
LButton::x
#If (script = 3)
LButton::y
#If
Re: Helpl please, join 3 Scripts in one multi container.
Thanks ahother question please: The container works perfectly but I can't "run only in the Game Window" (Game in Windowed mode 1024 x 768 not full screen). I added "#IfWinActive MyGame.exe" but Script also "run outside Game" (in all Windows system). How fix please Thank you.
Code: Select all
Suspend
#NoEnv
#SingleInstance force
#IfWinActive MyGame.exe <-- <-- <--
#IfWinActive <-- <-- <--
Left:: script = 1
Up:: script = 2
Right::script = 3
#If (script = 1)
~LButton::RButton
#If (script = 2)
Script 2
#If (script = 3)
Script 3
Home::Suspend
End::ExitApp
Re: Join 3 Scripts in one multi container.
Use a WinTitle instead of just a process name alone. https://www.autohotkey.com/docs/misc/WinTitle.htm#ahk_exe
Explained: #If
Code: Select all
winTitle = ahk_exe MyGame.exe
#If WinActive(winTitle)
Left:: script = 1
Up:: script = 2
Right::script = 3
#If WinActive(winTitle) && script = 1
LButton::RButton
#If WinActive(winTitle) && script = 2
LButton::x
#If WinActive(winTitle) && script = 3
LButton::y
#If
Like the #IfWin directives, #If is positional: it affects all hotkeys and hotstrings physically beneath it in the script. #If and #IfWin are also mutually exclusive; that is, only the most recent #If or #IfWin will be in effect.
Re: Join 3 Scripts in one multi container.
Thanks, but error continue. The objetive is Script runs only in the game (mode windowed, not full screen), but I go to desktop or another application and it continues run, even with this modification.
Code: Select all
Suspend
#NoEnv
#SingleInstance, force
winTitle = ahk_exe MyGame.exe
#If WinActive(winTitle)
Left:: script = 1
Up:: script = 2
Right::script = 3
#If WinActive(winTitle) && script = 1
Script 1
#If WinActive(winTitle) && script = 2
Script 2
#If WinActive(winTitle) && script = 3
Script 3
#If
Home::Suspend
Down::ExitApp
Re: Join 3 Scripts in one multi container.
You are showing just a script fragment, impossible to debug here. The window is checked only when the hotkey is triggered. You could run a SetTimer to check for changes, or use WinWaitActive.
#If applies only to hotstrings and hotkeys. See documentation.
#If applies only to hotstrings and hotkeys. See documentation.
Re: Join 3 Scripts in one multi container.
Sorry but i dont know how make run only in the game. I'll try to post on the forum.
Script complete is:
Script complete is:
Code: Select all
Suspend
#NoEnv
#SingleInstance, force
winTitle = ahk_exe MyGame.exe
#If WinActive(winTitle)
Left:: script = 1
Up:: script = 2
Right::script = 3
#If WinActive(winTitle) && script = 1
~LButton::RButton
Return
#If WinActive(winTitle) && script = 2
~RButton::LButton
Return
#If WinActive(winTitle) && script = 3
~LButton::
while GetKeyState("LButton", "P")
Send,{RButton Down}
KeyWait,LButton
Send,{RButton Up}
Return
Home::Suspend
Down::ExitApp
Re: Join 3 Scripts in one multi container.
After restoring the closing #If that I posted, I had no trouble with this in Notepad. Try it there to test it and see how it works.
Your final routine with While does not make sense to me. I am not sure of your intent there. Whether you intend a block is unclear. The role of KeyWait is also unclear to me.
Your final routine with While does not make sense to me. I am not sure of your intent there. Whether you intend a block is unclear. The role of KeyWait is also unclear to me.
Code: Select all
Suspend
winTitle = ahk_exe MyGame.exe
winTitle = ahk_exe notepad.exe
Home::Suspend
Down::ExitApp
#If WinActive(winTitle)
Left:: script = 1
Up:: script = 2
Right::script = 3
#If WinActive(winTitle) && script = 1
~LButton::RButton
#If WinActive(winTitle) && script = 2
~RButton::LButton
#If WinActive(winTitle) && script = 3
~LButton::
While GetKeyState("LButton", "P")
Click, R
Return
#If
Re: Join 3 Scripts in one multi container.
Thanks, it's still running outside game, Maybe Macros are the problem. Clicking outside Game macro don't stop, sometimes right click stop it outside but generally force close Script. I tried other options and don't work, just ~LButton::RButton work in my Game.
work ok in Game but run outside (no stop)
Code: Select all
~LButton::RButton
Re: Join 3 Scripts in one multi container.
You did not provide any information about use in Notepad, but if you are concurrently running any scripts, macros, keyboard or mouse software utilities, etc., they could conflict.