Page 1 of 1
Merging two scripts in one file
Posted: 03 Dec 2018, 09:32
by wise_mike
I have 2 scripts I want to merge in one file, however when I put them together, only the first one gets executed:
Script 1:
Code: Select all
#if WinActive("ahk_exe program.EXE")
#Persistent
Loop
{
WinWaitActive, Wizard
Send, !{F4}
}
Return
Script 2:
Code: Select all
#if WinActive("ahk_exe program2.EXE")
#Persistent
Loop
{
WinWait, ahk_class bosa_sdm_Mso96
; IfWinNotActive, ahk_class bosa_sdm_Mso96, ,WinActivate, ahk_class bosa_sdm_Mso96
; WinWaitActive, ahk_class bosa_sdm_Mso96
; Sleep, 0
ControlMove, RichEdit20W6, 20, 850, 750, 25 ;Adress box
ControlMove, SysTreeView321, , , 800, 700
ControlMove, TreeViewCFParent1, , , 1000, 700
ControlMove, SysTreeView322, , , 800, 700
ControlMove, TreeViewParent1, , , 760, 940
WinMove, ahk_class bosa_sdm_Mso96, , 600, 50, 1000, 900 ; 900 width
}
Return
Re: Merging two scripts in one file
Posted: 03 Dec 2018, 10:25
by hymal7
try this maybe?
Code: Select all
#Persistent
#if WinActive("ahk_exe program.EXE")
Loop
{
WinWaitActive, Wizard
Send, !{F4}
}
#if WinActive("ahk_exe program2.EXE")
Loop
{
WinWait, ahk_class bosa_sdm_Mso96
; IfWinNotActive, ahk_class bosa_sdm_Mso96, ,WinActivate, ahk_class bosa_sdm_Mso96
; WinWaitActive, ahk_class bosa_sdm_Mso96
; Sleep, 0
ControlMove, RichEdit20W6, 20, 850, 750, 25 ;Adress box
ControlMove, SysTreeView321, , , 800, 700
ControlMove, TreeViewCFParent1, , , 1000, 700
ControlMove, SysTreeView322, , , 800, 700
ControlMove, TreeViewParent1, , , 760, 940
WinMove, ahk_class bosa_sdm_Mso96, , 600, 50, 1000, 900 ; 900 width
}
Return
Re: Merging two scripts in one file
Posted: 03 Dec 2018, 10:33
by wise_mike
No, not working.
Re: Merging two scripts in one file
Posted: 03 Dec 2018, 10:48
by hymal7
try
IfWinactive, ahk_exe program.EXE
also try removing the loop
Re: Merging two scripts in one file
Posted: 03 Dec 2018, 10:51
by wise_mike
Neither working, sorry.
Re: Merging two scripts in one file
Posted: 03 Dec 2018, 14:33
by oif2003
Hi, if you want to use loops then you will need to merge them and check for windows activation inside the loops, otherwise it gets stuck in the first loop that meets the conditions.
Re: Merging two scripts in one file
Posted: 03 Dec 2018, 14:42
by wise_mike
Thanks, can you edit the script as suggested? I tried removing both the loops, but I think I am doing something wrong.
Re: Merging two scripts in one file
Posted: 03 Dec 2018, 14:48
by oif2003
Untested
Code: Select all
Loop
{
if WinActive("ahk_exe program.EXE")
{
WinWaitActive, Wizard
Send, !{F4}
}
else if WinActive("ahk_exe program2.EXE")
{
WinWait, ahk_class bosa_sdm_Mso96
; IfWinNotActive, ahk_class bosa_sdm_Mso96, ,WinActivate, ahk_class bosa_sdm_Mso96
; WinWaitActive, ahk_class bosa_sdm_Mso96
; Sleep, 0
ControlMove, RichEdit20W6, 20, 850, 750, 25 ;Adress box
ControlMove, SysTreeView321, , , 800, 700
ControlMove, TreeViewCFParent1, , , 1000, 700
ControlMove, SysTreeView322, , , 800, 700
ControlMove, TreeViewParent1, , , 760, 940
WinMove, ahk_class bosa_sdm_Mso96, , 600, 50, 1000, 900 ; 900 width
}
sleep 100 ;change it to whatever duration you deem fit
}
Re: Merging two scripts in one file
Posted: 03 Dec 2018, 15:14
by wise_mike
It worked for the first executed program only, but no the other.
Re: Merging two scripts in one file
Posted: 03 Dec 2018, 15:16
by oif2003
I see. Perhaps something is wrong with the conditions for program2 or there is an error in that block of code. Put and msgbox in it to see if it even executes, and if it does you will have to check the rest of that code block for errors.
Re: Merging two scripts in one file
Posted: 03 Dec 2018, 15:22
by wise_mike
OK, thanks a lot..