Gambler71 Posted March 5, 2014 Share Posted March 5, 2014 Firstly, I am not a programmer, but my code works, however, it visually appears messy as the metro app that I call will start on monitor 1, then move to monitor 2. Also, depending upon the speed of the machine (I tested my script on another computer that was slower) I have to adjust the second sleep parameter. #NotrayIcon Local $_MyName = "Facebook" Send("{RWIN} " & $_MyName) Sleep(1) Send("{ENTER}") Sleep(1000) Send('{SHIFTDOWN}{LWINDOWN}{RIGHT}{LWINUP}{SHIFTUP}') What I am trying to achieve: 1. start apps from the desktop 2. make them display on a specific monitor without starting on the primary monitor first I think it must be able to be done, as when I start metro from the charms menu of a specific monitor, it always displays metro on that monitor straight away. NOTE: you can change $_MyName = "Facebook" to any app name, eg $_MyName = "Store" or $_MyName = "Digital Table Clock" NOTE2: if you remove the bottom 2 lines of code you can start any app from the desktop onto the primary monitor Link to comment Share on other sites More sharing options...
Solution Gambler71 Posted March 8, 2014 Author Solution Share Posted March 8, 2014 (edited) I am so stupid, it is still a simulate button trick, but I figured it out. Anyway, here is my final code: expandcollapse popup#NotrayIcon Local $_MyName If ($CmdLine[0]=1) Then ;for making a desktop shortcut to a compiled version of this script $_MyName = $CmdLine[1] Else ;incase no command line parameter use file name $_MyName = @ScriptName If (StringCompare(StringRight($_MyName, 4), '.au3')=0) Then $_MyName = StringReplace($_MyName, '.au3', '', -1) ElseIf (StringCompare(StringRight($_MyName, 4), '.exe')=0) Then $_MyName = StringReplace($_MyName, '.exe', '', -1) EndIf EndIf Send("{RWIN}") Sleep(0) Send('{SHIFTDOWN}{LWINDOWN}{RIGHT}{LWINUP}{SHIFTUP}') Sleep(0) Send($_MyName) Sleep(1) Send("{ENTER}") #cs --------------------------------------------------------------------------------------------------------------- AutoIt Version: 3.3.10.2 #ce --------------------------------------------------------------------------------------------------------------- #Region AutoIt3Wrapper directives section #AutoIt3Wrapper_Icon=Mordern UI Apps 2 Desktop mon2.ico #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Res_Comment=Mordern UI Apps 2 Desktop mon2 #AutoIt3Wrapper_Res_Description=Mordern UI Apps 2 Desktop mon2 #AutoIt3Wrapper_Res_Fileversion=1.0.0.0 #AutoIt3Wrapper_Res_ProductVersion=1.0.0.0 #AutoIt3Wrapper_Res_LegalCopyright=Gambler71 #EndRegion You will notice that this version is slightly different from the first script. Here, I have tried to make a script that I can make a shortcut to, instead of having a whole heap of scripts. You may compile it or just rename the .au3 file (to the "app name.au3"). E.g. assuming you put the .exe file in the following directory "C:Modern UI Apps" then the following would be an example desktop shortcut: "C:Modern UI AppsMordern UI Apps 2 Desktop mon2.exe" "Skype" include quotes. Change Skype to the full name of any app as it appears in metro. All you need is some icons which are easy to get a hold of or make, and you are in business. I do not mind if people wish to copy this code, but please credit me inside your script. NOTE: I have the UAC turned down to the lowest part of the slide bar, but I did not do the registry trick to turn it off. NOTE2: My au3 file was called "Mordern UI Apps 2 Desktop mon2.au3" with my icon being called "Mordern UI Apps 2 Desktop mon2.ico" NOTE3: My computer is pretty fast so if you have a slowish machine and have some problems, try changing the sleep times to 10 or more. Edited March 8, 2014 by Gambler71 Link to comment Share on other sites More sharing options...
FireFox Posted March 8, 2014 Share Posted March 8, 2014 FYI, Sleep cannot take a value under 10 ms. Link to comment Share on other sites More sharing options...
BrewManNH Posted March 8, 2014 Share Posted March 8, 2014 Sleep(0) is a special case. Also, it's not good practice to use it unless you don't mind having your CPU cooked. Also, you can set sleep to under 10, it just won't make any difference if you do. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
FireFox Posted March 8, 2014 Share Posted March 8, 2014 (edited) Good catch, and any negative number is treated as 0 in autoit. Edited March 8, 2014 by FireFox Link to comment Share on other sites More sharing options...
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