Jump to content

Block user interaction in a specific window


Recommended Posts

Hi!

 

How can i block user interaction in just a window? For example, if i have a script running, working in an excel, i would like to block user interaction with just that window of excel while the script is running, but i would like to see what is happening with that window.

I know the BlockInput function, but i just want to block user interaction with a specific window. While the script is running i would like to work in another excel window. But i don't want to by mistake open the window that the script is working and screw everything.

What i was thinking is, create a 90% yellow(for example) transparent window that will always be in front of that excel window, and when i change position of the excel, that transparent window always change too. Why 90%? Because that way i know the script is running, i could only interact with the excel while the script is in a specific function (Func _Pause).

First question, there is already anything to do this job? I had search but didn't find anything.

Second, can anyone help me creating this almost transparent window? I know you like to see what people already tried, but this is still an idea, didn't start working in it.

 

Thanks and i'm sorry for my english but isn't my first language.

Link to comment
Share on other sites

Take a look at this snippet, it blocks all user inputs for a single window, but still allows programmatic manipulations :

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

Opt ("MustDeclareVars", 1)

Local $Form1 = GUICreate("Enable Window", 362, 190, 192, 124)
Local $Label1 = GUICtrlCreateLabel("Test of Window Enable", 56, 40, 115, 17)
Local $Input1 = GUICtrlCreateInput("Input1", 192, 38, 145, 21)
Local $Button1 = GUICtrlCreateButton("OK", 128, 104, 89, 33)
_WinAPI_EnableWindow ($Form1,False)

GUISetState(@SW_SHOW)

Sleep (1000)
GUICtrlSetData ($Input1, "Test")
ControlClick ($Form1, "", $Button1)

Local $t = TimerInit ()
While 1
  If TimerDiff ($t) > 10000 Then _WinAPI_EnableWindow ($Form1,True)
  Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
      ExitLoop
    Case $Button1
      ConsoleWrite ("Button1 was pressed" & @CRLF)
  EndSwitch
WEnd

 

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...