Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cannot activate window/remove focus from Remote Desktop
#1
I just transferred to a new computer
Copied over the qm file and all my macros are in place.

I have a macro to copy from an Excel file to a window in a Remote Desktop

This macro has worked unchanged for years. On the new pc (same OS, Windows 7 64bit) it won't "act w1" after "act w2"

I realized I hadn't input the registration key. I did and the macro worked once. But everytime now it is back to not "act w1" after "act w2"

Here's a snippet:
Code:
Copy      Help
int w1=act(win("Microsoft Excel" "XLMAIN"))
int w2=win("gpserv - Remote Desktop Connection" "TscShellContainerClass")
spe 700

inp numberofitems "How many items?" "QM Input"
if numberofitems = 0
    end
inp warehouse "Warehouse?" "QM Input" "KD01"
quick = mes("Express?" "" "YN")

if quick = 'Y'
    act w1
    'CcR
    act w2
    wait 4
    'CvTT
    wait 1
    act w1
    'CcLD
    act w2
    'CvTTT

Instead of the 2nd 'act w1' (4th last line) working, it stays in focus on w2 and does the 'CcLD on w2

please help, this is a macro I use for work everyday.
#2
Try this:
In Options check 'Disable lock foreground window'.
Then in this macro replace act to SetForegroundWindow.
#3
Or don't activate Excel. Replace this code

Code:
Copy      Help
,act w1
,'CcR
,act w2
,wait 4
,'CvTT
,wait 1
,act w1
,'CcLD
,act w2
,'CvTTT

to

Code:
Copy      Help
,ExcelSheet es.Init
,Excel.Range r=es._Range("sel")
,str s1=r.Value
,str s2=r.Offset(0 1).Value
,r.Offset(1 0).Select
,out F"{s1} {s2}" ;;delete this line
,
,act w2
,paste s1
,'TT
,paste s2
,'TTT
#4
it goes into a loop so I have to come back to excel for the next row

strange to me that activate won't work but I'll try setforeground...
#5
To copy data from Excel to another app, don't need to activate Excel if you use class ExcelSheet functions, like in the example macro.
#6
Disable "lock foreground window" was already checked on.

changed act to SetForegroundWindow in the macro

same result

checked versions and they differ:
new pc: 2.4.3.5
old pc (which still works fine): 2.4.2.2

does that give a clue?
#7
Doesn't. Your macro works on my computer. QM 2.4.3.8, Windows 10, Excel 2003.

In Options also should be selected Administrator or uiAccess, not User.

Maybe win("Microsoft Excel" "XLMAIN") finds wrong window if there are several windows that match "Microsoft Excel" "XLMAIN". Try to minimize and restore it (in macro).
#8
Administrator was already selected.

okay: played with min with very weird results
so I put min before the first act and it minimized the window and then 'act'ed (raised and gave focus) and continued with macro

I even put the min w1 after act w2 and it found and minimized

So here's the really weird part:
Code:
Copy      Help
if quick = 'Y'
    act w1
    'CcR
    act w2
    wait 4
    'CvTT
    wait 1
    min w1
    act w1
    'CcLD

in the last 3 lines it min'ed w1 but then did the 'CcLD in w2 !!!

were you testing with a remote desktop?
#9
any thoughts?
#10
No more ideas. I tested with Remote Desktop on Windows 10 + Excel 2003, no problems.
#11
Good news Gintaras

Well I've rebooted many times since the problem was happening.

And I've just been using my old machine for this task for the last couple of weeks.

But I gave it a try on the new machine today. It worked. :roll: Big Grin

Some things in computing disappear as mysteriously as they appear.

But thanks for everything Gintaras, I've enjoyed this program for years


Forum Jump:


Users browsing this thread: 1 Guest(s)