I need the following:
1. Script should wait till a program(notepad editor of windows) opening a error log window
2. Script should close error log window or ending the process (whatever is easier)
3. Script should start a program and there it should click "start" I guess it will needing coordinates to click the correct button
4. After the start button got clicked successfully the script should go again in standby till the next error log window comes up and then do the steps from 2-4 again
Help needed
Re: Help needed
I hope this nearly-pseudo-code helps.
Code: Select all
/*
1. Script should wait till a program(notepad editor of windows) opening a error log window
2. Script should close error log window or ending the process (whatever is easier)
3. Script should start a program
and there it should click "start"
I guess it will needing coordinates to click the correct button
4. After the start button got clicked successfully the script should
go again in standby till the next error log window comes up
and then do the steps from 2-4 again
*/
;-------------------------------------------------------------------------------
Loop { ; forever
;-------------------------------------------------------------------------------
WinWait, ErrorLog ahk_exe notepad.exe ; (1)
WinClose ; (2)
Run, whatever, get PID ; (3a)
While not Button ; waiting for button to appear
ControlGet, Button, hwnd,, Start, use PID
ControlClick, Start ; (3b)
; do nothing and restart from (1) ; (4)
}
Re: Help needed
A Bit I guess^^ But we need to find the button with coordinates or will start really work if the button is labeled with start? What's about the loop will this version of you stop actions after clicked the button and go back to standby till a new notepad window appears again?
Re: Help needed
I don't know what Run, whatever will start. Programs that don't work, we will call just weird and stop, or study a lot, and hope for early results.
I think it's worth trying, there some nice programs where it works.
Edit: Yes, the code should stop actions and start a new WinWait.
Condensed and fine tuned:
I think it's worth trying, there some nice programs where it works.
Edit: Yes, the code should stop actions and start a new WinWait.
Condensed and fine tuned:
Code: Select all
/*
1. Script should wait till a program(notepad editor of windows) opening a error log window
2. Script should close error log window or ending the process (whatever is easier)
3. Script should start a program
4. and there ...
5. it should click "start"
*/
;-------------------------------------------------------------------------------
Loop { ; forever
;-------------------------------------------------------------------------------
WinWait, ErrorLog ahk_exe notepad.exe ; (1)
WinClose ; (2)
Run, whatever, get PID ; (3)
; where is the button? ; (4)
Button := False ; reset each time
While not Button ; waiting for button to appear
{
ControlGet, Button, hwnd,, Start, use %PID%
Sleep, 15 ; limit to 60x checks per second vs. more
}
ControlClick, Start ; (5)
}
Re: Help needed
Well there are different buttons in the program window which should be reopen, one button will start the main function of the program, the others are for config settings etc...
Marked the button
This button I wanna to be clicked
Marked the button
This button I wanna to be clicked
Re: Help needed
Now use WinSpy. If WinSpy can see the button that would mean, we are good to go.
WinSpy is started from RightClick on SysTray icon near the clock.
WinSpy is started from RightClick on SysTray icon near the clock.
Re: Help needed
wolf_II wrote:Now use WinSpy. If WinSpy can see the button that would mean, we are good to go.
WinSpy is started from RightClick on SysTray icon near the clock.
Nice! It can read out the button!
So anything to edit now?
Re: Help needed
Don't edit yet: study first
Notice: control under mouse position field contains Text and ClassNN. There is a little confusion coming up since classNN looks dodgy to me.
The next check I would do: Rum your experiment a few times, write down EXACT classNN each time. same Program, same button, is it still same classNN?
It might be, it might not be, we don't care, we just need to know which it is. We may know already the solution to that particular weirdness.
Notice: control under mouse position field contains Text and ClassNN. There is a little confusion coming up since classNN looks dodgy to me.
The next check I would do: Rum your experiment a few times, write down EXACT classNN each time. same Program, same button, is it still same classNN?
It might be, it might not be, we don't care, we just need to know which it is. We may know already the solution to that particular weirdness.
Re: Help needed
Yes it's the same classNN
It's always ClassNN: WindowsForms10.BUTTON.app.0.2bf8098_r9_ad18
Window title is generated, but the .exe same is always same
btw, I'm not sure about the errorLog part for Notepad, wouldn't it be saver to just use it like if Notepad window appears in general?
It's always ClassNN: WindowsForms10.BUTTON.app.0.2bf8098_r9_ad18
Window title is generated, but the .exe same is always same
btw, I'm not sure about the errorLog part for Notepad, wouldn't it be saver to just use it like if Notepad window appears in general?
Re: Help needed
Now we get the handle of that button. Precision is king here, use the caption/text of the button.
this line: check all the commas, they control how each piece of info gets passed to AHK. the first 4 pieces are ControlGet, Button, hwnd, Value. (Value we don't use = empty)
Compare with the help file where it tells the meaning of all these pieces.
So far we have the command, comma, Button comma hwnd two commas. Which are OutputVar and SubCommand
we will use the handle, we got the handle before with hwnd, it is saved in varable Button.
like that:
this line: check all the commas, they control how each piece of info gets passed to AHK.
Code: Select all
ControlGet, Button, hwnd,, Start Botting !, ahk_id %PID%
Compare with the help file where it tells the meaning of all these pieces.
So far we have the command, comma, Button comma hwnd two commas. Which are OutputVar and SubCommand
we will use the handle, we got the handle before with hwnd, it is saved in varable Button.
like that:
Code: Select all
ControlClick, %Button% ; (5)
Let's test that. separately.Carl wrote:btw, I'm not sure about the errorLog part for Notepad, wouldn't it be saver to just use it like if Notepad window appears in general?
Re: Help needed
Could you post the script in his finished form please?
Re: Help needed
I can and I will.
First things first: I know notepad.exe. I don't know the errorLog part for Notepad. What is this saying, EXACTLY
First things first: I know notepad.exe. I don't know the errorLog part for Notepad. What is this saying, EXACTLY
Re: Help needed
Why we cannot use notepad in general? Like as soon as notepad.exe window appears it should start the script triggerwolf_II wrote:I can and I will.
First things first: I know notepad.exe. I don't know the errorLog part for Notepad. What is this saying, EXACTLY
ErrorLog meant, the program opening sometimes a error-message in notepad, because it can't handle a situation
Re: Help needed
We can, as long as you realize that this means every time notepad.exe starts, this script will close it and run whatever instead. AND try to click a button there.Carl wrote:Why we cannot use notepad in general? Like as soon as notepad.exe window appears it should start the script trigger
ErrorLog meant, the program opening sometimes a error-message in notepad, because it can't handle a situation
You can consider putting in an emergency break, in case unexpected things happen, you can always exit the script from SysTray, so you can get away without.
Just consider it, and consider again later, when unexpected things start happening. Keep in mind: emergency breaks are a thing.
Just replace whatever in the script in line marked ; (3) <<<:
Code: Select all
/*
1. Script should wait till a program(notepad editor of windows) opens
2. Script should close notepad window or ending the process (whatever is easier)
3. Script should start a program
4. and there ...
5. it should click "start"
*/
; configure
program := "C:\path\to\whatever.exe"
BtnName := "Start botting!"
; variable ; hex value ( use/meaning )
progPID := 0 ; will hold PID of the program with the wanted button
hButton := 0 ; will toggle between 0 and the handle of the button
;-------------------------------------------------------------------------------
Loop { ; forever
;-------------------------------------------------------------------------------
WinWait, ahk_exe notepad.exe ; (1)
WinClose ; (2)
Run, %program%,,, progPID ; (3)
; where is the button ; (4)
hButton := False ; reset each time
While not hButton ; waiting for button to appear
{
ControlGet, hButton, hwnd,, %BtnName%, ahk_pid %progPID%
Sleep, 15 ; limit to ~60 checks per second
}
ControlClick, %hButton% ; (5)
}
;-------------------------------------------------------------------------------
F5:: ExitApp ; emergency hotkey {F5}
;-------------------------------------------------------------------------------
Last edited by wolf_II on 23 Sep 2018, 07:51, edited 1 time in total.
Re: Help needed
Run, whatever,,, PID
I just need to change whatever to the .exe I wanna start right? Is the PID needed too? Not 100% sure if the PID is also every time the same
I just need to change whatever to the .exe I wanna start right? Is the PID needed too? Not 100% sure if the PID is also every time the same
Re: Help needed
just updated script again, sorry. Yes, but now it's:
Fill in ; configure
Pid will be diferent each time, that's right. We get it fresh for every program we run.
Fill in ; configure
Pid will be diferent each time, that's right. We get it fresh for every program we run.
Re: Help needed
Ok great! tested the script a bitwolf_II wrote:just updated script again, sorry. Yes, but now it's:
Fill in ; configure
Pid will be diferent each time, that's right. We get it fresh for every program we run.
1) Script closing Notepad like it should
2) Starting the program like it should
3) Not clicking the Start button after the program started <<<More work needed^^
What I thought about, can we add a kill process to be sure that the program which should start after notepad is closed is not running anymore? (I guess it should not run after the error appeared, but just to be sure it really not running)
Re: Help needed
OK, more work is done with help of debugging tools. I'd start with buildt-in ListVars command.
I can not test and see on screen, so you have to do that. I might get this wrong, lets see ...
patch this block of code with ListVars
Run and see what all the variables contain while the script runs. after that, I don't know yet, I might need a screenshot.
I can not test and see on screen, so you have to do that. I might get this wrong, lets see ...
patch this block of code with ListVars
Code: Select all
While not hButton ; waiting for button to appear
{
ControlGet, hButton, hwnd,, %BtnName%, ahk_pid %progPID%
Sleep, 15 ; limit to ~60 checks per second
ListVars
}
We can do that also, ...What I thought about, can we add a kill process to be sure that the program which should start after notepad is closed is not running anymore? (I guess it should not run after the error appeared, but just to be sure it really not running)
Re: Help needed
(3) make sure program has stopped before starting it, renumber old steps 3..5
Code: Select all
/*
1. Script should wait till a program(notepad editor of windows) opens
2. Script should close notepad window or ending the process (whatever is easier)
3. make sure program has stopped before starting it
4. Script should start a program
5. and there ...
6. it should click "start"
*/
;-------------------------------------------------------------------------------
; variable ; hex value ( use/meaning )
;-------------------------------------------------------------------------------
progPID := 0 ; will hold PID of the program with the wanted button
hButton := 0 ; will toggle between 0 and the handle of the button
;-------------------------------------------------------------------------------
; configure
;-------------------------------------------------------------------------------
progName := "whatever"
program := "C:\path\to\" progName ".exe"
BtnName := "Start botting!"
;-------------------------------------------------------------------------------
Loop { ; forever
;-------------------------------------------------------------------------------
WinWait, ahk_exe notepad.exe ; (1)
WinClose ; (2)
; make sure program has stopped ; (3)
Process, Exist, %progName%
if ErrorLevel ; there is a problem
{
MsgBox,, Alert!, %ErrorLevel% is the handle of %progName%.exe
ExitApp
}
Run, %program%,,, progPID ; (4)
; where is the button ; (5)
hButton := False ; reset each time
While not hButton ; waiting for button to appear
{
ListVars
ControlGet, hButton, hwnd,, %BtnName%, ahk_pid %progPID%
Sleep, 15 ; limit to ~60 checks per second
}
ControlClick, %hButton% ; (6)
}
;-------------------------------------------------------------------------------
F5:: ExitApp ; emergency hotkey {F5}
;-------------------------------------------------------------------------------
Re: Help needed
Great work
I will doing some tests now and reporting problems(if they're happening) later
At this point I wanna say thanks for your work!
I really appreciated
I will doing some tests now and reporting problems(if they're happening) later
At this point I wanna say thanks for your work!
I really appreciated