Sign in to follow this  
Followers 0
azeazezar

GUISetIcon-problem

12 posts in this topic

#1 ·  Posted (edited)

I got this function.

Func SetIcon($status)
    Select
        case $status = 0
    GUISetIcon(@ScriptDir & "\down.ico", -1 , $Gui1)
        Case $Status = 1
    GUISetIcon(@ScriptDir & "\online.ico", -1 , $Gui1)
        Case $Status = 2
    GUISetIcon(@ScriptDir & "\busy.ico", -1 , $Gui1)
        Case $Status = 3
    GUISetIcon(@ScriptDir & "\overloaded.ico", -1 , $Gui1)
    EndSelect
EndFunc
oÝ÷ ØâºÇ¢¶)æÊ趦²f¢Z(¦+p¢¹,½êâ~+¬z+bazºZ®Û(^¦º ­©¢µö¢Â-®'¶¬~éܶ*'×hzÌ(®Fî¶+mjG¬iº.·m,'vÆ®¶­s`¤gVæ26WD6öâb33c·7FGW2 6VÆV7@ 66Rb33c·7FGW2Ò vÆRuT6WD6öâ67&DF"fײgV÷C²b3#¶F÷vâæ6ògV÷C²ÂÓÂb33c´wV vVæ@ 66Rb33cµ7FGW2Ò vÆRuT6WD6öâ67&DF"fײgV÷C²b3#¶öæÆæRæ6ògV÷C²ÂÓÂb33c´wV vVæ@ 66Rb33cµ7FGW2Ò  vÆRuT6WD6öâ67&DF"fײgV÷C²b3#¶'W7æ6ògV÷C²ÂÓÂb33c´wV vVæ@ 66Rb33cµ7FGW2Ò0 vÆRuT6WD6öâ67&DF"fײgV÷C²b3#¶÷fW&ÆöFVBæ6ògV÷C²ÂÓÂb33c´wV vVæ@¤VæE6VÆV7@¤VæDgVæ0

Can someone explain me wat i'm doin wrong?

EDIT: added the icon files i'm using

Autoit_scripts.rar

Edited by azeazezar

Share this post


Link to post
Share on other sites



HI,

try this:

Func SetIcon($status)
    Switch $status
        Case 0
            GUISetIcon(@ScriptDir & "\down.ico", -1, $Gui1)
        Case 1
            GUISetIcon(@ScriptDir & "\online.ico", -1, $Gui1)
        Case 2
            GUISetIcon(@ScriptDir & "\busy.ico", -1, $Gui1)
        Case 3
            GUISetIcon(@ScriptDir & "\overloaded.ico", -1, $Gui1)
    EndSwitch
EndFunc   ;==>SetIcon

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

That still doesn't work

*CENSORED*

This is the complete script i'm working with, the function does work to set the icon to down, but doesn otherwise...

Oh, and this is my first script in autoit ^^

Edited by azeazezar

Share this post


Link to post
Share on other sites

That still doesn't work

This is the complete script i'm working with, the function does work to set the icon to down, but doesn otherwise...

Oh, and this is my first script in autoit ^^

Welcome in Autoit comunity :whistle:

As your first script it's good.

Your problem:

In Func ServerWait() use SetIcon(0) instead of GUISetIcon(0)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Welcome in Autoit comunity :)

As your first script it's good.

Your problem:

In Func ServerWait() use SetIcon(0) instead of GUISetIcon(0)

Thank you, i know it had to be somethin like that, but i couldn't find it...

Edit: this fixed only part of the problem

it still doesn't work from the ReadServerPHP() function :whistle:

Edited by azeazezar

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Thank you, i know it had to be somethin like that, but i couldn't find it...

Edit: this fixed only part of the problem

it still doesn't work from the ReadServerPHP() function :whistle:

Local $Server should be Local $ServerStatus

instead of:

Func ReadServerPHP($maintenance = 0)
    InetGet("http://account.conqueronline.com/status.php", @TempDir & "serverstatus.txt", 1)
    Local $Server = FileRead(@TempDir & "serverstatus.txt", 1000)
    If $ServerStatus = 0 Then
    Else
        Local $Status = (StringRight((StringLeft(StringTrimLeft($Server, (StringInStr($Server, "Emerald")) - 1), 9)), 1))
        If $ServerStatus = $Status Then
        Else
            SetIcon($Status)
            $ServerStatus = $Status
        EndIf
    EndIf
    Return $Server
EndFunc  oÝ÷ ÚÚò¶¬jëh×6Func ReadServerPHP($maintenance = 0)
    InetGet("http://account.conqueronline.com/status.php", @TempDir & "serverstatus.txt", 1)
    Local $ServerStatus = FileRead(@TempDir & "serverstatus.txt", 1000)
    If $ServerStatus = 0 Then
    Else
        Local $Status = (StringRight((StringLeft(StringTrimLeft($ServerStatus, (StringInStr($ServerStatus, "Emerald")) - 1), 9)), 1))
        If $ServerStatus = $Status Then
        Else
            SetIcon($Status)
            $ServerStatus = $Status
        EndIf
    EndIf
    Return $ServerStatus
EndFunc  oÝ÷ Úâ~+wöË-Yg¢Ü(®H§Úò¶¬jëh×6Func ReadServerPHP($maintenance = 0)
    InetGet("http://account.conqueronline.com/status.php", @TempDir & "serverstatus.txt", 1)
    Local $ServerStatus = FileRead(@TempDir & "serverstatus.txt", 1000)
    If $ServerStatus = 0 Then
    Else
        Local $Status = (StringRight((StringLeft(StringTrimLeft($ServerStatus, (StringInStr($ServerStatus, "Emerald")) - 1), 9)), 1))
        If $ServerStatus = $Status Then
        Else
            $ServerStatus = $Status
        EndIf
    EndIf
    SetIcon($Status)
    Return $ServerStatus
EndFunc
Edited by Zedna

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Local $Server should be Local $ServerStatus

Dim $ServerStatus = -1<-- is declared globally

instead of:

Func ReadServerPHP($maintenance = 0)
    InetGet("http://account.conqueronline.com/status.php", @TempDir & "serverstatus.txt", 1)
    Local $Server = FileRead(@TempDir & "serverstatus.txt", 1000)
    If $ServerStatus = 0 Then
    Else
        Local $Status = (StringRight((StringLeft(StringTrimLeft($Server, (StringInStr($Server, "Emerald")) - 1), 9)), 1))
        If $ServerStatus = $Status Then
        Else
            SetIcon($Status)
            $ServerStatus = $Status
        EndIf
    EndIf
    Return $Server
EndFunc  oÝ÷ ÚÚò¶¬jëh×6Func ReadServerPHP($maintenance = 0)
    InetGet("http://account.conqueronline.com/status.php", @TempDir & "serverstatus.txt", 1)
    Local $ServerStatus = FileRead(@TempDir & "serverstatus.txt", 1000)
    If $ServerStatus = 0 Then
    Else
        Local $Status = (StringRight((StringLeft(StringTrimLeft($ServerStatus, (StringInStr($ServerStatus, "Emerald")) - 1), 9)), 1))
        If $ServerStatus = $Status Then
        Else
            SetIcon($Status)
            $ServerStatus = $Status
        EndIf
    EndIf
    Return $ServerStatus
EndFunc  oÝ÷ Úâ~+wöË-Yg¢Ü(®H§Úò¶¬jëh×6Func ReadServerPHP($maintenance = 0)
    InetGet("http://account.conqueronline.com/status.php", @TempDir & "serverstatus.txt", 1)
    Local $ServerStatus = FileRead(@TempDir & "serverstatus.txt", 1000)
    If $ServerStatus = 0 Then
    Else
        Local $Status = (StringRight((StringLeft(StringTrimLeft($ServerStatus, (StringInStr($ServerStatus, "Emerald")) - 1), 9)), 1))
        If $ServerStatus = $Status Then
        Else
            $ServerStatus = $Status
        EndIf
    EndIf
    SetIcon($Status)
    Return $ServerStatus
EndFunc

This produces a msgbox with 0 as title, meaning it failed to set the icon, and 1 as text, so online.ico should have been used.

Which is ok since this is the status.php, and the number behind emerald is 1.

Dragon 1 Phoenix 2 Kylin 2 Tiger 2 Lion 1 Eagle 1 Sapphire 2 Ruby 1 Diamond 1 Crystal 1 Emerald 1 Turquoise 1 Triumph 1 Justice 1 Honor 1 Glory 1 Freedom 1 Faith 2 Eternity 2 Dream 1 Volcano 2 Thunder 1 Lightning 1 Sunshine 1 Blizzard 2 Meteor 2 Tornado 2 Snowfall 2 Venus 2 Mercury 3 Mars 2 Jupiter 3 Saturn 2 Uranus 3 Neptune 1 Pluto 2 GreatWall 2 HangingGardens 1 Mausoleum 3 Pharos 2 StatueOfZeus 3 Pyramid 1 ColossusRhodes 2 TempleArtemis 2 Ryee 3 KingJus 3 Arbiter 3 Hebby 2 66666 3 6 3 7 3 8 3 Aquarius 2 Pisces 3 Aries 2 Taurus 3 Gemini 2 Cancer 2 Leo 3
Edited by azeazezar

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

This produces a msgbox with 0 as title, meaning it failed to set the icon, and 1 as text, so online.ico should have been used.

Which is ok since this is the status.php, and the number behind emerald is 1.

Try to rename $Status param in Func SetIcon to something else (it's same as other local variables).

It isn't bad but if you have problems then only for sure.

Other thing: Try to add some ConsoleWrite's:

Func SetIcon($Status_icon)
    Local $name, $ret

    Switch $Status_icon
        Case 0
          $name = "down.ico"
        Case 1
          $name = "online.ico"
        Case 2
          $name = "busy.ico"
        Case 3
          $name = "overloaded.ico"
        Case Else
          $name = "?"
    EndSwitch

    ConsoleWrite("icon name=" & @ScriptDir & "\" & $name)
    ConsoleWrite("GUI=" & $GUi1)
    $ret = GUISetIcon(@ScriptDir & "\" & $name, -1, $Gui1)
    ConsoleWrite("@error=" & @error)
    ConsoleWrite("return=" & $ret)
    return $ret
EndFunc   ;==>SetIcon
Edited by Zedna

Share this post


Link to post
Share on other sites

Func ReadServerPHP($maintenance = 0)
    InetGet("http://account.conqueronline.com/status.php", @TempDir & "serverstatus.txt", 1)
    Local $Server = FileRead(@TempDir & "serverstatus.txt", 1000)
    If $ServerStatus = 0 Then
    Else
        Local $Status = (StringRight((StringLeft(StringTrimLeft($Server, (StringInStr($Server, "Emerald")) - 1), 9)), 1))
        ;If $ServerStatus = $Status Then
        ;Else
        ;   $ServerStatus = $Status
            SetIcon($Status)
            ;MsgBox(0,SetIcon($Status),$Status, 5) ;<-------------this msgbox apears, so my code should be ok....
        ;EndIf
    EndIf
    Return $Server
EndFunc

the SetIcon() function works like it should like this

but with the if ..then...else...endif it doesn't work :whistle:

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

the SetIcon() function works like it should like this

but with the if ..then...else...endif it doesn't work :whistle:

$serverstatus has initial value of 0

so in first test If $serverstatus = $status is: 0 = 0

You should add some Initial value that is not same as expected status, for example:

Dim $serverstatus = -1

and instead of:

If $ServerStatus = $Status Then
Else
   $ServerStatus = $Status
   ...
EndIf
oÝ÷ Úë²)©êÚºÚ"µÍY   ÌÍÔÙÝ]È   ÉÝÈ  ÌÍÔÝ]È[    ÌÍÔÙÝ]ÈH  ÌÍÔÝ]Â[Y
Edited by Zedna

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

$serverstatus has initial value of 0

so in first test If $serverstatus = $status is: 0 = 0

You should add some Initial value that is not same as expected status, for example:

Dim $serverstatus = -1

This is exactly how it is in my script...

and instead of:

If $ServerStatus = $Status Then
Else
   $ServerStatus = $Status
   ...
EndIf
oÝ÷ Úë²)©êÚºÚ"µÍY   ÌÍÔÙÝ]È   ÉÝÈ  ÌÍÔÝ]È[    ÌÍÔÙÝ]ÈH  ÌÍÔÝ]Â[Y
Okay, i'l try this.

EDIT: didn't work.

Edited by azeazezar

Share this post


Link to post
Share on other sites

nevermind, i got it to work, i'm gonna remove the script to make sure i'm not gonna get banned for it

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