Jump to content

Running automation behind a blurred background


ute_man
 Share

Recommended Posts

Hi Forum,

I wrote an Autoit script that automates downloading log files from a Data Logger. (GUI_1)

This involves launching of third party software like WinSCP using my script.

While downloading logs, I would like to blur the background (preferably blackout the background) leaving only GUI_1 visible so that users will only see the messages coming from my script and therefore user mistakes will be minimised.

I can blur the background by creating another GUI (GUI_2) and using _GDIPlus.

However, as I use WinWaitActive and WinActivate functions, there is no way for me to run my script behind GUI_2 as my script needs windows to be active for clicking on relevant buttons and other controls by moving mouse to specific mouse co-ordinates.

Is there a way for me to achieve this.

What I want is to run my script showing only GUI_1 and hiding everything else on the desktop bu masking with GUI_2.

To make it more clear, I have a bottom layer on the desktop where the real mouse moving and clicking is taking place and middle layer for GUI_2 and then GUI_1 as the top most layer.

Thank you guys,

Any help is appreciated.

UM

 

Link to comment
Share on other sites

Maybe this ?

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

_GDIPlus_Startup()
Local $hGui1 = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
Local $hGUI2 = GUICreate ("", -1, -1, -1, -1, $WS_POPUP+$WS_BORDER, $WS_EX_TOPMOST)
Local $idButton = GUICtrlCreateButton ("OK",100,100,100,25)
Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui1)
Local $hHBitmap = _ScreenCapture_Capture("", 0, 0, @DesktopWidth, @DesktopHeight, 0)
Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap)
_WinAPI_DeleteObject($hHBitmap)
Local $hEffect = _GDIPlus_EffectCreateBlur(5)
_GDIPlus_BitmapApplyEffect($hBitmap, $hEffect)
GUISetState(@SW_SHOWNA, $hGui1)
GUISetState(@SW_SHOW, $hGui2)
_GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, @DesktopWidth, @DesktopHeight)

While True
  Switch GUIGetMsg ()
    Case $GUI_EVENT_CLOSE, $idButton
      ExitLoop
  EndSwitch
WEnd

_GDIPlus_EffectDispose($hEffect)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hGraphics)
GUIDelete($hGui1)
GUIDelete($hGui2)

_GDIPlus_Shutdown()

 

Link to comment
Share on other sites

Hi Nine,

Thank you so much and much appreciated.

My problem with this implementation is that since the third party applications that require WinWaitActive and WinActivate along with mouse move to coordinates and require mouse clicking, they will not work as WinWaitActive and WinActivate will require the other GUIs to be active and hence I will not be able to hide them while working.

Therefore, it will not be possible for these third party applications to work behind another gui. (in your example it is Gui1)

What I need is to work my program that require WinWaitActive and WinActivate to work in a hidden mode where the third party applications, mouse moves or clicks will not be visible to the end user.

Any other thoughts ?

Once again I thank you for your support.

UM

Link to comment
Share on other sites

@ute_man I think I understand what you want to achieve now.  You want to automate some application, over a blurred background, and run your script hidden, so only that application is visible.  Ok, let's say it is notepad.  You want to click,  send text, etc, to Notepad on the foreground and have a blurred background behind.  Is that it ?  What is the application you want to automate ?

Link to comment
Share on other sites

Hi Nine,

 

Thank you so much again.

I am so sorry, I have not made it clear enough.

What I am trying to do is to click,  send text, etc, to Notepad on the BACKGROUND and have it covered with a blurred (or black) foreground.

As per your example, let's say my third party application is Notepad and let's say my Autoit application is MyApp.

What I need is to :

1. Run MyApp.

2. Launch Notepad with in MyApp.

3. Bring MyApp to foreground (may be topmost)

3. Do mouse moves and mouse clicks and whatever the other automation on Notepad in HIDDEN mode so that users will not even see Notepad or the desktop.

(Users will only see MyApp and the message boxes generated by MyApp)

image.png.338dc7b387ae5267c1d0038f1e684a55.png

Once again apologies for the confusion and wasting your time.

Thank you,

UM

Link to comment
Share on other sites

Ok, I got it now.  So what is the application you want to hide ?  This is the key question, because some function like ControlSend, ControlClick, etc can manipulate hidden apps, but rarely it is fully possible.  So what is the application you want to hide ?

Link to comment
Share on other sites

Thank you Nine, that was quick.

I use 2 applications - one of which is WinSCP.

The other application is a proprietary corporate application which is used in railway industry to download/analyse logs from locomotive on-board systems, which is not a "known" application. The name is PCSAM.

Thanks Nine for all your assistance.

br

UM

Link to comment
Share on other sites

Here an example very close of what you are after using notepad :

#NoTrayIcon
#include <Screencapture.au3>
#include <Constants.au3>
#include <GUIConstants.au3>
#include <WinAPISysWin.au3>

HotKeySet("{ESC}", _Exit)
OnAutoItExitRegister(_Clean)

_GDIPlus_Startup()
Local $hGui1 = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOOLWINDOW)
;Local $hGUI2 = GUICreate ("", -1, -1, -1, -1, $WS_POPUP+$WS_BORDER, $WS_EX_TOPMOST)
;Local $idButton = GUICtrlCreateButton ("OK",100,100,100,25)
Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui1)
Local $hHBitmap = _ScreenCapture_Capture("", 0, 0, @DesktopWidth, @DesktopHeight, 0)
Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap)
_WinAPI_DeleteObject($hHBitmap)
Local $hEffect = _GDIPlus_EffectCreateBlur(5)
_GDIPlus_BitmapApplyEffect($hBitmap, $hEffect)
GUISetState(@SW_SHOW, $hGui1)
;GUISetState(@SW_SHOW, $hGui2)

Local $hWnd = WinGetHandle ("[CLASS:Notepad]")
;_WinAPI_SetWindowLong ($hWnd, $GWL_STYLE, $WS_DLGFRAME)
_WinAPI_SetWindowLong ($hWnd, $GWL_EXSTYLE, $WS_EX_TOOLWINDOW)
_WinAPI_SetWindowPos($hWnd,  $HWND_TOPMOST, 0, 0, 0, 0, $SWP_FRAMECHANGED+$SWP_NOSIZE+$SWP_NOMOVE)

While True
  _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, @DesktopWidth, @DesktopHeight)
  Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
      ExitLoop
  EndSwitch
WEnd

Func _Clean()

  _GDIPlus_EffectDispose($hEffect)
  _GDIPlus_BitmapDispose($hBitmap)
  _GDIPlus_GraphicsDispose($hGraphics)
  GUIDelete($hGui1)
  _GDIPlus_Shutdown()

EndFunc   ;==>_Clean

Func _Exit()
  Exit
EndFunc   ;==>_Exit

The winapi will depend on how your apps can react to them.  So you will need to adjust it along your requirements...Let just say it is my last effort on this.  Next you will need to provide some effort from your side.

Link to comment
Share on other sites

Thank you so much for all your guidance and assistance and much appreciated as always. 

I will certainly give it a try, hopefully I will be able to make you proud.

Once again, a big thank you to you.

I would like to take this opportunity to wish you and your families a Merry Christmas and a great new year ahead.

br

UM

Link to comment
Share on other sites

Assuming you're using WinSCP as a file-getter, there are command line (Secure) FTP programs that you can use with a UDF... that way you don't need to automate it.

I use this one:

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

Have you considered instead of using mouse clicks - see if your app supports command line? If yes then that would be much more stable. 

If no, then have you considered simply moving the window so it is off the screen then doing the control clicks that way? 

Link to comment
Share on other sites

Hi Bert,

Thank you so much.

With WinSCP, yes, I have started using command line, but with my company's proprietary tool, there is no way that can be achieved.

However, as you have suggested I will try moving the windows off the screen - brilliant tip - I never thought about it nor never believed that it would be possible.

Thank you again Bert, this forum is amazing.

I mean all these helpful people make this forum amazing.

Let me wish you and your families a fun filled Christmas and safe holidays !!!

Regards,

UM

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

×
×
  • Create New...