inmysights Posted August 2, 2009 Posted August 2, 2009 Hello, I am new to autoit and think it is a great tool! I have read some of the tutorials and understand the basics to get going now. I have one question which seems rather simple to do but I think I am missing something. can you please explain if I understand this wrong: ; Run Notepad Run("notepad.exe") ; Wait for the Notepad become active - it is titled "Untitled - Notepad" on English systems WinWaitActive("Untitled - Notepad") Does WinWaitActive set the focus for the script to run on that instance of that notepad? that is how I am reading that. I tried to make my own script with this, and it just runs on my desktop, it wont set focus to the screen I have open, how do you set autoit to run a script on a open window? Thank you!
water Posted August 2, 2009 Posted August 2, 2009 (edited) Hi,welcome to the forum.Here you'll find a good example that takes data from a GUI and inserts it into Notepad. It shows how to wait for a window and set focus to it. Edited August 2, 2009 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Info Posted August 2, 2009 Posted August 2, 2009 RunWait("notepad.exe") ;Will run notepad and pause the script until the window exists WinActivate("Untitled - Notepad") ;Will activate the window Send("Hey! I just used the Send function!")
inmysights Posted August 2, 2009 Author Posted August 2, 2009 Thank you, got it to set focus to the window, WinActivate did the trick! Why does this not work? WinActivate("Untitled - Notepad") MouseClickDrag("left", 500, 700, 500, 300) Instead of dragging inside my instance of notepad, it defaults to my windows desktop and drags there? How to I get it to stay in notepad and drag? thank you
AdmiralAlkex Posted August 2, 2009 Posted August 2, 2009 Why would you want to drag inside your notepad? Seems pointless, but if you really need it try setting MouseCoordMode to 0 or 2. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
somdcomputerguy Posted August 2, 2009 Posted August 2, 2009 Function AutoItSetOptionUse 2 = relative coords to the client area of the active window - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
inmysights Posted August 2, 2009 Author Posted August 2, 2009 that worked, than you for your help!!!!!!
martin Posted August 2, 2009 Posted August 2, 2009 RunWait("notepad.exe") ;Will run notepad and pause the script until the window exists WinActivate("Untitled - Notepad") ;Will activate the window Send("Hey! I just used the Send function!") Perhaps you should have tried that Info. >_< Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Info Posted August 2, 2009 Posted August 2, 2009 Perhaps you should have tried that Info. What do you mean? >_<
inmysights Posted August 2, 2009 Author Posted August 2, 2009 is this proper logic: AutoItSetOption ( "PixelCoordMode" , 2 ) $var = PixelGetColor( 10 , 100 ) If $var <> $var Then MouseClick("left") EndIf What I want to do is, if the pixel color stored in var changes to any other color that what I stored there on the active window, then it will left click for me. Thank you
AdmiralAlkex Posted August 2, 2009 Posted August 2, 2009 What do you mean? Just try it once and you will see >_< .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
Info Posted August 2, 2009 Posted August 2, 2009 (edited) Ah. Runs an external program and pauses script execution until the program finishes.Run("notepad.exe") WinWaitActive("Untitled - Notepad") WinActivate("Untitled - Notepad") Send("Hey! I just used the Send function!") >_< Edited August 2, 2009 by Info
herewasplato Posted August 2, 2009 Posted August 2, 2009 Ah. Run("notepad.exe") WinWaitActive("Untitled - Notepad") WinActivate("Untitled - Notepad") Send("Hey! I just used the Send function!") >_< Did you actually run the code? Runwait was not your only error. And now you have added a WinWaitActive before a WinActivate??? You will need to use the "raw" parm for Send... When it is simple code like this - just run it before posting. {I'm not picking on ya - just pointing out a good practice.} [size="1"][font="Arial"].[u].[/u][/font][/size]
inmysights Posted August 2, 2009 Author Posted August 2, 2009 I am still trying to get this to work, is it correct? logic seems right, but it does not work. AutoItSetOption ( "PixelCoordMode" , 2 ) $var = PixelGetColor( 10 , 100 ) If $var <> $var Then MouseClick("left") EndIf What I want to do is, if the pixel color stored in var changes to any other color that what I stored there on the active window, then it will left click for me. Thank you
Info Posted August 2, 2009 Posted August 2, 2009 Did you actually run the code?Runwait was not your only error.And now you have added a WinWaitActive before a WinActivate???You will need to use the "raw" parm for Send...When it is simple code like this - just run it before posting.{I'm not picking on ya - just pointing out a good practice.}Actually I did test it at the first time, it didn't work but I thought it's fine because my notepad language is Hebrew.Not only that, the OP said my script helped him. >_<
herewasplato Posted August 3, 2009 Posted August 3, 2009 ... if the pixel color stored in var changes to any other color that what I stored there on the active window, then it will left click for me. ...AutoItSetOption("PixelCoordMode", 2) ;get color info the first time $var = PixelGetColor(10, 100) Do Sleep(99) Until $var <> PixelGetColor(10, 100) ;watch for change MouseClick("left") [size="1"][font="Arial"].[u].[/u][/font][/size]
herewasplato Posted August 3, 2009 Posted August 3, 2009 Actually I did test it at the first time, it didn't work but I thought it's fine because my notepad language is Hebrew.Not only that, the OP said my script helped him. >_<Okay, just avoid special characters like "!" in a send line or add the raw parmSend("Hey! I just used the Send function!", 1)'!'This tells AutoIt to send an ALT keystroke, therefore Send("This is text!a") would send the keys "This is text" and then press "ALT+a". [size="1"][font="Arial"].[u].[/u][/font][/size]
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