Jump to content

BlockInput() not working & WinWait() not working for Java window


Witto
 Share

Recommended Posts

Dear all,

I have two questions.

First question

BlockInput() does not work at all for me.

The script is launched by a common user on Windows XP SP3 and looks like:

;*******************
; AutoIT Parameters
;*******************
Dim $r
$r = BlockInput(1)
#NoTrayIcon
$r = AutoItSetOption("MustDeclareVars", 1)
; Here comes the rest of the script
$r = BlockInput(0)
Exit(0)
What am I doing wrong?

Second question

I understood there are problems handling Windows made with java.

Is there any alternative for WinWait() to wait for a certain Java window to appear? If that window appears, I can end my script.

Edited by Witto
Link to comment
Share on other sites

Its working, put some sleep like 10 seconds (10000 miliseconds) and youl see that its working

If new java window isnt "window in a window" or have its own controll then it can b tracked with win info tool then it can probably b handled, you did not provide enought info for your java win so probably even if someone know how to help you there isnt enought info to go on.

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

Is it win in a win, what does win info tool return from it, do you have picture? if win apears on the identical position did you try to solve it with PixelChecksum on prefered location or something similar?

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

Dear bogQ,

I do not understand your question about "win in a win".

The "(Frozen) AutoIt v3 Window Info" returns the following on the "Summary" tab

>>>> Window <<<<

Title: MyApplication - Login

Class: HwndWrapper[DefaultDomain;;208873d9-b169-4e12-bead-0509dc531d8f]

Position: 359, 254

Size: 682, 512

Style: 0x16C80000

ExStyle: 0x00040100

Handle: 0x00591116

>>>> Control <<<<

Class:

Instance:

ClassnameNN:

Name:

Advanced (Class):

ID:

Text:

Position:

Size:

ControlClick Coords:

Style:

ExStyle:

Handle:

>>>> Mouse <<<<

Position: 748, 459

Cursor ID: 0

Color: 0x434D59

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<

>>>> Hidden Text <<<<

Kind regards, Edited by Witto
Link to comment
Share on other sites

So is the

Title: MyApplication - Login

window that your trying winwait?

or it have some other window in itself that you cant get winname with info tool?

Can you post picture of that window ?

Did you try to PixelChecksum?

Common don't expect from someone to put words in your mouth

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

Dear bogQ,

I think I have overlooked something. the only excuse I have is that this is my first AutoIt3 script.

The only thing WinWait() can check for is the Title: "MyApplication - Login"

WinWait() is working fine and I can use it for the end of my script. If the login window appears, the user can start working.

BlockInput(1) is not working.

If I add Sleep(10000) as you suggested, the console is blocked for 10 seconds. After this, the script continues and the user can interrupt the script at wish.

I snipped some code from my script. Don't mind the order, I have to move some variables to the top.

;*******************
; AutoIT Parameters
;*******************
#NoTrayIcon
Dim $r
; $r = BlockInput(1)
; Sleep(10000)
$r = AutoItSetOption("MustDeclareVars", 1)

;***********************
; Operational Constants
;***********************
; some constants

;***********
; Variables
;***********
Dim $handle
Dim $error
Dim $Success = 0
Dim $Counter = 0

;******************
; Program Function
;******************
; some stuff

$Counter = 0
$Success = 0
Do
    ; This is the MyApplication installation warning
    Dim $Title4 = "Application Install - Security Warning"
    Dim $Text4 = "MyApplication"
    Dim $BtnInstall = "[Name:btnInstall]"
    Dim $BtnDontInstall = "[Name:btnCancel]"
    $Handle = WinWait($Title4,$Text4,1)
    if $Handle <> 0 Then
        if $Handle = 1 Then
            $r = WinActivate($Title4,$Text4)
            $r = ControlClick($Title4,$Text4,$BtnInstall,$MouseBtnMain,1)
        Else
            $r = WinActivate($Handle)
            $r = ControlClick($Handle,"",$BtnInstall,$MouseBtnMain,1)
        EndIf
    EndIf
    ; This is the MyApplication - Login
    Dim $Title5 = "MyApplication - Login"
    $Handle = WinWait($Title5,"",1)
    If $Handle <> 0 Then
        $Success = 1
    EndIf
    $Counter = $Counter + 1
Until $Success = 1 or $Counter = 30
If $Counter = 30 Then
    $Error = 1
    Exit($Error)
EndIf

; $r = BlockInput(0)

Exit(0)

If I uncomment the BlockInput() function at the top, together with the Sleep(10000), my mouse and keyboard only freeze for 10 seconds. Afterwards, I can interrupt the script by pushing the "Esc" key.

I tested BlockInput() with AutoIt3.exe v3.3.6.1 and v3.2.2.0. It failed for both versions.

Edited by Witto
Link to comment
Share on other sites

i did test your code not involving sleep and it block the input until i press ctrl+alt+del, so i dont have slitest idea whats wrong on your comp.

If this is workong for you until you press ctrl+alt+del

$r = BlockInput(1)
While 1
    Sleep(10)
WEnd
$r = BlockInput(0)

then its problem probably that your script exits before you know it or something else

Test the script to geave you msgbox before it exits

See the return on BlockInput(1), if its returning 0 try #requireAdmin dono what else can b wrong

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

With this script:

;*******************
; AutoIT Parameters
;*******************
#NoTrayIcon
Dim $r
$r = AutoItSetOption("MustDeclareVars", 1)

;*******************
; Script
;*******************
$r = BlockInput(1)
Sleep(3000)
$r = MsgBox(1,"Try to click me","If you can click this, BlockInput is not working",10)
$r = WinWait("dummy","dummy",30)

$r = Run(@ScriptDir & "\CertMgr.exe -add -c " & '"' & @ScriptDir & '\MyCert.cer"' & " -s ROOT")
sleep(10000)

$r = BlockInput(0)
Exit(0)
BlockInput() works fine until the "Run" statement.

I seem to notice that run is not the only command or function breaking the BlockInput.

I do not want to use #requireAdmin. It gives a pop-up for administrative credentials. The script HAS to run in the user environment, without any advanced privileges.

Edited by Witto
Link to comment
Share on other sites

Dear BogQ,

The use of CertMgr.exe overrides the BlockInput(1). CertMgr.exe can be found in the Microsoft Windows SDK for Windows 7 and .NET Framework 4.

In my script, I try to enable the BlockInput(1) as soon as possible after CertMgr.exe disabled it.

I hope my script can help other users wih the same problem.

WinWait() is working. The Java program window can only be found by it's title.

; ===========================================================================================
;
;   Script Information
;   
;   Title:                  InstallMyApplication
;   Author:                 Witto
;   Description:            Installs MyApplication
;   
; ===========================================================================================

;*******************
; AutoIT Parameters
;*******************
#NoTrayIcon
Dim $r
$r = BlockInput(1)
$r = AutoItSetOption("MustDeclareVars", 1)
; This option is not supported anymore since v3.2.12.0
; $r = AutoItSetOption("RunErrorsFatal", 0)

;***********************
; Operational Constants
;***********************
; Buttons in forms
Const $WinCtrlYes = 6
Const $WinCtrlNo = 7
; Certificate
Const $FileName = '"' & @ScriptDir & '\MyCertificate.cer"'
; Mouse Buttons
Const $MouseBtnMain = "primary"
Const $MouseBtnMenu = "secondary"
Const $MouseBtnMiddle = "middle"

;***********
; Variables
;***********
Dim $handle
Dim $error
Dim $Success = 0
Dim $Counter = 0

; This box appears when trying to add the certificate
Dim $WinTitle0 = "Security Warning"
Dim $WinText0 = "You are about to install a certificate"

; This box appears if the certificate has been installed before
Dim $WinTitle1 = "Root Certificate Store"
Dim $WinText1 = "Do you want to DELETE the following certificate from the Root Store?"

; This is the file download warning
Dim $Title2 = "File Download - Security Warning"
Dim $Text2 = "Do you want to run or save this file?"
Dim $ButtonRun = 4426
Dim $ButtonSave = 4427
Dim $ButtonCancel = 2

; This is the security warning that asks if you want to run te program
Dim $Title3 = "Internet Explorer - Security Warning"
Dim $Text3 = "The publisher could not be verified.  Are you sure you want to run this software?"

; This is the MyApplication installation warning
Dim $Title4 = "Application Install - Security Warning"
Dim $Text4 = "MyApplication"
Dim $BtnInstall = "[Name:btnInstall]"
Dim $BtnDontInstall = "[Name:btnCancel]"

; This is the MyApplication - Login
Dim $Title5 = "MyApplication - Login"

;******************
; Program Function
;******************
; Install MyCertificate
$r = Run(@ScriptDir & "\CertMgr.exe -add -c " & $FileName & " -s ROOT")

If @error = 0 Then
    Do
        ; Check if pop-up appears to install the certificate
        ; This box appears when trying to add the certificate
        $handle = WinWait($WinTitle0, $WinText0, 1)
        ; At this moment, BlockInput(1) stops working
        ; Enable it again ASAP
        $r = BlockInput(0)
        $r = BlockInput(1)
        If $handle <> 0 Then
            If $Handle = 1 Then
                ; support for versions of AutoIt older then 3.3.2.0
                $r = WinActivate($WinTitle0, $WinText0)
                $r = ControlClick($WinTitle0, $WinText0, $WinCtrlYes, $MouseBtnMain, 1)
            Else
                ; code for AutoIt v3.3.2.0 or more recent
                $r = WinActivate($handle)
                $r = ControlClick($handle, "", $WinCtrlYes, $MouseBtnMain, 1)
            EndIf
            $Success = 1
        EndIf
        ; Check if Certificate has been installed before
        ; This box appears if the certificate has been installed before
        $handle = WinWait($WinTitle1, $WinText1, 1)
        ; At this moment, BlockInput(1) stops working
        ; Enable it again ASAP
        $r = BlockInput(0)
        $r = BlockInput(1)
        If $handle <> 0 Then
            If $Handle = 1 Then
                $r = WinActivate($WinTitle1, $WinText1)
                $r = ControlClick($WinTitle1, $WinText1, $WinCtrlYes, $MouseBtnMain, 1)
            Else
                $r = WinActivate($handle)
                $r = ControlClick($handle, "", $WinCtrlYes, $MouseBtnMain, 1)
            EndIf
        $Counter = $Counter + 1
        EndIf
    Until $Success = 1 or $Counter = 30
    If $Counter = 30 Then
        $Error = 1
        exit $Error
    EndIf
Else
    $Error = 1
    Exit $Error
EndIf

; Start the setup of MyApplication via the Internet
$r = Run('"' & envget("ProgramFiles") & '\Internet Explorer\iexplore.exe"  "https://services.MyApplication.provider.com/etcetera/etcetera/setup.exe"')

; This is the file download warning
$Handle = WinWait($Title2,$Text2,30)
If $Handle <> 0 Then
    If $Handle = 1 Then
        $r = WinActivate($Title2,$Text2)
        $r = ControlClick($Title2,$Text2,$ButtonRun,$MouseBtnMain,1)
    Else
        $r = WinActivate($Handle)
        $r = ControlClick($Handle,"",$ButtonRun,$MouseBtnMain,1)
    EndIf
Else
    $Error = 1
    Exit($Error)
EndIf


; This is the security warning that asks if you want to run te program
$Handle = WinWait($Title3,$Text3,30)
If $Handle <> 0 Then
    If $Handle = 1 Then
        $r = WinActivate($Title3,$Text3)
        $r = ControlClick($Title3,$Text3,$WinCtrlYes,$MouseBtnMain,1)
    Else
        $r = WinActivate($Handle)
        $r = ControlClick($Handle,"",$WinCtrlYes,$MouseBtnMain,1)
    EndIf
Else
    $Error = 1
    exit($Error)
EndIf

$Counter = 0
$Success = 0
Do
    ; This is the MyApplication installation warning
    $Handle = WinWait($Title4,$Text4,1)
    If $Handle <> 0 Then
        If $Handle = 1 Then
            $r = WinActivate($Title4,$Text4)
            $r = ControlClick($Title4,$Text4,$BtnInstall,$MouseBtnMain,1)
        Else
            $r = WinActivate($Handle)
            $r = ControlClick($Handle,"",$BtnInstall,$MouseBtnMain,1)
        EndIf
    EndIf
    
    ; This is the MyApplication - Login
    $Handle = WinWait($Title5,"",1)
    If $Handle <> 0 Then
        If $Handle <> 0 Then
            If $Handle = 1 Then
                $r = WinActivate($Title5)
            Else
                $r = WinActivate($Handle)
            EndIf
        EndIf
        $Success = 1
    EndIf
    $Counter = $Counter + 1
Until $Success = 1 or $Counter = 60
If $Counter = 60 Then
    $Error = 1
    Exit($Error)
EndIf

$r = BlockInput(0)

Exit(0)
Edited by Witto
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...