Jump to content

[Solved] AdlibRegister fails after 'stop executing' uncompiled script


Recommended Posts

Hi, I wrote a script using 2 GUIs. At some point I AdlibRegister a function to always WinActivate GUI1 if GUI2 is activated.

Most of the time it works perfect. But I have the feeling that nearly always if I stop executing the uncompiled au3 with Strg+Break and restart the script then the AdlibRegister returns 1 but will not run. If I exit the script with Exit everything is fine.

Did I noticed it right? Is there a AdlibRegister issue if script is aborted? Is there a possibility to fix this?

Regards, Conrad

P.S. The script is about 1000 lines, so I think it wouldn't be helpful posting it. And I have no idea how to make it very small but prove the issue.

Edited by Simpel
[Solved]
SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Link to comment
Share on other sites

  • Developers
35 minutes ago, Simpel said:

Strg+Break

You mean in SciTE?  This will kill the process so don't expect any clean termination of the script.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

#include <GUIConstants.au3>
#include <WinAPI.au3>
#include <WinAPISys.au3>

Global Const $WA_ACTIVE = 1
Global Const $WA_CLICKACTIVE = 2

Global $hMain = GUICreate("Window 1")
Global $hSecond = GUICreate("Window 2")

GUIRegisterMsg($WM_ACTIVATE, WM_ACTIVATE)

GUISetState(@SW_SHOW, $hMain)
GUISetState(@SW_SHOW, $hSecond)


While (True)
    Switch (GUIGetMsg())
        Case $GUI_EVENT_CLOSE
            Exit 0
    EndSwitch
WEnd

Func WM_ACTIVATE($hWnd, $iMsg, $wParam, $lParam)
    Switch (_WinAPI_LoWord($wParam))
        Case $WA_ACTIVE, $WA_CLICKACTIVE
            Switch ($hWnd)
                Case $hSecond
                    ConsoleWrite("[" & @MIN & ":" & @SEC & ":" & @MSEC & "] Second window set to active, changing to main" & @LF)
                    Return _WinAPI_SetActiveWindow($hMain)
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_ACTIVATE

Give that a go instead of using AdLibRegister. Just use GUIRegisterMsg($WM_ACTIVATE, "") to turn off the activate function

Edited by InunoTaishou
Changed $WA_INACTIVE to $WA_CLICKACTIVE, had the proper value, just the wrong name
Link to comment
Share on other sites

Hi @InunoTaishou,

your example works perfect. I have to prove whether I can put it into my script without greater problems. I'll give it a try.

Thank you and regards, Conrad

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Link to comment
Share on other sites

There was no problem to implement this. Thanks again.

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...