WinActivate dont work

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jkeks
Posts: 60
Joined: 20 Oct 2019, 00:24
Contact:

WinActivate dont work

Post by jkeks » 16 Nov 2021, 03:39

in this case WinActivate work fine

Code: Select all

WinActivate BZProcessDS
in this case WinActivate dont work, cant understand why

Code: Select all

MouseMove, 1, 1
CoordMode Pixel
Loop,
{
    ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, wm.png
    if (FoundX > 0) { 
        CoordMode Mouse, Screen
        FoundX:=FoundX+90
        FoundY:=FoundY+90
        MouseMove, %FoundX%, %FoundY%
        Click
        Send, ^v
        Sleep, 200
        Send, {Tab}{Enter}
        break
   }
   sleep, 200 
} 

; find when addsubj done
Loop,
{
    ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, WMadded.png
    if (FoundX > 0) { 
        break
   }
   Sleep, 200
} 

WinActivate BZProcessDS

User avatar
lmstearn
Posts: 698
Joined: 11 Aug 2016, 02:32
Contact:

Re: WinActivate dont work

Post by lmstearn » 16 Nov 2021, 03:59

Hi, try some error handling after the imagesearch function(s):

Code: Select all

if (ErrorLevel = 2)
    MsgBox Could not conduct the search. File Exists?
else if (ErrorLevel = 1)
    MsgBox Image could not be found on the screen.
else
    MsgBox The image was found at %FoundX%x%FoundY%.
Edit: the second search starts without CoordMode Pixel -is that intended?
Last edited by lmstearn on 16 Nov 2021, 04:04, edited 1 time in total.
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH

amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: WinActivate dont work

Post by amateur+ » 16 Nov 2021, 04:03

Looks strange.
If you substitute WinActivate BZProcessDS by another command (e.g. MsgBox, Success!), will it be executed?
Does DetectHiddenWindows On help?
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.

jkeks
Posts: 60
Joined: 20 Oct 2019, 00:24
Contact:

Re: WinActivate dont work

Post by jkeks » 17 Nov 2021, 03:29

If I run this script manually it work fine

Code: Select all

WinActivate BZProcessDS
but if I run this script from onother my programm it dont work propertly

strange thing

jkeks
Posts: 60
Joined: 20 Oct 2019, 00:24
Contact:

Re: WinActivate dont work

Post by jkeks » 17 Nov 2021, 03:33

amateur+ wrote:
16 Nov 2021, 04:03
Looks strange.
If you substitute WinActivate BZProcessDS by another command (e.g. MsgBox, Success!), will it be executed?
Does DetectHiddenWindows On help?
MsgBox executed well, winActivate dont work

Code: Select all

WinActivate BZProcessDS
MsgBox, DONE

Code: Select all

DetectHiddenWindows, On
Does not affect

jkeks
Posts: 60
Joined: 20 Oct 2019, 00:24
Contact:

Re: WinActivate dont work

Post by jkeks » 17 Nov 2021, 03:37

lmstearn wrote:
16 Nov 2021, 03:59
Hi, try some error handling after the imagesearch function(s):

Code: Select all

if (ErrorLevel = 2)
    MsgBox Could not conduct the search. File Exists?
else if (ErrorLevel = 1)
    MsgBox Image could not be found on the screen.
else
    MsgBox The image was found at %FoundX%x%FoundY%.
Edit: the second search starts without CoordMode Pixel -is that intended?
add CoordMode Pixel before second search, it does not affect
There no matter what code before. I tested it. Code

Code: Select all

WinActivate BZProcessDS
work fine if it will run manually, and dont work if it run from my another programm

User avatar
MrDodel
Posts: 96
Joined: 28 Apr 2021, 09:03
Location: Event Horizon

Re: WinActivate dont work

Post by MrDodel » 17 Nov 2021, 03:39

jkeks wrote:
17 Nov 2021, 03:29
If I run this script manually it work fine

Code: Select all

WinActivate BZProcessDS
but if I run this script from onother my programm it dont work propertly

strange thing
You're initial script is searching for an image (wm.png) as mentioned replace Winactivate with an msgbox, if that doesn't work, there's an issue with your imagesearch routine.

Code: Select all

WinActivate BZProcessDS
- on it's own will work, but your adding into an routine which you've not confirmed is working (is your image found / not found ?)
So much universe, and so little time. GNU Sir Terry.

jkeks
Posts: 60
Joined: 20 Oct 2019, 00:24
Contact:

Re: WinActivate dont work

Post by jkeks » 17 Nov 2021, 04:08

Code: Select all

if WinExist("BZProcessDS")
    MsgBox, YES
    Else
    MsgBox, No
    ; WinActivate
    
if WinExist("BZProcessDS")
    WinActivate
Msgbox YES - shown
but WinActivate not work !

jkeks
Posts: 60
Joined: 20 Oct 2019, 00:24
Contact:

Re: WinActivate dont work

Post by jkeks » 17 Nov 2021, 04:11

MrDodel wrote:
17 Nov 2021, 03:39
jkeks wrote:
17 Nov 2021, 03:29
If I run this script manually it work fine

Code: Select all

WinActivate BZProcessDS
but if I run this script from onother my programm it dont work propertly

strange thing
You're initial script is searching for an image (wm.png) as mentioned replace Winactivate with an msgbox, if that doesn't work, there's an issue with your imagesearch routine.

Code: Select all

WinActivate BZProcessDS
- on it's own will work, but your adding into an routine which you've not confirmed is working (is your image found / not found ?)
Image always found well

User avatar
lmstearn
Posts: 698
Joined: 11 Aug 2016, 02:32
Contact:

Re: WinActivate dont work

Post by lmstearn » 17 Nov 2021, 04:36

Code: Select all

sleep, -1
UniqueID := WinExist("BZProcessDS")
if (UniqueID)
WinActivate AHK_ID %UniqueID%
Also, not running this on a remote server?
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH

amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: WinActivate dont work

Post by amateur+ » 17 Nov 2021, 04:56

@jkeks, try PostMessage, 0x0006,,,, BZProcessDS

Update.
I've created a topic about it: viewtopic.php?f=76&t=96775
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.

jkeks
Posts: 60
Joined: 20 Oct 2019, 00:24
Contact:

Re: WinActivate dont work

Post by jkeks » 18 Nov 2021, 03:13

not work

Code: Select all

PostMessage, 0x0006,,,, BZProcessDS
not work

Code: Select all

sleep, -1
UniqueID := WinExist("BZProcessDS")
if (UniqueID)
WinActivate AHK_ID %UniqueID%
work !

Code: Select all

titleToActivate := "BZProcessDS"
hWnd := WinExist(titleToActivate)
PostMessage, WM_SYSCOMMAND := 0x0112, SC_HOTKEY := 0xF150, hWnd,, ahk_id %hWnd%
WWWHHYYYY???

jkeks
Posts: 60
Joined: 20 Oct 2019, 00:24
Contact:

Re: WinActivate dont work

Post by jkeks » 18 Nov 2021, 03:28

if

Code: Select all

titleToActivate := "BZProcessDS"
hWnd := WinExist(titleToActivate)
PostMessage, WM_SYSCOMMAND := 0x0112, SC_HOTKEY := 0xF150, hWnd,, ahk_id %hWnd%

send {down}{tab}

Code: Select all

send {down}{tab}
work first then winactivate abrakadabra

amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: WinActivate dont work

Post by amateur+ » 19 Nov 2021, 15:31

Haven't understood about send {down}{tab} and winactivate abrakadabra. Could you explain, please?
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.

Post Reply

Return to “Ask for Help (v1)”