Jump to content

Autoit functions fail after first execution


Recommended Posts

I'm trying to do something very simple: close an error message that pops up after most sleeps. Everything I try works the first time, but not after that. A reboot allows me to start over.

The basic function I want to use is WinClose(), but below you can see all the stuff I've been trying after it starts failing (from looking through the forums).

;Opt("WinWaitDelay", 1000)       ;250 millis default
WinWait("Intelliremote","",30)
Dim $r = WinActivate("Intelliremote")
;msgbox(1,"winactivate",$r)
Sleep(500)
;WinKill($r)
;Send("!{F4}",0)
;Send("{ENTER}")
;if 0 = WinClose("Intelliremote") Then
    WinClose("Intelliremote")
    WinKill("Intelliremote")
;Endif
;Opt("WinWaitDelay", 250)

So each function Send, WinClose, WinKill works only once. Any clues?

Thanks,

Carlos

Link to comment
Share on other sites

  • Moderators

cacortes,

Welcome to the AutoIt forum. :)

As the script ends after the first pass it is hardly surprising that it only works once. Try putting it inside a loop to keep it alive. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I failed to make myself clear. After a reboot and appearance of the unwanted "intelliremote" error window, running the script works. That's because it waits up to 30 seconds to find the window, then it activates that window, and then removes it.

The second time the unwanted error window appears, I run the script but it fails to work when it should. It activates the window, but fails to get rid of it as it did the previous time. I don't put a loop in this script because it makes no sense programmatically.

FYI the script is launched via the task scheduler on computer wake up when this error appears.

Thanks for your help.

Link to comment
Share on other sites

No dice on the WinWaitActive. Ultimately I am only activating the window as a matter of trying to fix this problem in the first place. I'd rather not flash the unwanted error window to the foreground. WinKill after WinWait should accomplish what I want perfectly, but of course it doesn't.

I finally found something that works. I throw up a MsgBox with a timeout of 10 seconds after the WinActivate, then I do a bunch of closing operations. Not sure which one is actually working. But I will say this is a pretty ugly solution.

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...