Jump to content

Very simple request


 Share

Recommended Posts

Hello i'm quite new to autoIT and i don't know much about this script language, some time ago i found a simple script for my needings but it went lost and im not able to find it again on the web.

It just consisted in a few lines with following actions:

waiting for a certain named window appearing, checking it was on top or selecting it and pressing the hotkey corresponding to the Yes button.

i compiled that script in an exe file and made it launch on startup or whenever i wanted.

then what i just need is some directions on how to make this happening again since i don't know the language, and i'm not sure on what commands suits best for this. also since i have to run the program for several hours or also days the loop shouldnt take much memory but thats not a problem i think...

any help will be appreciated, i just remember it was all written in a few lines and i had just to type in the window name and the proper shortcut key, Hope this post is appropriate to the forum and someone can help me, thanks

PS: did not mention it should continue the task in loop since the window may reappear with the same name

Edited by bandito88
Link to comment
Share on other sites

ok, i've found i can use a structure like:

if WinWaitActive("My window name") then

ControlClick("My window name", "", "[CLASS:Button; TEXT:Yes]")

endif

i have just to find the proper id with the Window info tool, am i doing right? thanks again and sorry for the easy request :)

Edited by bandito88
Link to comment
Share on other sites

ok i've come myself to a solution, but far as i know this is a tiny cpu consuming as i dont like working with the whiles loops:

While(1) 
sleep(50)
if WinWait("this window") then
ControlClick("this window", "", "[CLASS:Button; INSTANCE:1]")
endif
WEnd

is there anyway to improve and make it more light?

Link to comment
Share on other sites

Instead of WinWait, you can use WinExists to see if the window is there and close it appropriately. The While loop will be idled by the sleep if the window doesn't exist. The way you have it now it's constantly waiting for the window until it shows up so the sleep is never used.

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 Gude
How 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

thanks for the answer, i tried your suggestion and noticed that a loop with WinExists and a sleep of 100 is less CPU consuming and the delay does not affect my work.

a last question now, the window i'm looking for appears when i try to open multiple instances of a determinate program, is there any way to associate the script to be ran whenever the program is launched for the first time or in more istances?

my problem is specifically that, when i launch the program to have a second instance of it, appears a confirmation window and the program is not launched.... the best is to crack it and remove the multiple-instance warning but i'm not in the mood for.

Link to comment
Share on other sites

Put a run command that launches your program just before the While 1 line and then use your script/compiled exe to run the program.

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 Gude
How 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...