I just bought a separate pc for receiving weather satellites and weather information. I use AHK for automating some processes.
One program (Wxtoimg-Pro) has a problem: the Auto Record button switches off after receiving a satellite. The program is not maintained anymore so I cannot ask the author.
So I wrote a AHK-script that presses the Auto Record button every 15 minutes, triggered by the Windows task Planner. Works OK.
Problem is that when I am working on one of the other programs, the Wxtoimg-screen pops up and remains there.
So I thought of the following solution. In the beginning of the script I look what screen is active, continue the script and at the end I activate again the screen that was active in the beginning.
I looked to a lot of commands and examples on the forum, tried a lot but did not find a solution. Anybody who can show me the way?
Thanks in advance.
Get the name of a screen Topic is solved
Re: Get the name of a screen
Post your code and I'm sure we could helpFredVN wrote: ↑18 Apr 2019, 02:44I just bought a separate pc for receiving weather satellites and weather information. I use AHK for automating some processes.
One program (Wxtoimg-Pro) has a problem: the Auto Record button switches off after receiving a satellite. The program is not maintained anymore so I cannot ask the author.
So I wrote a AHK-script that presses the Auto Record button every 15 minutes, triggered by the Windows task Planner. Works OK.
Problem is that when I am working on one of the other programs, the Wxtoimg-screen pops up and remains there.
So I thought of the following solution. In the beginning of the script I look what screen is active, continue the script and at the end I activate again the screen that was active in the beginning.
I looked to a lot of commands and examples on the forum, tried a lot but did not find a solution. Anybody who can show me the way?
Thanks in advance.
-TL
Re: Get the name of a screen
The problems are in the “Get” and “Make” parts. The others are working fine.
I tried a lot of command. These are the last attempts. There were a lot of –not working- before these.
I tried a lot of command. These are the last attempts. There were a lot of –not working- before these.
Code: Select all
;****************************************************
;Dit script:
; Get the active screen
; Press the Record Auto button
; Restores the previous active screen
;
;Auteur: Fred van den Bosch
;****************************************************
;****************************************************
; Get the name of the acive screen and put it into ActiefScherm
;****************************************************
WinGet, ActiefScherm, ProcessName, hwnd
;****************************************************
; Press Auto Record button
;****************************************************
WinActivate, WXtoImg [Registered to Fred van den Bosch]
ControlClick, X348 Y11
Sleep, 1000
WinActivate, WXtoImg:
Send, {Alt}+{F}
Send, {e}
Sleep, 500
WinActivate, WXtoImg: Record
WinWaitActive, WXtoImg: Record
Sleep, 500
MouseMove, 72, 562
Sleep, 500
MouseClick,, 72, 562
Sleep, 500
;****************************************************
; Make the previous screen active
;****************************************************
WinActivate, ActiefScherm
;****************************************************
; End
;****************************************************
Process, Close, Wxtoimg Auto
Process, Close, AutoHotKey.exe
Re: Get the name of a screen
I would try these 2 commands:
WinMenuSelectItem - Syntax & Usage | AutoHotkey
https://autohotkey.com/docs/commands/WinMenuSelectItem.htm
ControlClick - Syntax & Usage | AutoHotkey
https://autohotkey.com/docs/commands/ControlClick.htm
Or instead of WinMenuSelectItem (more advanced):
Get Info from Context Menu - Scripts and Functions - AutoHotkey Community
https://autohotkey.com/board/topic/19754-get-info-from-context-menu/
I would consider WinClose instead of Process Close, and ExitApp to end the script:
To get the active window, and make it active 5 seconds later:
WinMenuSelectItem - Syntax & Usage | AutoHotkey
https://autohotkey.com/docs/commands/WinMenuSelectItem.htm
ControlClick - Syntax & Usage | AutoHotkey
https://autohotkey.com/docs/commands/ControlClick.htm
Or instead of WinMenuSelectItem (more advanced):
Get Info from Context Menu - Scripts and Functions - AutoHotkey Community
https://autohotkey.com/board/topic/19754-get-info-from-context-menu/
I would consider WinClose instead of Process Close, and ExitApp to end the script:
Code: Select all
WinClose, Wxtoimg Auto
ExitApp ;close this AutoHotkey script
Code: Select all
WinGet, hWnd, ID, A
Sleep, 5000
WinActivate, % "ahk_id " hWnd
Last edited by jeeswg on 18 Apr 2019, 10:51, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: Get the name of a screen
Thanks for your answer.
The WinClose and ExitApp are working now.
To activate the previous window does not work yet.
I have added a messagebox after the WinGet in the beginning and just before the WinActivate at the end and both give the same value.
But the wxtoimg window remains in the front.
So my guess is that the problem is in the WinActivate.
I live in Vietnam (I am Dutch), so time to go to bed.
Tomorrow I will continue trying to get it working.
The WinClose and ExitApp are working now.
To activate the previous window does not work yet.
I have added a messagebox after the WinGet in the beginning and just before the WinActivate at the end and both give the same value.
But the wxtoimg window remains in the front.
So my guess is that the problem is in the WinActivate.
I live in Vietnam (I am Dutch), so time to go to bed.
Tomorrow I will continue trying to get it working.
Re: Get the name of a screen
I found the cause of the problems. For a solution there is a big lack of AHK-knowledge here.
First I opened a screen of Digital Atmosphere and also added a WinActivate for that screen to my Wxtoimg-script
Now when running the script in the beginning and at the end the DA-screen pops up.
Which means that without the WinActivate the DA-screen is not the active screen when opening the wxtoimg-script but that's somehow overwritten by starting the wxtoimg-script.
So the question is now, is it possible to know what the active screen was just before the wxtoimg-script is started?
Code: Select all
WinActivate, Digital Atmosphere
Sleep, 2000
WinGet, hWnd, ID, A
First I opened a screen of Digital Atmosphere and also added a WinActivate for that screen to my Wxtoimg-script
Now when running the script in the beginning and at the end the DA-screen pops up.
Which means that without the WinActivate the DA-screen is not the active screen when opening the wxtoimg-script but that's somehow overwritten by starting the wxtoimg-script.
So the question is now, is it possible to know what the active screen was just before the wxtoimg-script is started?
Re: Get the name of a screen
"So the question is now, is it possible to know what the active screen was just before the wxtoimg-script is started?"
Anybody who has suggestions how to do this?
Anybody who has suggestions how to do this?
Re: Get the name of a screen
Put this at the beginning of your script. This gives you some information on the active process before the script start.
Code: Select all
WinGet, ID, ID, A
WinGet, prc, ProcessName, ahk_id %id%
WinGetClass, Cls, ahk_id %id%
WinGetTitle, tit, ahk_id %id%
MsgBox,% format("Process`t{}`nClass`t{}`nTitle`t{}", prc,cls,tit)
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
Re: Get the name of a screen Topic is solved
YES! It works.
In fact the first suggestion from jeeswg also worked. But with these extra lines I found out that running the script does not work.
But compiling the script and put the .exe-file in the taskplanner did the trick.
Thanks everyone for the tips. I am very happy with the result!.
In fact the first suggestion from jeeswg also worked. But with these extra lines I found out that running the script does not work.
But compiling the script and put the .exe-file in the taskplanner did the trick.
Thanks everyone for the tips. I am very happy with the result!.
Who is online
Users browsing this forum: DIYCB, Google [Bot] and 40 guests