Sign in to follow this  
Followers 0
Coded4Decades

is script really paused?

10 posts in this topic

That little icon in the system tray makes me crazy.  But, I am an Autoit rookie so perhaps I just don't know the right tricks.

If I just hover and don't click the following happens:

A "quick hover" (2 seconds of hover then quickly move away) lets me peak at the currently executing line.

A "long hover" (10 seconds of hover, then move away) shows me a peak for about 5 seconds, but the text disappears and Autoit enters a "no peaking" mode where it refuses to give me information about current line for several minutes.

For instance, right now my program is at line 131 where a filecopy of a huge file takes about 5 minutes.

If I do several quick hovers in a row, they all show line  131.  But, as soon as I do a long hover, I get no more information for several minutes.  At first I thought I was crazy, but this behavior is quite repeatable.

So, I have several questions

1) HIGH PRIORITY. Can I get rid of the "no peaking" mode?  It really drives me crazy.

2) Can I get a "constant hover" to continuously peak with a "refresh" every 15 seconds?

The behavior when I click the icon is even more infuriating, but I may be misinterpreting it because of the issues I described above. So, I will postpone asking about clicks until later.

Share this post


Link to post
Share on other sites



Look at the following AutoItSetOption settings in the Help File for working with the tray icon.  If your trying to debug, use the "TrayIconDebug" option set to 1.  To keep the script from pausing, when you click the tray icon, use the "TrayAutoPause" option set to 0.  

Opt("TrayAutoPause", 0) ;0=no pause, 1=Pause
Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info

Adam

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Even with the TrayIconDebug mode, it's not going to show much until the file copy is completed because FileCopy is a blocking function which means the script won't continue until it is done.

 

BTW, you could also create a HotKey to run a function that shows a tooltip whenever you'd like it to, and where ever you'd like it.

Edited by BrewManNH

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

Share this post


Link to post
Share on other sites

I believe the problem is that trayicondebug only shows the line that was executing at the time the mouse was first placed over the icon, no matter how long you leave the mouse there.

Brewman's suggestion would be the way to go.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

The program always had Opt("TrayIconDebug", 1).  And, I am not clicking the icon, so the TrayAutoPause setting is irrelevant.

 

you said <<a long filecopy, even with the TrayIconDebug mode, the tray icon is not going to show much>>

I am only using a long filecopy as an example --  I see this "no peaking allowed" mode in many situations.

Besides, all I want to know is "what line is my program currently running?".  I don't think that is too much to ask of autoit.

If I just hover and leave quickly, the tray icon tells me exactly what a want. But, once I hover too long, it stubbornly refuses to show me anything for a few minutes. 

I hope you'll admit, that is truly stupid behavior.

My workaround for this behavior is to hover then jerk away, sort of like a bartender shaking a martini.

Anyway, I am hoping for a better way to reliably find out what line is currently running. Turning on trace lines is another workaround, but it is overkill and really slows down the program. Plus, it changes all of my line numbers, which can really confuse things.

Can someone give me more details of how to "create a HotKey to run a function that shows a tooltip"

Share this post


Link to post
Share on other sites

Here's a brute-force method of grabbing the information from the tray icon and displaying it in a tooltip.

NOTE: If you've forced closed a script and the icon is still in the tray, it will probably pick that one up and not the currently running script. This script will search in the visible and hidden icons for the proper icon to read the text from. It's not perfect, but it works fairly well.

#include <GuiToolBar.au3>

Opt("TrayIconDebug", 1)
HotKeySet("p", "My_Tooltip")
For $Loop = 1 To 1000000
    $a = Sqrt($Loop)
    ; the following line is used to slow the script down enough to be able to press the hotkey
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $a = ' & $a & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
Next
Func My_Tooltip()
    $Text = Get_SysTray_IconText(@ScriptName)
    If $Text = "" Then
        MsgBox(0, "", "Icon not found")
    Else
        ToolTip($Text, 20, 20)
    EndIf
EndFunc   ;==>My_Tooltip

Func Get_SysTray_IconText($sScriptName = @ScriptName) ; http://www.autoitscript.com/forum/topic/157933-hinttray-tip-how-to-get-text/?p=1145366

    ; Find systray handle for "User Promoted Notification Area"
    Local $hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]')
    If @error Then
        MsgBox(16, "Error", "System tray not found")
        Exit
    EndIf
    ; Find systray handle for "Overflow Notification Area" i.e. hidden icons
    Local $hSysTray_Handle_Hidden = ControlGetHandle('[Class:NotifyIconOverflowWindow]', '', '[Class:ToolbarWindow32;Instance:1]')
    If @error Then
        MsgBox(16, "Error", "System tray not found")
        Exit
    EndIf

    ; Get systray item count
    Local $iSysTray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle)
    If $iSysTray_ButCount = 0 Then
        MsgBox(16, "Error", "No items found in system tray")
        Exit
    EndIf

    Local $sSysTray_ButtonText = ""
    ; Look for wanted tooltip
    For $iSysTray_ButtonNumber = 0 To $iSysTray_ButCount - 1
        $sSysTray_ButtonText = _GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSysTray_ButtonNumber)
        If StringInStr($sSysTray_ButtonText, $sScriptName) Then Return $sSysTray_ButtonText
    Next

    Local $iSysTray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle_Hidden)
    If $iSysTray_ButCount = 0 Then
        MsgBox(16, "Error", "No items found in system tray")
        Exit
    EndIf
    Local $sSysTray_ButtonText = ""

    ; Look for wanted tooltip
    For $iSysTray_ButtonNumber = 0 To $iSysTray_ButCount - 1
        $sSysTray_ButtonText = _GUICtrlToolbar_GetButtonText($hSysTray_Handle_Hidden, $iSysTray_ButtonNumber)
        If StringInStr($sSysTray_ButtonText, $sScriptName) Then Return $sSysTray_ButtonText
    Next

    Return ""

EndFunc   ;==>Get_SysTray_IconText

It's a proof-of-concept script and probably needs some tweaking.


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

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

thanks to brewman for saying <<FileCopy is a blocking function>>

 I have discovered that:

   For commands like filecopy, the tooltip SHOWS PREVIOUSLY COMPLETED LINE info

   For commands like msgbox and sleep, the tooltip SHOWS CURRENT LINE.

   and, for commands like Consolewrite, the tooltip NEVER SHOWS.

   During long running commands, hovers over the tray work, but left and right clicks are silently queued until later. 

After realizing the above, things make a lot more sense.

When I clicked the TrayIconDebug icon, often nothing happened which was very confusing.

It turns out that autoit does not flash red X immediately. It waits until AFTER the current command completes. During that wait, the tooltip continues to report information about the PREVIOUSLY executed command.

So, if a 5 minute filecopy was running, and I clicked the icon it does not start flashing red until 5 minutes later. This was extremely irritating because i might get interrupted during that 5 minutes, and come back an hour later only to discover that my script had been paused for the whole hour !!!

Now that I understand, things are better, but autoit's behavior is still irritating. Once I click to pause, there is no way to change my mind until after the long running command is finished.  So, if an urgent phone call comes in, I am out of luck.

 

I wished the icon immediately changed the tooltip to report something like "pause request queued for later, right click to cancel the request".

But, my wishes are irrelevant, I will work with the tools I am given, and I will close this problem.

By the way, the "brute force"  tooltip shortcut key code is almost certain to have the same problems, so I will not try them out for this question. But I might use those tricks in the future so thanks anyhow.

Edited by Coded4Decades

Share this post


Link to post
Share on other sites

Unless you need the option to pause the script using the icon, you can turn off that feature by the information posted in post #2.


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

Share this post


Link to post
Share on other sites


Thanks for that advice, but I already understood post #2, and I choose to never use Opt("TrayAutoPause", 0) 

That command turns off TWO options:  A) it turns off the "click to pause" option.  B) it turns off the "hover to see line #" option.

I see absolutely no reason to turn off either option.  There is no downside to getting the "hover to see line #" information.  If I don't want to see the info, I simply don't hover over the icon.

And, there is no downside having the "click to pause" option available.  If I don't want to pause the script, I simply don't click on the icon.

 

Yes, I am annoyed that clicking on the icon silently queues the pause request. And I am also annoyed that I cannot cancel the pause that queue, but I can avoid those

annoyances by simply not clicking.

Using  Opt("TrayAutoPause", 0) is a far less flexible choice because it completely removes both options.

Share this post


Link to post
Share on other sites

Thanks for that advice, but I already understood post #2, and I choose to never use Opt("TrayAutoPause", 0)

That command turns off TWO options: A) it turns off the "click to pause" option. B) it turns off the "hover to see line #" option.

No it doesn't, the hovering still shows the line being executed.

 

I see absolutely no reason to turn off either option.  There is no downside to getting the "hover to see line #" information.  If I don't want to see the info, I simply don't hover over the icon.

 

And, there is no downside having the "click to pause" option available.  If I don't want to pause the script, I simply don't click on the icon.

I misunderstood your statement above, I assumed you were doing it by mistake and then coming back to find out it was paused. I didn't realize you intentionally pause the script and forget to unpause it.

 

Yes, I am annoyed that clicking on the icon silently queues the pause request. And I am also annoyed that I cannot cancel the pause that queue, but I can avoid those

annoyances by simply not clicking.

So your issue is what again?

 

Using  Opt("TrayAutoPause", 0) is a far less flexible choice because it completely removes both options.

You can always use "Opt("TrayMenuMode", 1)" and turn off the default menu and roll your own icon context menus. Just another option.


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

Share this post


Link to post
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
Sign in to follow this  
Followers 0