Autoit controlsend remote desktop - desktop

I have a remote desktop and i'm trying to run a simple script to prevent idle session timeout, which is 3 min (quite annoying). The script should, for example, press "A" key every 2.5 min or so.
Problem is, the remote desktop window is often inactive/minimized and:
1) if i try to run such a script "inside" the remote desktop, i still get disconnected, despite it actually works (continues to type or create/delete files etc even as the "idle timer expired" message is on screen). i believe the system wants some "external" action.
2) if i run the script on my PC, it doesn'do anything at all on the remote desktop (i had an open notebook there, and there was no typing):
ControlSend("[CLASS:TscShellContainerClass]", "", "[CLASS:OPContainerClass; INSTANCE:1]", "{A}")
I think the problem lies with the "controlid" part, which i got via autoit window info. If i set controlid as "" - it works, but only if the window is currently active.
I've seen a registry key solution, but doesn't seem to work for me.
If anyone has any ideas about fixing this, please, don't hold back:)

I know it's late but here's the ONLY thing I could get to work; it involved activating the window. I tried ControlFocus but to no avail, so here's what I got.
You should be able to modify your script as needed.
#include<Array.au3>
OPT("WinTitleMatchMode",2)
$a = WinList("Remote Desktop Connection")
;_ArrayDisplay($A)
ConsoleWrite(UBound($A)& #CRLF)
FOR $N = 1 to $A[0][0]
$hActiveWindow = WinGetHandle("")
WinActivate($a[$N][1]) ;comment if using controlfocus
;ControlFocus($a[$N][1],"","") ;comment if using winactivate
ControlSend($a[$N][1],"","","^+{ESC}")
WinActivate($hActiveWindow)
Next

Related

Get Postman to open on monitor 2

I have two monitors. My laptop (monitor #1) and an HDMI monitor (monitor #2). Postman will only open on #1 forcing me to drag it to monitor #2 for use. Is there any way to force Postman to always open on monitor #2. (And the windows key + alt + enter doesn't work for me.)
I think it's opening on the main monitor. You could use e.g. DisplayFusion to memorize the window location.
https://www.displayfusion.com/ works for me. If it's a corporate laptop then use
Windows key + Shift + Enter
Using the latest version of Windows 10, I have found that Postman consistently opens on the display I last had it open on. Simply backing up and reinstalling Postman could fix this, or forcing a windows update if you're on an older version.
If not a solution such as PowerToys' FancyZones or DisplayFusion could work for you, although I have no experience either of these so I couldn't say for sure if they would work.
I think you can try following below steps:
Open the program.
Move it to the monitor on which you would like it to open by default.
Hit the Windows key + Shift + Enter
And now, it will be open each time on the monitor of your preference.

WAMP Server not turning green every time I restart my Surface

I've been using WAMP server for a few of my school projects however I have had a lot of trouble with it staying green. I am pretty sure its an internal issue but I'm not really sure how to figure out what exactly is happening. The main problem I experience is that it installs fine and runs. However, whenever I restart my laptop it will not turn green. It stays orange and says 1 of 2 services running. I tried the methods I saw online however it does not even let me right-click it to see what isn't running or to restart the services. I've had to reinstall it about five times to keep using it and it's getting extremely annoying. I think it has to do with mySQL not starting properly but then why do I not get the option to right click?
check if you have any previous installations ( for example : mysql,MariaDB ..ect ) and open task manager and see the proccess of mysql ( open the properties ) if the path isn't from the wamp mysql then desactivate it / kill the process.
here's FAQ Link that helped me alot in the past , you may find it usefull

Transparent UI / hidden UI after BringToForeground

I am programming in C++ using Qt (on Windows), I have a GUI application that can be run on the command line so that users can schedule it to be run using Scheduled Tasks.
Everything was working fine (I think), except when a user tried to schedule the task with the "run when user is logged on or not" option is checked. In this instance the application would run fine, but not pop up the GUI.
I thought maybe my problem was similar to this: https://serverfault.com/questions/101671/scheduled-tasks-w-gui-issue
I thought I found the issue because my GetProcID call was returning a list of ProcessId's and I was only using the first one it returned, which caused some issues. That process ID was then passed to BringToForeground.
After this change it now brings up a transparent, or non-existent other than the application icon on some machines (basically every test except my 3 machines that can debug). Works exactly as required on my test machines.
The application works well if the GUI app is already running and you make the same call on the command line (it passes the call to that process to run). The app also works fine in normal UI mode, (no command line params passed)
EDIT:
Does anyone have any ideas what might cause this? I am thinking it has something to do with the app not starting on the correct Desktop, but don't have a ton of experience with those and have no idea where to even begin.
EDIT 2: Only seem to have the issue when it is run remotely, or through virtualization. (still confirming if this is truly the case)

QTP+VM: Why is the Click command not executed when I'm not conncted to the VM via Remote Desktop?

I'm using QTP 10 together with VMWare to test a Siebel Application.
I'm executing the following code to click on a Save button.
Browser("Siebel").Dialog("Filedownload").WinButton("Save").Click
The code works perfectly fine when I'm connected to the VM via Remote Desktop.
On the other side, when I'm starting the QTP test through the scheduler, without having a Remote Desktop connection, the code above fails without any error message. The WinButton is simply not clicked.
Any idea?
Just to add from my experience.
In some companies I worked for I couldn't change screensaver or standby settings due to security policy. A PC was bringing up screensaver during long synchronization periods (like generating really big report), and execution was broken.
To avoid that I created simple "Anti Sleep" function that slightly "moves" mouse every 5 minutes.
http://automation-beyond.com/2009/08/18/anti-sleep-function/
Private Const SleepTime_Max = 300 ‘ 5 minutes
Public Function AntiSleep()
Dim iter
Dim objTimer
Dim objDeviceReplay
Dim intTimeElapsed
Set objTimer = MercuryTimers(“AntiSleep”)
intTimeElapsed = CInt(objTimer.ElapsedTime/1000)
If intTimeElapsed = 0 Then
MercuryTimers(“AntiSleep”).Start
Exit Function
End If
If intTimeElapsed < SleepTime_Max Then
Exit Function
End If
Set objDeviceReplay = CreateObject(“Mercury.DeviceReplay”)
For iter = 100 To 110
objDeviceReplay.MouseMove iter,300
Next
MercuryTimers(“AntiSleep”).Start
Set objDeviceReplay = Nothing
End Function
Example of using it in a custom synchronization function:
http://automation-beyond.com/2009/08/20/gui-object-synchronization-custom-function/
Thank you,
Albert Gareev
QTP can't interact with a locked desktop, that's why it'll only work for you when logged in interactively either locally or over RDP. It's a well known limitation of QTP, most automation engineers go through this pain at some point. :)
To be more specific, it can't interact with Win32 objects (can't think of a better way of putting it), so it'll interact with basic browser controls on a locked desktop no problem, but browser popups and Windows applications can't be interacted with in those circumstances.
I strongly recommend (if your system policy allows) that you install something like UltraVNC or another VNC variant to interact with your remote machines. That way you can leave the remote machine's desktop logged on and active at all times. Since it's a VM that shouldn't cause you any major security problems either. Make sure you turn off any screen savers and don't auto-lock the desktop too. QTP should work just fine for you if you do that.

Testing running condition of a Windows app

I have several applications that are part of a suite of tools that various developers at our studio use. these applications are mainly command line apps that open a DOS cmd shell. These apps in turn start up a GUI application that tracks output and status (via sockets) of these command line apps.
The command line apps can be started with the user is logged in, when their workstation is locked (they fire off a batch file and then immediately lock their workstation), and when they are logged out (via a scheduled task). The problems that I have are with the last two cases.
If any of these apps fire off when the user is locked or logged out, these command will spawn the GUI windows which tracks the output/status. That's fine, but say the user has their workstation locked -- when they unlock their workstation, the GUI isn't visible. It's running the task list, but it's not visible. The next time these users run some of our command line apps, the GUI doesn't get launched (because it's already running), but because it's not visible on the desktop, users don't see any output.
What I'm looking for is a way to tell from my command line apps if they are running behind a locked workstation or when a user is logged out (via scheduled task) -- basically are they running without a user's desktop visible. If I can tell that, then I can simply not start up our GUI and can prevent a lot of problem.
These apps that I need to test are C/C++ Windows applications.
I hope that this make sense.
I found the programmatic answer that I was looking for. It has to do with stations. Apparently anything running on the desktop will run on a station with a particular name. Anything that isn't on the desktop (i.e. a process started by the task manager when logged off or on a locked workstation) will get started with a different station name. Example code:
HWINSTA dHandle = GetProcessWindowStation();
if ( GetUserObjectInformation(dHandle, UOI_NAME, nameBuffer, bufferLen, &lenNeeded) ) {
if ( stricmp(nameBuffer, "winsta0") ) {
// when we get here, we are not running on the real desktop
return false;
}
}
If you get inside the 'if' statement, then your process is not on the desktop, but running "somewhere else". I looked at the namebuffer value when not running from the desktop and the names don't mean much, but they are not WinSta0.
Link to the docs here.
You might be able to use SENS (System Event Notification Services). I've never used it myself, but I'm almost positive it will do what you want: give you notification for events like logon, logoff, screen saver, etc.
I know that's pretty vague, but hopefully it will get you started. A quick google search turned up this, among others: http://discoveringdotnet.alexeyev.org/2008/02/sens-events.html
I have successfully used this approach to detect whether the desktop is locked on Windows:
bool isDesktopLocked = false;
HDESK inputDesktop = OpenInputDesktop(0, FALSE,
DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW |
DESKTOP_ENUMERATE | DESKTOP_SWITCHDESKTOP |
DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS |
DESKTOP_WRITE);
if (NULL == inputDesktop)
{
isDesktopLocked = true;
}
else
{
CloseDesktop(inputDesktop);
}