Jump to content

Disable/Hide Windows Activation Dialog [SOLVED]


Recommended Posts

Hi everyone,

Im calling the SLUI.exe of Windows (responsible for activation) to force the Windows Activation Window to show up. Then I hide it using WinSetState with this Code:

If @OSArch = "X86" Then
    Run("C:\Windows\System32\SLUI.exe 4", "C:\Windows\System32\")
Else
    $IntPtr = DllStructGetPtr(DllStructCreate("int"))
    DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "ptr", $IntPtr)
    Run("C:\Windows\System32\SLUI.exe 4", "C:\Windows\System32\")
    DllCall("kernel32.dll", "int", "Wow64RevertWow64FsRedirection", "ptr", $IntPtr)
EndIf

$winHandle = WinWait("Windows Activation")
WinSetState($winHandle, "", @SW_HIDE)

After about an hour or two the window gets the @SW_SHOW message from somewhere.

Is there a way to force the window to stay hidden even if it gets a @SW_SHOW message?

If not is there a way to detect the @SW_SHOW state like WinWait? Checking every minute with WinGetState would be overpowered...

Thanks in advance!

Edited by MemphiZ
Link to comment
Share on other sites

If you're really not concerned with the window's state, but just want to ensure it is out of sight, you could always move the window into the twilight zone...

Run("C:\Windows\System32\sol.exe")
$winHandle = WinWait("Solitaire")
Sleep(2000)
WinMove($winHandle, "", -600, -600)
Sleep(2000)
WinMove($winHandle, "", 200, 200)
Sleep(2000)
WinClose($winHandle)
Link to comment
Share on other sites

If you're really not concerned with the window's state, but just want to ensure it is out of sight, you could always move the window into the twilight zone...

Run("C:\Windows\System32\sol.exe")
$winHandle = WinWait("Solitaire")
Sleep(2000)
WinMove($winHandle, "", -600, -600)
Sleep(2000)
WinMove($winHandle, "", 200, 200)
Sleep(2000)
WinClose($winHandle)

OK, that could work but how do I get rid of the Taskbar Icon?
Link to comment
Share on other sites

OK, that could work but how do I get rid of the Taskbar Icon?

I would expect that although there is something in the app which resets the visibility, it is less likely that there is something which resets its parent. So if you create a window with extended style $WS_EX_TOOLWINDOW so that it has no icon on the task bar, and set the program window so that is the parent then you can just hide the toolwindow. It might work and then you wouldn't need to keep monitoring it.

EDIT:

But maybe rasim's script will do the job for you. When that is running you simply hold down the shift ket and minimize a Window and it disappears from the task bar and from view. Optionally you can use CTRL instead of SHIFT.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I found 2 ways that actually work for me:

First is to create a new window and make the activation window a child of it. If my window is hidden the child will be hidden as well. It also won't have a taskbar icon because my windows doesn't have one.

After it becomes a child window I tried to just Sleep forever. A close look in process explorer shows that AutoIT's Sleep is using 0.01% CPU power so I wrote a little exe in C# to suspend a process using a given process ID.

Using this SuspendProcess.exe I suspend my own AutoIT process after making the activation window my child and (just to be sure) moving it out of sight. Here's the Code:

While (ProcessExists("slui.exe"))
     ProcessClose("slui.exe")
WEnd

If @OSArch = "X86" Then
    Run("C:\Windows\System32\SLUI.exe 4", "C:\Windows\System32\")
Else
    $IntPtr = DllStructGetPtr(DllStructCreate("int"))
    DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "ptr", $IntPtr)
    Run("C:\Windows\System32\SLUI.exe 4", "C:\Windows\System32\")
    DllCall("kernel32.dll", "int", "Wow64RevertWow64FsRedirection", "ptr", $IntPtr)
EndIf

$winHandle = WinWait("Windows Activation")
$parentWindow = GUICreate("", 0, 0, @DesktopWidth * 2, 0, "", $WS_EX_TOOLWINDOW)
_WinAPI_SetParent($winHandle, $parentWindow)


GUISetState(0, $window)

RunWait(@WorkingDir & "\SuspendProcess.exe " & @AutoItPID, "", @SW_HIDE)

If you don't want to have a process running (even if its suspended and won't use any CPU) heres another approach:

Hide the activation window and suspend its process. I realized that slui.exe is running 2 times. I guess one process is creating the GUI and the other brings it into view after some time (which was my initial problem).

Here's the Code for the second approach:

While (ProcessExists("slui.exe"))
    ProcessClose("slui.exe")
WEnd

If @OSArch = "X86" Then
    Run("C:\Windows\System32\SLUI.exe 4", "C:\Windows\System32\")
Else
    $IntPtr = DllStructGetPtr(DllStructCreate("int"))
    DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "ptr", $IntPtr)
    Run("C:\Windows\System32\SLUI.exe 4", "C:\Windows\System32\")
    DllCall("kernel32.dll", "int", "Wow64RevertWow64FsRedirection", "ptr", $IntPtr)
EndIf

$winHandle = WinWait("Windows Activation")
WinSetState($winHandle, "", @SW_HIDE)

$processList = ProcessList("slui.exe")
For $i = 1 To $processList[0][0]
    $pid = $processList[$i][1]
    ;MsgBox(0, "", "Suspending PID: " & $pid)
    RunWait(@WorkingDir & "\SuspendProcess.exe " & $pid, "", @SW_HIDE)
Next

I've also attached the ResumeProcess.exe just in case someone needs it. You can just pass a process ID to them and they will suspend/resume for you. (I know this could've been done using AutoIT as well using DLL calls I was just too lazy :mellow:)

Hope this helps!

SuspendProcess.exe

ResumeProcess.exe

Edited by MemphiZ
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...