Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Alt-Tab in macro not always working
#1
Hi all,

I have an issue that I really don't understand. It seems pretty easy and basic, but I can't get it to work.
I am trying to automate the installation of a program. It is basically doing Alt-N for NEXT and a few spaces to select the default options.
There is a problem in the installer and on the last window where it says that it was installed successfully, the window doesn't have the focus. There is a Finish button that can be used with either Enter or Alt-F when the window has focus. I do not have access to that program's code and cannot change this focus issue.

So, what I did to trick it was to do an Alt-Tab on the Finish window, then another Alt-Tab to get back to it. This way, it has the focus and I can finish the install.

The Alt-Tab is working perfectly when I test the macro in Quick Macro.
When I generate a EXE, the Alt-tab fails.

I have tried to increase/decrease the Pauses before and between the Alt-Tab key but it doesn't help either. I tried to run the EXE as admin or not, without any changed to this behaviour.

I am not sure if this can help, but here is my code.
Code:
Copy      Help
OnScreenDisplay "Running installer" 2 0 0 "" 0 0 1|4|128 "spla" 0 0
run    "C:\install\Program.exe"
3
'An             ;; ALT+N
2
'An           ;; ALT+N
2
'V An           ;; ESPACE ALT+N    
2
'An             ;; ALT+N
2
;Do Alt-Tab to bypass focus problem on Finish window
'AT            ;; ALT+TAB
2
'AT            ;; ALT+TAB
'Y              ;; ENTREE
#2
Replace

;Do Alt-Tab to bypass focus problem on Finish window
'AT ;; ALT+TAB
2
'AT ;; ALT+TAB

to

act "Window name"

If it does not work in exe, let exe run as administrator.
#3
Thanks for the help.
It doesn't work though. It brings the window to the front but it still doesn't look like it really has focus.
I execute the code with the ACT at the end. My window comes to the foreground. Then even out of the macro, I hit ENTER on my keyboard (or Alt-F) and it doesn't react.
If I alt-tab twice, then it works.

And this is when I execute directly from QM.

But why wouldn't Alt-tab work? All the other keystrokes I tried work.
When you say "let the exe run as admin" would that be the same as Right-click Run as admin? I've done this and still nothing.
#4
Hahaha I managed to make it work in the most disgraceful way. Any serious programmer would frown upon this but..

At the end of the install I launch Notepad, exit, and then my window has focus Smile

I wonder if this will fail on some computers. I guess most PC have notepad in System32 but.. anyway, the program should be build in a way that the window has focus and the shortcuts actually work!

Thanks for your help, I think you've responses to all my post with success - or guiding me in the proper direction.
#5
if act does not work, maybe there are 2 similar windows, and act finds wrong window. Look in "Explore windows", it is in QM floating toolbar, "More tools" menu. Also, to see what is the active window then, insert this in the macro:
outw win

Quote:But why wouldn't Alt-tab work?
I don't know. Anyway, Alt+Tab is not the best way to activate windows in macros.
Quote:When you say "let the exe run as admin" would that be the same as Right-click Run as admin?
Yes.
#6
Oh, that was it.

I was using a different software to show the Window name. It was showing a different name than what Quick Macro display in the option you explained.

Now it is working as it should - not with a stupid patch as before.

Thanks a lot. I actually purchased the software. I was running in demo mode and this forum has helped me a lot, I have solved all the issues I found during my trial.. so I decided to purchase it. I had tried a different macro software before this one and it didn't work quite as well.

You have great / fast support, congrads.


Forum Jump:


Users browsing this thread: 2 Guest(s)