Help with ControlSend to inactive window

Get help with using AutoHotkey and its commands and hotkeys
Poedre7
Posts: 1
Joined: 20 Jan 2019, 21:34

Help with ControlSend to inactive window

21 Jan 2019, 07:04

Hello i need help to work this scritp to inactive window using to Controlsend to Title window.

My script works fine but only in activewindow

Code: Select all

;   ,--------------------------------------.
;  | PoE TradeChannelAdvertisement by immo! |
;   `--------------------------------------´
;
; Version: v1.5g


#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Persistent ; Only the user can kill the application
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
StringCaseSense, On ; Match strings with case.
SetWorkingDir %A_ScriptDir%
CoordMode, ToolTip, Relative
CoordMode, Mouse, Screen
#MaxThreadsPerHotkey 2
SendMode Input
#UseHook
#InstallKeybdHook
; =[User config]=======================================
; Edit the following variables according to your needs!
; =====================================================

_tcaDuration = 1			; Time in minutes between each advertisement-loop!

_tcaStart = F12				; Hotkey to start advertising
			; Hotkey to pause advertising
			; Hotkey to exit script
_delay = 1777				; delay between each inputs (value gets automaticaly randomized)

_chans = 9				; Number of tradechannels you want to advertise at

; ================================================================
; DO NOT EDIT BELOW THIS LINE - UNLESS YOU KNOW WHAT YOU'RE DOING!
; ================================================================

; some needed calculations
_tcaDurationMS := ((_tcaDuration * 1000) * 60)

; Internal config
_scriptName =  TradeChannelAdvertisement
_scriptVer = v1.6
endchan := 1

; linking Hotkeys
Hotkey, %_tcaStart%, tcaStart



; poor method of "stopping" the script
^!F11::

; main Tradescript for advertising in an array of Tradechannels.
tcaStart:

TrayTip, Executing the Tradechannel advertisement! , Spamming advertisement every %_tcaDuration% minutes!`n`n%_scriptName%.%_scriptVer%, 2
Sleep, % Random(75,225)

SetTimer, tcaMain, %_tcaDurationMS%
tcaMain:
	
	TrayTip, Executing the advertisement! , Spamming advertisement on %_chans% channels!`n`n%_scriptName%.%_scriptVer%, 2

	; main loop
	Loop
	{
		; main advertising part
		Blockinput on
		if a_index > %_chans%
			break
		Sleep, % Random((_delay - 25),(_delay + 25)) 
		ControlSend,, {NumpadEnter},Path of Exile
		Blockinput off
		Sleep, % Random((_delay - 25),(_delay + 25))
		Blockinput on
		ControlSend,, {/}trade %a_index%,Path of Exile
		Blockinput off
		Sleep, % Random((_delay - 25),(_delay + 25))
		Blockinput on
		ControlSend,, {NumpadEnter},Path of Exile
		Blockinput off
		Sleep, % Random((_delay - 25),(_delay + 25)) 
		Blockinput on
		ControlSend,, {NumpadEnter},Path of Exile
		Blockinput off
		Sleep, % Random((_delay - 25),(_delay + 25))
		Blockinput on
		ControlSend,, {UP}{UP},Path of Exile
		Blockinput off
		Sleep, % Random((_delay - 25),(_delay + 25))
		Blockinput on
		ControlSend,, {NumpadEnter},Path of Exile
		Blockinput off
	}

	Blockinput on
	; joining next endchannel to not spam your advertisment twice in a vibrant channel
	Sleep, % Random((_delay - 25),(_delay + 25))
	Blockinput off
	Blockinput on
	ControlSend,, {NumpadEnter},Path of Exile
	Blockinput off
	Sleep, % Random((_delay - 25),(_delay + 25)) 
	Blockinput on
	ControlSend,, {/}trade %endchan%,Path of Exile
	Blockinput off
	Sleep, % Random((_delay - 25),(_delay + 25))
	Blockinput on
	ControlSend,, {NumpadEnter},Path of Exile
	Blockinput off
	Sleep, % Random((_delay - 25),(_delay + 25)) 
	Blockinput on
	ControlSend,, {NumpadEnter},Path of Exile
	Blockinput off
	Sleep, % Random((_delay - 25),(_delay + 25))
	Blockinput on
	ControlSend,, {UP}{UP},Path of Exile
	Blockinput off
	Sleep, % Random((_delay - 25),(_delay + 25)) 
	Blockinput on
	ControlSend,, {NumpadEnter},Path of Exile
	Blockinput off
	TrayTip, Finished advertising! , Next advertisement-loop in %_tcaDuration% minutes.`n`n%_scriptName%.%_scriptVer% > made by immo, 2 
	Sleep, % Random(75,225)
return
^F5::
	Blockinput on 
	TrayTip, Executing the Tradechannel advertisement! , Spamming advertisement every %_tcaDuration% minutes!`n`n%_scriptName%.%_scriptVer%, 2
	Sleep, % Random(75,225)	
	TrayTip, Executing the advertisement! , Spamming advertisement on %_chans% channels!`n`n%_scriptName%.%_scriptVer%, 2
	Blockinput on
	; main loop
	Loop
	{
		; main advertising part
		if a_index > %_chans%
			break
		Sleep, % Random((_delay - 25),(_delay + 25))
		Blockinput off
		Blockinput on
		ControlSend,, {NumpadEnter},Path of Exile
		Blockinput off
		Sleep, % Random((_delay - 25),(_delay + 25))
		Blockinput on
		ControlSend,, {/}trade %a_index%,Path of Exile
		Blockinput off
		Sleep, % Random((_delay - 25),(_delay + 25))
		Blockinput on
		ControlSend,, {NumpadEnter},Path of Exile
		Blockinput off
		Sleep, % Random((_delay - 25),(_delay + 25))
		Blockinput on
		ControlSend,, {NumpadEnter},Path of Exile
		Blockinput off
		Sleep, % Random((_delay - 25),(_delay + 25)) 
		Blockinput on
		ControlSend,, {UP}{UP},Path of Exile
		Blockinput off
		Sleep, % Random((_delay - 25),(_delay + 25))
		Blockinput on
		ControlSend,, {NumpadEnter},Path of Exile
		Blockinput off
	}

	Blockinput on
	; joining next endchannel to not spam your advertisment twice in a vibrant channel
	Sleep, % Random((_delay - 25),(_delay + 25))
	Blockinput off 
	Blockinput on
	ControlSend,, {NumpadEnter},Path of Exile
	Blockinput off
	Sleep, % Random((_delay - 25),(_delay + 25))
	Blockinput on
	ControlSend,, {/}trade %endchan%,Path of Exile
	Blockinput off
	Sleep, % Random((_delay - 25),(_delay + 25)) 
	Blockinput on
	ControlSend,, {NumpadEnter},Path of Exile
	Blockinput off
	Sleep, % Random((_delay - 25),(_delay + 25))
	Blockinput on
	ControlSend,, {NumpadEnter},Path of Exile
	Blockinput off
	Sleep, % Random((_delay - 25),(_delay + 25))
	Blockinput on
	ControlSend,, {UP}{UP},Path of Exile
	Blockinput off
	Sleep, % Random((_delay - 25),(_delay + 25))
	Blockinput on
	ControlSend,, {NumpadEnter},Path of Exile
	Blockinput off
	TrayTip, Finished advertising! , Next advertisement-loop in %_tcaDuration% minutes.`n`n%_scriptName%.%_scriptVer% > made by immo, 2 
	Sleep, % Random(75,225)
	
return

; randomization
Random(min,max) {
	Random, out, %min%, %max%
	return out
	}
; simple exit routine
tcaExit:
	TrayTip, , >> Terminating %_scriptName%.%_scriptVer%! <<, 2
	Sleep, % Random(775,2225)
	exitapp

return
Tab::
if A_IsPaused
{
	Blockinput on
	ControlSend,, {NumpadEnter},Path of Exile
	Blockinput off
	reload
}
return
F10:: Pause
Moderator Note: Added code tags and modified post title. ~ sinkfaze

Return to “Ask For Help”

Who is online

Users browsing this forum: Google [Bot], Gully, mtira, swagfag, TheMainEvent and 68 guests