How to Detect a Loading Cursor
Hi! I am automating a application that has uneven timeouts to load object, sometimes it takes 2 seconds to load an object and others almost 20 seconds. Instead of adding delays that will make my automation runs very long I was wondering if there was a why to detect a spinning loading cursor icon either via an operation or a script. Since the loading cursor is the only constant between all runs I think it's the only way to stabilize my automation unless someone has a better idea?
Loading Cursor looks like this:
I have experimented with identifying the current cursor. While it is theoretically possible in Windows applications I would advise against that approach.
The suggestions for using a WaitWindow or WaitProperty are the best way to go. As suggested, you can wait for a particular control (e.g. button) to become enabled with WaitProperty. Alternatively, you may wait for a new window/dialog to open with WaitWindow if that applies to your situation.Here is a VBScript example where I've waited up to 2.5s for a button to become enabled before proceeding:
Call o_SavBtn.WaitProperty("Enabled",True,2500) 'Wait for the button to be enabled
Below is some VB code from my attempt using the Win32 API to identify the current mouse cursor in case you want to go down that rabbit hole (not advised). This is from several years ago. I can't remember if I ever got it working.
Function getCurrentCursor(wndObj) Dim pid, tid, crsr pid = Win32API.GetWindowThreadProcessId(wndObj.Handle, Nothing) tid = Win32API.GetCurrentThreadId Call Win32API.AttachThreadInput(pid, tid, True) crsr = Win32API.GetCursor Call Win32API.AttachThreadInput(pid, tid, False) getCurrentCursor = crsr End Function Function getCursorType(id, global_cache) Dim res res = id Select Case id Case 65541 res = "Arrow" Case 65541 res = "Move" Case 429134809 res = "Horizontal resize" Case 13569245 res = "Motor" Case 25758991 res = "Utility" Case 256118743 res = "Bus" Case Else res = "Other" End Select getCursorType = res End Function