Script working on background. Help

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
macrotec
Posts: 1
Joined: 19 Jul 2017, 21:57

Script working on background. Help

19 Jul 2017, 22:09

Hi I have a script that is working fine. I use chrome access a website and run the script just fine.
My questions are:
1. Is it possible for it to run on the background while I work in other stuff ?
2. If #1 can be done. Is it possible to open different chrome windows and run the script on each window ?

//I did the following on a Macro Creator

Please help me with the script.

Code: Select all

#NoEnv
SetWorkingDir %A_ScriptDir%
CoordMode, Mouse, Window
SendMode Input
#SingleInstance Force
SetTitleMatchMode 2
#WinActivateForce
SetControlDelay 1
SetWinDelay 0
SetKeyDelay -1
SetMouseDelay -1
SetBatchLines -1


UserAccount1 := {email: "*****@gmail.com", sendpassword: "*****1", sendusername: "*******@gmail.com", sendusing: 2, smtpauthenticate: 1, smtpconnectiontimeout: 30, smtpserver: "smtp.gmail.com", smtpserverport: 465, smtpusessl: 1}
Pause::Pause
^!r::
Macro1:
Loop
{
	Sleep, 3000
	Click, 97, 163 Left, 1  ; Click Refresh
	Sleep, 10
	CoordMode, Pixel, Window
	ImageSearch, FoundX, FoundY, 589, 105, 1245, 302, C:\Users\gchiham\AppData\Roaming\MacroCreator\Screenshots\Screen_20170718214446.png
	CenterImgSrchCoords("C:\Users\gchiham\AppData\Roaming\MacroCreator\Screenshots\Screen_20170718214446.png", FoundX, FoundY)
	If ErrorLevel = 0
		Click, %FoundX%, %FoundY% Left, 1  ; Search OK
	Sleep, 5
	Sleep, 3000
	Loop
	{
		CoordMode, Pixel, Window
		ImageSearch, FoundX, FoundY, 119, 238, 1684, 403, C:\Users\gchiham\AppData\Roaming\MacroCreator\Screenshots\Screen_20170718201421.png
		CenterImgSrchCoords("C:\Users\gchiham\AppData\Roaming\MacroCreator\Screenshots\Screen_20170718201421.png", FoundX, FoundY)
		If ErrorLevel = 0
			Click, %FoundX%, %FoundY% Left, 1  ; Search Green
		Sleep, 2
	}
	Until ErrorLevel
	CoordMode, Pixel, Window
	PixelSearch, 906, 413, 116, 233, 1685, 405, 0xF49346, 0, Fast RGB
	If ErrorLevel = 0
		{
		Click, 906, 413 Left, 1  ; Search Greens Selected; Submit
		SoundPlay, C:\Users\gchiham\Downloads\Train Whistle-SoundBible.com-458982136.mp3
		MsgBody = Intervalos Capturados
		CDO(UserAccount1, "******@gmail.com", "Intervalos Capturados", MsgBody, 0)
		Sleep, 2000
		}
	PixelSearch, 906, 413, 116, 233, 1685, 405, 0x247192, 0, Fast RGB
	If ErrorLevel = 0
		{
		Click, 906, 413 Left, 1  ; Search Greens Selected; Submit
		SoundPlay, C:\Users\gchiham\Downloads\Train Whistle-SoundBible.com-458982136.mp3
		MsgBody = Intervalos Capturados
		CDO(UserAccount1, "*******@gmail.com", "Intervalos Capturados", MsgBody, 0)
		Sleep, 2000
		}
	CoordMode, Pixel, Window
	ImageSearch, FoundX, FoundY, 589, 105, 1245, 302, C:\Users\gchiham\AppData\Roaming\MacroCreator\Screenshots\Screen_20170718214446.png
	CenterImgSrchCoords("C:\Users\gchiham\AppData\Roaming\MacroCreator\Screenshots\Screen_20170718214446.png", FoundX, FoundY)
	If ErrorLevel = 0
		Click, %FoundX%, %FoundY% Left, 1  ; Search OK
	Sleep, 5
}
Return


CDO(Account, To, Subject := "", Msg := "", Html := false, Attach := "", CC := "", BCC := "")
{
	MsgObj			:= ComObjCreate("CDO.Message")
	MsgObj.From		:= Account.email
	MsgObj.To		:= StrReplace(To, ",", ";")
	MsgObj.BCC		:= StrReplace(BCC, ",", ";")
	MsgObj.CC		:= StrReplace(CC, ",", ";")
	MsgObj.Subject	:= Subject

	If (Html)
		MsgObj.HtmlBody	:= Msg
	Else
		MsgObj.TextBody	:= Msg

	Schema	:= "http://schemas.microsoft.com/cdo/configuration/"
	Pfld	:= MsgObj.Configuration.Fields

	For Field, Value in Account
		(Field != "email") ? Pfld.Item(Schema . Field) := Value : ""
	Pfld.Update()

	Attach := StrReplace(Attach, ",", ";")
	Loop, Parse, Attach, `;, %A_Space%%A_Tab%
		MsgObj.AddAttachment(A_LoopField)

	MsgObj.Send()
}

CenterImgSrchCoords(File, ByRef CoordX, ByRef CoordY)
{
	static LoadedPic
	LastEL := ErrorLevel
	Gui, Pict:Add, Pic, vLoadedPic, %File%
	GuiControlGet, LoadedPic, Pict:Pos
	Gui, Pict:Destroy
	CoordX += LoadedPicW // 2
	CoordY += LoadedPicH // 2
	ErrorLevel := LastEL
}
Thank You

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], drlvanb, serenite and 393 guests