VikFra Posted November 28, 2013 Posted November 28, 2013 I've been using AutoIt in Windows 98, Windows XP, and Windows 7 without a problem. But in Windows 8 the following command, which switches from one window to another, just refuses to work: Send("!{TAB}") Why?
Bester Posted November 28, 2013 Posted November 28, 2013 Have you tried? Send("{LWINDOWN}") Send("{TAB 2}") Send("{LWINUP}")
DW1 Posted November 28, 2013 Posted November 28, 2013 (edited) I'm sure somebody will correct me if I'm wrong here, but I think the issue is Windows 8 requires UIAccess = True in the manifest file like this: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> <security> <requestedPrivileges> <requestedExecutionLevel level="asInvoker" uiAccess="true"/> </requestedPrivileges> </security> </trustInfo> </assembly> You can use "#AutoIt3Wrapper_Res_File_Add=<filename>" to add this to the file at compile. That being said, I'm not sure you can request UIAccess=True without being digitally signed. I'm poking around and will update if I see a way. Somebody smarter than me will hopefully come along and provide us both with some knowledge on the subject. EDIT (after testing): It can work but the following conditions must be met: -UIAccess=True in the manifest. -Must be digitally signed. You can do this yourself with makecert and then add your cert to your cert store. -Executable must be run from a "trusted" location like Program Files Meeting the above requirements I was able to simulate Alt-Tab in Windows 8.1 just fine, but what a pain in the ass. If for some odd reason you NEED to automate Alt-Tab, I'll include the steps below, but I would recommend moving to WinActivate() to avoid this mess, as it will not require any of the above and can be used to make your own Alt-Tab action. Steps to create the cert, add it to your local machines, and sign your executable with it (found on msdn forums): 1) Open an elevated command prompt - Click start - Find Cmd Shell or command prompt - Right-click, click Run As Administrator 2) Create a trusted root certificate - Browse to the folder that you wish to contain a copy of the certificate - In the command shell, execute the following commands: makecert -r -pe -n "CN=Test Certificate - For Internal Use Only" -ss PrivateCertStore testcert.cer certmgr.exe -add testcert.cer -s -r localMachine root 3) Sign your file - In the command shell, browse to the location of your exe - In the command shell, type: SignTool sign /v /s PrivateCertStore /n "Test Certificate - For Internal Use Only" /t http://timestamp.verisign.com/scripts/timestamp.dll APP.exe Where APP.exe is your application. EDIT2: If you don't have the cert/signing tools from above, you will need to grab the Windows SDK for Windows 8 or 8.1 Edited November 28, 2013 by danwilli AutoIt3 Online Help
KaFu Posted November 28, 2013 Posted November 28, 2013 (edited) The SwitchToThisWindow function allows for Alt+Tab simulation, >here's an example. Don't know if it still works on Win8. Though be aware... [This function is not intended for general use. It may be altered or unavailable in subsequent versions of Windows.] Edited November 28, 2013 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
DW1 Posted November 28, 2013 Posted November 28, 2013 (edited) The SwitchToThisWindow function allows for Alt+Tab simulation, >here's an example. Don't know if it still works on Win8. KaFu, that does indeed work on both 8 and 8.1, though I'm not sure it would be any different than WinActivate(). Interesting though, and new to me Edited November 28, 2013 by danwilli AutoIt3 Online Help
VikFra Posted November 29, 2013 Author Posted November 29, 2013 Thank you so much guys for your suggestions, I learned from all of them. In the end I made a synthesis according to my limited experience in programming: Global $Flag = 1 (...) Select Case $Flag = 1 Send("#1") Global $Flag = 2 Case $Flag = 2 Send("#2") Global $Flag = 1 EndSelect I start by defining a variable $Flag with a value of 1. When the moment comes of using the Function, I put a Select/Case sequence to switch the $Flag from 1 to 2 to 1, while using the [Windows Key]+1 or [Windows Key]+2 combination, that works perfectly fine in Windows 8. The caveat is that I need to slide the 2 applications to the leftmost position of the Taskbar, but considering the benefits that I get in terms of releasing the pressure on my sore finger articulations, it's well worth it. (It's a lot easier to press the [ ` ] key using only one finger in a natural position, than it is to press the [ Alt ] + [ Tab ] combination using two fingers in awkward positions). Thank you again!
Jeff987 Posted September 27, 2014 Posted September 27, 2014 hey gang, I have been using this switchtothiswindow and it works with my script when running within autoit or after compiling. I do have a problem, when I reboot the box and run my program from any number of ways automatically it will not switch to the windows being called. I had put in msgbox's to show progress for the window handle and window title to prove that it was performing the proper commands.... I would loose focus of the current window and it would show my msgbox debug's and not switch. Is there something special about launching applications at startup that causes the user32.dll switchtothiswindow function to not work properly?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now