MSFN Forum: AutoIt Unfocused Windows? - MSFN Forum

Jump to content



Unattended CD/DVD Guide Homepage · MSFN Forum Rules

Welcome to the Applications Installs forum. Make sure you read the forum rules before you start posting.

Links/Requests to warez and/or any illegal material (porn, cracks, serials, etc..) will not be tolerated. Discussion of circumventing WGA/activation/timebombs/keygens or any other illegal activity will also not be tolerated.

We try our best to keep this forum clean of illegal content. If you see any illegal activity use the "report" button you find in every post to report the specific post to the moderators. If you ignore any of the rules you will be banned without notice.

Read Forum Rules
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

AutoIt Unfocused Windows? Rate Topic: -----

#1 User is offline   RandomClown 

  • Group: Members
  • Posts: 8
  • Joined: 28-October 08

Posted 28 October 2008 - 12:46 AM

Hello, I have been over the internet for a while now, & I didnt see how to focus on a window.
Is there no way to do it? Or are my eyes bad from hours of reading? :wacko:



Since I didnt see it, I might have to do this instead; I wanted to write a little script that will:
* Perform a "IF WinActive()" check 10 times, once per second.

- If the window was active during the check, do a Goto to get out of the messy script & goto the main script.

- If the window did not focus during the check, do that code then goto the script:
MouseMove(@DesktopWidth/2, @DesktopHeight/2-30, 0)
MouseClick("primary")



ima go to sleep now.
ive been reading & typing all day..
thanks for reading.


#2 User is offline   radix 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 715
  • Joined: 08-February 07

Posted 28 October 2008 - 06:54 AM

View PostRandomClown, on Oct 28 2008, 08:46 AM, said:

I didnt see how to focus on a window.

If I understand right, you need to use WinActivate function.

This post has been edited by radix: 28 October 2008 - 06:55 AM


#3 User is offline   RandomClown 

  • Group: Members
  • Posts: 8
  • Joined: 28-October 08

Posted 28 October 2008 - 05:07 PM

oooohhh that could stand alone?

I thought it was a checking thingy for If() funcs.
AutoIT is more powerful then I thought.

Thanks a lot!



EDIT [not to double post]

How would I set 2 conditions in a While statement?
- There is the i++ thing
[something like that] I saw in the very useful help file
- Where is the &&?

I want to set a While() with these conditions:
- Run at most 10 times
- Check if "Some Window" is up

...hmm I just saw this right now: "ExitLoop".
I could do an If("Some Window" is up){ExitLoop}
[of course in AutoIT language], but I want to cut off 3 lines from the tiny check script if possible.


This post has been edited by RandomClown: 28 October 2008 - 05:24 PM


#4 User is offline   Nick_White 

  • Member
  • PipPip
  • Group: Members
  • Posts: 137
  • Joined: 14-March 08

Posted 30 October 2008 - 04:54 AM

$i=1
While ($i<=10)
	If (WinActive("Window title")) Then
		ExitLoop
	EndIf
	$i = $i + 1
	Sleep(1000)
WEnd


#5 User is offline   MHz 

  • SendToA3X v1.7
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,634
  • Joined: 02-August 04

Posted 30 October 2008 - 08:52 AM

Welcome to the forum RandomClown, :)

View PostRandomClown, on Oct 29 2008, 09:07 AM, said:

How would I set 2 conditions in a While statement?
- There is the i++ thing something like that I saw in the very useful help file
- Where is the &&?

AutoIt supports only the operators under "Language Reference" catagory in the help file supplied within the installation of AutoIt3.

Quote

I want to set a While() with these conditions:
- Run at most 10 times
- Check if "Some Window" is up

You may use as Nick White displays or you could use a For...Next loop that is suitable for limited looping by using a counter variable. Using AdlibEnable() function may also be suitable for detection in your script. The choice is for you to make. I made example code below.

 
; title of test window
$title = 'Target Window'

; create a window to test with
GUICreate($title)
GUISetState()

; run the _Adlib() function every 2 seconds to check for the test window
AdlibEnable('_Adlib', 2000)

Sleep(2000)

; activate the test window if needed
If Not WinActive($title) Then
	WinActivate($title)
EndIf

; loop 10 times
For $i = 1 To 10
	; check if test window is active
	If WinActive($title) Then
		; disable the _Adlib() function check
		AdlibDisable()
		; show the result
		SplashTextOn('For...Next Loop', 'Window is active', 200, 50)
		Sleep(2000)
		SplashOff()
		; enable the _Adlib() function check
		AdlibEnable('_Adlib', 2000)
		; exit the For...Next Loop
		ExitLoop
	EndIf
	Sleep(500)
Next

Sleep(5000)

Exit

Func _Adlib()
	; Adlib function to show result while the main code is executing
	SplashTextOn('_Adlib() function', 'Window is active', 200, 50)
	Sleep(1000)
	SplashOff()
	Sleep(250)
EndFunc
 


Quote

...hmm I just saw this right now: "ExitLoop".
I could do an If("Some Window" is up){ExitLoop} [of course in AutoIT language], but I want to cut off 3 lines from the tiny check script if possible.

Single line If...Then... are allowed though your mention of removing 3 lines is beyond my understanding to answer with the information supplied.

#6 User is offline   RandomClown 

  • Group: Members
  • Posts: 8
  • Joined: 28-October 08

Posted 31 October 2008 - 04:07 PM

Thanks for the welcome!

Hey thanks for the info guys, I just learned a few things from your responses.


MHz:
Single line If...Then... are allowed though your mention of removing 3 lines is beyond my understanding to answer with the information supplied.

Oops! Did I write 3? I meant a lot.
This is what I wrote before revisiting this thread:

$i = 0
While $i <= 60
$i = $i + 1
Sleep(1000)
If WinActive("setup") Then
ExitLoop
EndIf
WinActivate("setup")
WEnd
WinWaitActive("setup")
ControlClick("setup", "", "[CLASS:Button; INSTANCE:##]")
WinWaitClose("setup")
Exit

This is way more than 3 lines..I meant a lot

The code you wrote is beyond my understanding. :D

I made the code on 1 line before & I got error messages.
Is there a way to make it all on 1 line?

For now, I will replace my script with Do Untils

This post has been edited by RandomClown: 31 October 2008 - 09:21 PM


#7 User is offline   MHz 

  • SendToA3X v1.7
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,634
  • Joined: 02-August 04

  Posted 01 November 2008 - 09:38 AM

View PostRandomClown, on Nov 1 2008, 08:07 AM, said:

I made the code on 1 line before & I got error messages.
Is there a way to make it all on 1 line?

Controlclick() normally works with an inactive window so this may do the task as being 1 line.
If WinWait("setup") And ControlClick("setup", "", "[CLASS:Button; INSTANCE:##]") Then WinWaitClose("setup")


#8 User is offline   RandomClown 

  • Group: Members
  • Posts: 8
  • Joined: 28-October 08

Posted 03 November 2008 - 12:15 AM

thanks

I am also trying this for buttons disabled while installing:

Do Sleep(200)
Until ControlCommand($title, , 'Button2', 'IsEnabled', '')
ControlClick($title, "", "[CLASS:Button; INSTANCE:2]")


It keeps crashing at the until.
I want to make it wait until it is enabled.
Did I use the wrong code?

- The window is called setup; I used $title you guys showed me.
- The button is named Button2,

This post has been edited by RandomClown: 03 November 2008 - 12:20 AM


#9 User is offline   MHz 

  • SendToA3X v1.7
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,634
  • Joined: 02-August 04

  Posted 03 November 2008 - 10:48 AM

View PostRandomClown, on Nov 3 2008, 04:15 PM, said:

Do Sleep(200)
Until ControlCommand($title, , 'Button2', 'IsEnabled', '')
ControlClick($title, "", "[CLASS:Button; INSTANCE:2]")

Put the Do keyword on a line of it's own to avoid the error condition.
Do
	Sleep(200)
Until ControlCommand($title, , 'Button2', 'IsEnabled', '')
ControlClick($title, "", "[CLASS:Button; INSTANCE:2]")

You can use [ CODE ] ... [/ CODE ] tags (without spaces in the tags) to post code segments in this forum.

#10 User is offline   RandomClown 

  • Group: Members
  • Posts: 8
  • Joined: 28-October 08

Posted 06 November 2008 - 11:07 AM

thanks for the reminder. I forgot I was on a coding forum.
:D

hmm.

Still not working.
I am getting a Line -1: error.

**EDIT** I read it wrong. It said Line -1:, not Line: -1

It crashes after 2 seconds...
I wonder where that is. ;)
ControlCommand is a command right?
can commands be used as umm...
..forgot the term.. as a comparison? [whiles, ifs, do untils, !='s, other stoofs]

$title = 'setup'
Do
	Sleep(1000)
	WinActivate($title)
Until WinActive($title)
sleep(2000)
Do
	Sleep(200)
Until ControlCommand($title, , 'Button2', 'IsEnabled', '')
ControlClick($title, "", "[CLASS:Button; INSTANCE:2]")

This post has been edited by RandomClown: 06 November 2008 - 08:13 PM


#11 User is offline   RandomClown 

  • Group: Members
  • Posts: 8
  • Joined: 28-October 08

Posted 06 November 2008 - 08:32 PM

OMG I found the problem!!

command($title, , 'Button2', 'IsEnabled', '')
**TO**
command($title, '', 'Button2', 'IsEnabled', '')


got to have the ''

If you didnt know, use that to help other users in the future.

W00T!

This post has been edited by RandomClown: 06 November 2008 - 08:34 PM


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy