Jump to content

Problem with Window Activation While Session Minimized


 Share

Recommended Posts

Hello.

I designed a robot that measures the time of specific tasks on an application. It calls the applications, wait for the screen to come up, and starts to click around in specific places, every now and then, another window is expected to pop up after a query or something like this.

The code is:

; -------- Start APP and checks if it is up
Run("C:\FS\FS.EXE")

;------ Wait for the main window
$vWait1 = WinWait("Folha de Dados", "Observações", 30)
If $vWait1 = 0 Then
    FileWriteLine($EUM_FDC_LOG, "Status=Error-01;timeResult=Timeout")
EndIf

; ------ Checks window existence, makes sure it is activated.
$vWhile1 = False
While $vWhile1 = False
    Sleep(100)
    If WinExists("Folha de Dados") Then
        WinActivate("Folha de Dados")
        $vWhile1 = True
    Else
        $initAppTime = $initAppTime + 0.1
        If $initAppTime > 30 Then
            FileWriteLine($EUM_FDC_LOG, "Status=Error-02;timeResult=Timeout") ;;;;;; error here
            Exit
        EndIf
    EndIf
WEnd

;------ Activate Window
Global $WinStatus1 = WinWaitActive("Folha de Dados", "Observações", 10)

;------ Gets handle
$hMainHandle = ControlGetHandle("Folha de Dados", "Observações", "[CLASSNN:msvb_lib_toolbar1]")

;------ Click on new
ControlClick("Folha de Dados", "Observações", $hMainHandle, "left", 1, 12, 12)
If @error then
    FileWriteLine($EUM_FDC_LOG, "Status=Error-02;timeResult=Timeout")
    Exit
EndIf

This is just a third of the script (it gets stuck early on the condition described below).

It works perfectly while logged to the computer and/or accessing via remote desktop. I have two monitors, If I click on the other monitor, making the remote computer screen unfocused, it runs perfectly. But if I minimize it, block the computer or close the connection at the red X (disconnecting only), it gives me this erros in the log:

Status=Error-02;timeResult=Timeout
Status=Error-02;timeResult=Timeout
Status=Error-02;timeResult=Timeout
Status=Error-02;timeResult=Timeout
Status=Error-02;timeResult=Timeout

Do you have any idea why the Windows Status funcions are failing? 

 

Link to comment
Share on other sites

This is normal Windows internal behavior. When you minimalize remote desktop sesion, then Windows on remote computer stops sending/analyzing some internal messages.
In your case I can only say: do not minimalize remonte desktop, just move the window outside visible area.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

16 minutes ago, DavidLago said:

 

It works perfectly while logged to the computer and/or accessing via remote desktop. I have two monitors, If I click on the other monitor, making the remote computer screen unfocused, it runs perfectly. But if I minimize it, block the computer or close the connection at the red X (disconnecting only), it gives me this erros in the log:

 

 

I don't see a GUI defined, when you say Red X, are you talking about on the remote desktop window or the application you made? Also, what do you mean by 'block the computer'?

C0d3 is P0etry( ͡° ͜ʖ ͡°)

Link to comment
Share on other sites

13 minutes ago, Kovacic said:

I don't see a GUI defined

There is no GUI. I'm calling an application, that has its own GUI.

13 minutes ago, Kovacic said:

are you talking about on the remote desktop window or the application you made?

Remote Desktop. I didn't make the application.

13 minutes ago, Kovacic said:

Also, what do you mean by 'block the computer'

WIN + L

 

17 minutes ago, mLipok said:

Windows on remote computer stops sending/analyzing some internal messages

If that is true, it really really sucks. Do you think there is a way around this, like, preventing the OS to stop sending those internal messages even if minimized?

I'll search for more info about this (a KB or something). If you happen to know exactly the one, please share.

Link to comment
Share on other sites

6 minutes ago, Kovacic said:

Or instead of remote desktop, use something that lets you interact directly with a logged in console session like TeamViewer, then use a simple mouse jiggle to keep it from locking.

Well, I don't think that would be possible. This computer that is going to run this will have to run it like 24/7. Its a full time end user experience monitoring. Just for the sake of information, I tested this teamviewer before and if you minimize it disconnects too. Just like mLipok said, it seems that some of the funcions just stop working...

Since I'm inside a company environtment, the policy ensures that the computer gets blocked after 10 or 15 minutes. Also, it cannot be overriden, since an user from one of those computers that will run the script could gain access to a computer who is authenticated inside the domain, with no need to type passwords. When it comes to security, this is not good.

An alternative I've been thinking, is creating another GPO (domain policy) to block the USB devices, so nobody would interact with the computer but the authorized personnel (through remote desktop).

An idea just came to my mind: using mstsc /admin to connect to the console. I'll perform a test.

Link to comment
Share on other sites

2 minutes ago, DavidLago said:

An idea just came to my mind: using mstsc /admin to connect to the console. I'll perform a test.

No luck.

But I noticed that even when I come back, the screen is still there waiting (grayed out) and it only is recognized after I click on it. If I click on anything else, it won't work. (the script works clicking and typing in the application while the application is minimized too, no problem).

Any ideas?

 

Link to comment
Share on other sites

Didn't know this was for business.. Sounds possible as long as you are not in the medical or financial industry..

Will an end user be using the computer as your script is running, or is this more of a lab machine?

Edited by Kovacic

C0d3 is P0etry( ͡° ͜ʖ ͡°)

Link to comment
Share on other sites

As mLipok said once a windows session is locked then no window is allowed to be active,  You will need to change your script so that It does not need to use WinWaitActive.  Try using WinExists

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

1 hour ago, DavidLago said:

Do you think there is a way around this, like, preventing the OS to stop sending those internal messages even if minimized?

TeamViewer.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

1 hour ago, DavidLago said:

since an user from one of those computers that will run the script could gain access to a computer who is authenticated inside the domain, with no need to type passwords. When it comes to security, this is not good.

 

If this is a lab machine, it should be locked behind a secure door so no end users can get to it.

C0d3 is P0etry( ͡° ͜ʖ ͡°)

Link to comment
Share on other sites

15 hours ago, Kovacic said:

 

If this is a lab machine, it should be locked behind a secure door so no end users can get to it.

It should, but not all branches have a datacenter. 

I tried this: https://support.smartbear.com/viewarticle/72139/

And it worked. I wished that there would be a way to do something like this to avoid that behavior when disconnecting. The only thing I found is so jury-rigged... https://support.smartbear.com/viewarticle/72794/

Edited by DavidLago
english grammar (I'm brazilian)
Link to comment
Share on other sites

9 minutes ago, DavidLago said:

I tried this: https://support.smartbear.com/viewarticle/72139/

And it worked.

Interesting find.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

Thanks, @mLipok. By the way, scavenging around the forum, I've found this topic: 

Check answer nº 4: 

On 9/5/2012 at 10:45 PM, OregonJohn said:

I have three different XP machines running AutoIt3 scripts interacting with the front end of the same program. I have a third XP machine (oldie) that runs a RDP of all three machines running scripts ... I call it my RDP monitor machine.

 

As an aside, I have one of those XP machines providing two RDP sessions for the RDP monitor because I want two active scripts running on two separate programs.

 

I wish XP provided the ability to run separate desktop instances on the same machine. I tried using virtual desktops (like Dexpot) but the windows the script was watching for kept coming to the main desktop and interrupted the activity on the main desktop.

Interesting idea. I will have to consider this.

Link to comment
Share on other sites

Okay, guys. This is a little spartan, but it works.

In order to be able to minimize and also disconnect from the remote computer without affecting any of the GUI oriented scripts you must do:

1. In the local computer:

  • Launch the Registry editor (regedit.exe), go to HKLM\Software\Microsoft\Terminal Server Client
  • Create a DWORD value named RemoteDesktop_SuppressWhenMinimized and set it to 2.

2. In the remote computer:

  • Place in the desktop the file attached to this post. It's a zip file containing a .bat file with a code that will disconnect your session without telling the OS that there is no user watching it anymore.

You'll have to execute this .bat script everytime you have to disconnect the session. (If anyone wants to convert the batch to AutoIt, it would be interesting too).

Tested and confirmed.

disconnect.zip

Link to comment
Share on other sites

1 hour ago, DavidLago said:
  • Launch the Registry editor (regedit.exe), go to HKLM\Software\Microsoft\Terminal Server Client
  • Create a DWORD value named RemoteDesktop_SuppressWhenMinimized and set it to 2.

It would be nice if you make AutoIt script for that.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

1 hour ago, mLipok said:

It would be nice if you make AutoIt script for that.

Oki.

Here it goes:

#cs ----------------------------------------------------------------------------
    AutoIt Version: 3.3.14.2
    Author:             David
    Script Function:    Go to HKLM\Software\Microsoft\Terminal Server Client, create a DWORD value named RemoteDesktop_SuppressWhenMinimized and set it to 2
#ce ----------------------------------------------------------------------------

#RequireAdmin
#include <Process.au3>

Global $eErr

;---- Remote Desktop Connections must be closed.
If ProcessExists("mstsc.exe") Then
    Local $mAnswer = MsgBox(52, "Warning", "There is at least one Remote Desktop Session active. May the process(es) be terminated?")
    If $mAnswer = 6 Then
        ProcessClose("mstsc.exe")
        If @error Then _RunDos("taskkill /F /IM mstsc.exe")
    Else
        Exit
    EndIf
EndIf

;---- Write the Registry 1
RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Terminal Server Client", "RemoteDesktop_SuppressWhenMinimized", "REG_DWORD", "2")
If @error Then
    $eErr = @error
    _ErrorDisplay($eErr)
EndIf

;---- Write the Registry 2
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client", "RemoteDesktop_SuppressWhenMinimized", "REG_DWORD", "2")
If @error Then
    $eErr = @error
    _ErrorDisplay($eErr)
EndIf

;---- SUCCESS
MsgBox(64, "Success", "Windows Registry settings applied successfully")

Func _ErrorDisplay($eErr)
    If $eErr = 1 Then MsgBox(16, "Error", "Unable to open requested key")
    If $eErr = 2 Then MsgBox(16, "Error", "Unable to open requested main key")
    If $eErr = 3 Then MsgBox(16, "Error", "Unable to remote connect to the registry")
    If $eErr = 4 Then MsgBox(16, "Error", "Unable to open requested value")
    If $eErr = 5 Then MsgBox(16, "Error", "Value type not supported")
    Exit
EndFunc   ;==>_ErrorDisplay

Haven't tested, though :)

Link to comment
Share on other sites

You are using strange naming convention I mean $mAnswer
For detailed information read here: https://www.autoitscript.com/wiki/Best_coding_practices#Names_of_Variables

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

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