Script will not work if not running twice
Script will not work if not running twice
I'm using a hotkey activated macro script to automate procedures in a program. If I only run one instance of the script, it does not work, if I run the same script under two different names simultaneously it works perfectly. Trying to figure out why.
Re: Script will not work if not running twice
Hard to guess what's the problem without seeing those scripts
Re: Script will not work if not running twice
Code: Select all
;
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: A.N.Other <[email protected]>
;
; Script Function:
; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;
;~ if not A_IsAdmin
;~ {
;~ Run *RunAs "%A_ScriptFullPath%" ; Requires v1.0.92.01+
;~ ExitApp
;~ }
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance,Force ;Only launch 1 instance of thise script.
#Persistent ;Will keep it running...
;;;;;;;;;;;;Hotkeys to help develop your code;;;;;;;;;;;;;;
^r::Reload ;This will reload this script
^e::Edit ;This will edit this script
;;;;;;;;;;;;Hotkeys:::::::::: Alt key is ! Windows key is #, Shift key is +, Control key is ^
+q:: ;Hotkey to trigger the keystrokes
Sleep, 1000
;Set Sparrow
SendInput +{d}
Sleep, 1000
SendInput {1}
Sleep, 1000
SendInput {1}
Sleep, 1000
SendInput {2}
Sleep, 1000
SendInput {2}
Sleep, 1000
SendInput {LCtrl down}{7}{LCtrl up}
Sleep, 1000
SendInput {LCtrl down}{7}{LCtrl up}
Sleep, 1000
SendInput {LCtrl down}{7}{LCtrl up}
Sleep, 1000
SendInput {LAlt down}{8}{LAlt up}
;Set AMRAAM
Sleep, 1000
SendInput +{w}
Sleep, 1000
SendInput {1}
Sleep, 1000
SendInput {1}
Sleep, 1000
SendInput {2}
Sleep, 1000
SendInput {1}
Sleep, 1000
SendInput {6}
Sleep, 1000
SendInput {LAlt down}{6}{LAlt up}
Sleep, 1000
SendInput {LCtrl down}{7}{LCtrl up}
Sleep, 1000
SendInput {LCtrl down}{7}{LCtrl up}
Sleep, 1000
SendInput {LCtrl down}{7}{LCtrl up}
Sleep, 1000
SendInput {LAlt down}{8}{LAlt up}
;Set Sidewinder
Sleep, 1000
SendInput +{s}
Sleep, 1000
SendInput {LAlt down}{7}{LAlt up}
Sleep, 1000
SendInput {LCtrl down}{7}{LCtrl up}
Sleep, 1000
SendInput {LCtrl down}{7}{LCtrl up}
Sleep, 1000
SendInput {LCtrl down}{7}{LCtrl up}
Sleep, 1000
SendInput {LAlt down}{8}{LAlt up}
Sleep, 1000
SendInput +{d}
Sleep, 1000
SendInput +{s}
Sleep, 1000
SendInput +{w}
;~ ;return ; Finishes the script action
Re: Script will not work if not running twice
So nothing? Can someone at least tell me what format or mechanism is used to send the hotkey command to Autohotkey and can it be changed?
Re: Script will not work if not running twice
For me your script works fine if I press +q. Without multiple scripts being running. So I don't know how to help you.
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.
Re: Script will not work if not running twice
I suggest trying simpler scripts with one or two hotkeys tied to a simple action, then slowly build it out to your full script until you see what addition causes it to fail as a single script.
Re: Script will not work if not running twice
Yeah, it's not really the script per say, it's getting the script macro to trigger. The running script isn't getting the hotkey input when in game unless I run two scripts. Could be a DirectX directinput issue but figured someone here might know more about it. What method or protocol is the hotkey sent to the script to activate the macro and can that protocol be changed to something else. You can send keystrokes from the script via different methods can you do the same for the hotkey that activates it?
Re: Script will not work if not running twice
Ususally @mikeyww sends users to read this topic at first.
How to Make AHK Work in Most Games - The Basics - AutoHotkey Community
How to Make AHK Work in Most Games - The Basics - AutoHotkey Community
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.