Sign in to follow this  
Followers 0
GoogleDude

display tool tip while function running

6 posts in this topic

I tried to use a While statement to display a traytip of the script status while running a function but its not working!

My script calls a _GetIP() function and it takes a few before it set the $VAR. What I was looking to do it display a tooltip saying something like "Please wait wil I detect your IP." Then when the $var gets set it continues with the script. But I dont get the tray tip until after the _GetIP() is done running (which I guess kinda makes sense).

I based my code snippet from the INetGet sample in Help

#include <INet.au3>
TraySetState(2)
_GetIP()

While _GetIP()
  TrayTip("Please wait", "Detecting your IP Address", 10, 16)
  Sleep(250)
Wend

As always Thanks for any help!

GoogleDude

Share this post


Link to post
Share on other sites



Wow...

#include <INet.au3>
TraySetState(2)

$GetIP = _GetIP()

While $GetIP <> ""
  TrayTip("Please wait", "Detecting your IP Address", 10, 16)
  Sleep(250)
Wend
Did you bother to test your code? It's no different than the OP <> "" is no different than what he has.

Besides that... you don't get to the loop until _GetIP() is done.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Besides that... you don't get to the loop until _GetIP() is done.

Thats kinda what I was thinking, But how comb it works with @InetGetActive? Is it becuase its a Macro?

GoogleDude

Share this post


Link to post
Share on other sites

Try this:

#include <INet.au3>

Global $t1, $h1, $sIP

$t1 = _CallBackSetTimer($h1, "_TrayIPMsg", "int", "", 0, 0, 250)
Sleep(3000)

$sIP = _GetIP()
_CallBackKillTimer($h1, $t1)
MsgBox(64, "Info", "Your IP is: " & $sIP)

Func _TrayIPMsg()
    If $sIP = "" Then TrayTip("Please wait", "Detecting your IP Address", 10, 16)
EndFunc

Func _CallBackSetTimer(ByRef $hHMOD, $sFuncName, $vReturnType, $vParams, $hWnd, $nEventID, $nEventTime)
    Local $hTimer
    $hHMOD = DllCallbackRegister($sFuncName, $vReturnType, $vParams)
    If @error Then Return SetError(@error, 1, 0)
    $hTimer = DllCall("User32.dll", "int", "SetTimer", "hwnd", $hWnd, _
            "uint", $nEventID, "uint", $nEventTime, "ptr", DllCallbackGetPtr($hHMOD))
    If @error Then Return SetError(@error, 2, 0)
    If IsArray($hTimer) Then Return $hTimer[0]
    Return SetError(3, 0, 0)
EndFunc   ;==>_CallBackSetTimer

Func _CallBackKillTimer($hMOD, $hTimer, $hWnd = 0)
    DllCallbackFree($hMOD)
    DllCall("user32.dll", "int", "KillTimer", "hwnd", $hWnd, "int", $hTimer)
    If @error Then Return SetError(@error, 0, 0)
    Return 1
EndFunc   ;==>_CallBackKillTimeroÝ÷ ØêÓ+ºÚ"µÍÚ[ÛYH   ÒS]]LÉÝÂÛØ[   ÌÍÜÒTYX[XJ  ][Ý×Õ^RTÙÉ][ÝËL
BÛY
Ì
BÌÍÜÒTHÑÙ]T

BÙÐÞ
    ][ÝÒ[É][ÝË ][ÝÖ[ÝTΠ   ][ÝÈ  [È ÌÍÜÒT
B[ÈÕ^RTÙÊ
BRY ÌÍÜÒTH  ][ÝÉ][ÝÈ[^U
    ][ÝÔXÙHØZ]  ][ÝË  ][ÝÑ][È[ÝTYÜÉ][ÝËLMB[[
The sleep is because I got my IP so fast I wanted to see it working anyway.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Try this:

#include <INet.au3>

Global $t1, $h1, $sIP

$t1 = _CallBackSetTimer($h1, "_TrayIPMsg", "int", "", 0, 0, 250)
Sleep(3000)

$sIP = _GetIP()
_CallBackKillTimer($h1, $t1)
MsgBox(64, "Info", "Your IP is: " & $sIP)

Func _TrayIPMsg()
    If $sIP = "" Then TrayTip("Please wait", "Detecting your IP Address", 10, 16)
EndFunc

Func _CallBackSetTimer(ByRef $hHMOD, $sFuncName, $vReturnType, $vParams, $hWnd, $nEventID, $nEventTime)
    Local $hTimer
    $hHMOD = DllCallbackRegister($sFuncName, $vReturnType, $vParams)
    If @error Then Return SetError(@error, 1, 0)
    $hTimer = DllCall("User32.dll", "int", "SetTimer", "hwnd", $hWnd, _
            "uint", $nEventID, "uint", $nEventTime, "ptr", DllCallbackGetPtr($hHMOD))
    If @error Then Return SetError(@error, 2, 0)
    If IsArray($hTimer) Then Return $hTimer[0]
    Return SetError(3, 0, 0)
EndFunc   ;==>_CallBackSetTimer

Func _CallBackKillTimer($hMOD, $hTimer, $hWnd = 0)
    DllCallbackFree($hMOD)
    DllCall("user32.dll", "int", "KillTimer", "hwnd", $hWnd, "int", $hTimer)
    If @error Then Return SetError(@error, 0, 0)
    Return 1
EndFunc   ;==>_CallBackKillTimeroÝ÷ ØêÓ+ºÚ"µÍÚ[ÛYH   ÒS]]LÉÝÂÛØ[   ÌÍÜÒTYX[XJ  ][Ý×Õ^RTÙÉ][ÝËL
BÛY
Ì
BÌÍÜÒTHÑÙ]T

BÙÐÞ

    ][ÝÒ[É][ÝË ][ÝÖ[ÝTΠ   ][ÝÈ  [È ÌÍÜÒT
B[ÈÕ^RTÙÊ
BRY ÌÍÜÒTH  ][ÝÉ][ÝÈ[^U
    ][ÝÔXÙHØZ]  ][ÝË  ][ÝÑ][È[ÝTYÜÉ][ÝËLMB[[
The sleep is because I got my IP so fast I wanted to see it working anyway.
As always that did the trick. Next time im in town I owe you a beer or 2 or 3 or 4. You get the point!

Thanks again.

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