Jump to content

Easy question


BeZ
 Share

Recommended Posts

Here is my script:

#include <GuiConstants.au3>
;#NoTrayIcon

$x = 0

GuiCreate("compteur", 115, 18, 0, 0, BitOR($WS_BORDER, $WS_POPUP), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GuiSetState()

$Label_1 = GuiCtrlCreateLabel ("$x" , 0, 0, 120, 20)
$x = $x + 1
Sleep (12000)
$Label_1 = GuiCtrlCreateLabel ("$x" , 0, 0, 120, 20)
$x = $x + 1
Sleep (12000)
$Label_1 = GuiCtrlCreateLabel ("$x" , 0, 0, 120, 20)
$x = $x + 1
Sleep (12000)

Exit

I guess you understand i want to use the variable "x" in the abel but it doens't work. It writes $x in the label instead. If i write

$Label_1 = GuiCtrlCreateLabel (""$x"" , 0, 0, 120, 20)
(changed "$x" to ""$x"") it gives me an error when i run the script.

Also, I've seen in the function reference not to put sleep command in While...Cases...WEnd. How could i make a loop instead of repeating the 3 lines tons of times.

Thanks for the help, BeZ

Link to comment
Share on other sites

Can't use quotes when you want the actuall value of the variable

#include <GuiConstants.au3>
;#NoTrayIcon

$x = 0

GuiCreate("compteur", 115, 18, 0, 0, BitOR($WS_BORDER, $WS_POPUP), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
$Label_1 = GuiCtrlCreateLabel (0 , 0, 0, 120, 20)
GuiSetState()


For $x =1 to 15
GuiCtrlSetData($Label_1, $x);No quotes on '$x' and changes the label  instead of make a new one
Sleep(12000)
Next

Exit
Edited by Paulie
Link to comment
Share on other sites

Use variable directly ie $x in place of "$x" and use FOR loop to repeat the required no. of times

Gerry

#include <GuiConstants.au3>
;#NoTrayIcon

$x = 0

GuiCreate("compteur", 115, 18, 0, 0, BitOR($WS_BORDER, $WS_POPUP), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GuiSetState()
For $x = 1 To 10
$Label_1 = GuiCtrlCreateLabel ($x , 0, 0, 120, 20)
Sleep (1200)
Next
Exit
Link to comment
Share on other sites

Use variable directly ie $x in place of "$x" and use FOR loop to repeat the required no. of times

Gerry

#include <GuiConstants.au3>
;#NoTrayIcon

$x = 0

GuiCreate("compteur", 115, 18, 0, 0, BitOR($WS_BORDER, $WS_POPUP), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GuiSetState()
For $x = 1 To 10
$Label_1 = GuiCtrlCreateLabel ($x , 0, 0, 120, 20)
Sleep (1200)
Next
Exit
Problem with that is it is creating a label on top of the old one, instead of just changing it

Mine changes the value in the label, and doesn't just overwrite it, make your program use less CPU

I recomend using mine

Link to comment
Share on other sites

Thanks this work really fine.

Now I would like to put decimal number instead of integer.

#include <GuiConstants.au3>
;#NoTrayIcon

$x = 0

GuiCreate("compteur", 115, 18, 0, 0, BitOR($WS_BORDER, $WS_POPUP), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GuiSetState()

$Label_1 = GuiCtrlCreateLabel ($x , 0, 0, 120, 20)

For $x = 0.01 to 3600
$Label_1 = GuiCtrlCreateLabel ($x , 0, 0, 120, 20)
Sleep (12000)
Next
Exit

How can i make it grow by 0.01 instead of 1 ?

Link to comment
Share on other sites

#include <GuiConstants.au3>
;#NoTrayIcon

$x = 0

GuiCreate("compteur", 115, 18, 0, 0, BitOR($WS_BORDER, $WS_POPUP), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
$Label_1 = GuiCtrlCreateLabel ($x , 0, 0, 120, 20)
GuiSetState()



For $x = 0.01 to 3600 Step 0.01; say step then number
$Label_1 = GuiCtrlSetData ($Label_1, $x); this works better
Sleep (1000)
Next
Exit

Edited by Paulie
Link to comment
Share on other sites

Works again im learning more and more :P

$x = 0

GuiCreate("compteur", 62, 14, 0, 0, BitOR($WS_BORDER, $WS_POPUP), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GuiSetState()

$Label_1 = GuiCtrlCreateLabel ($x dollars, 0, 0, 64, 16)

For $x = 0.01 to 3600 step 0.01
$Label_1 = GuiCtrlCreateLabel ($x dollars, 0, 0, 64, 16)
Sleep (12000)
Next
Exit

As you can see I want to write the word "dollars" after the number. Gives me an error I tryed a couple of things with " " and still doens't work with me. Is there a way I can write $ instead of dollars (im not sure because $ is for variable).

BeZ

Edited by BeZ
Link to comment
Share on other sites

HI,

#include<GuiConstants.au3>
$x = 0

GuiCreate("compteur", 62, 14, 0, 0, BitOR($WS_BORDER, $WS_POPUP), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GuiSetState()

$Label_1 = GuiCtrlCreateLabel ($x & 'dollars', 0, 0, 64, 16)

For $x = 0.01 to 3600 step 0.01
GUICtrlSetData($Label_1, $x & 'dollars')
Sleep (120)
Next
Exit

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

Link to comment
Share on other sites

Ok now this is my final code

#include<GuiConstants.au3>
$x = 0.25

GuiCreate("compteur", 54, 14, 0, 0, BitOR($WS_BORDER, $WS_POPUP), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GuiSetState()

$Label_1 = GuiCtrlCreateLabel ($x & '$ +tx.', 0, 0, 56, 16)
Sleep (288000)
For $x = 0.25 to 3600 step 0.01
GUICtrlSetData($Label_1, $x & '$ +tx.')
Sleep (12000)
Next
Exit

And I have one last question.

I want to run this script from my comp and i want the label to appear on both my screen and on a screen of another specific computer of my network.

Thank you for your patiente, you people are great :P

BeZ

EDIT: any help or hint would be greatly appreciated.

BeZ

Edited by BeZ
Link to comment
Share on other sites

And I have one last question.

I want to run this script from my comp and i want the label to appear on both my screen and on a screen of another specific computer of my network.

Thank you for your patiente, you people are great :nuke:

BeZ

EDIT: any help or hint would be greatly appreciated.

BeZ

That's more complicated. What program will the other computer be running and how will you communicate with it? Are you coding an AutoIT script for the other computer also?

:P

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I'll tell you exactly why I need this script.

My father has a business and we have two computer that client can use to go on the internet for 3$/hour.

There is always people in the shop and i am the only employee, he has no time to count how much time people are on internet. I want to be able to run this script on my computer (so I don't have to go on the other computer to run the script). I want the label to appear on my screen (so i know how much i have to charge $) and on the client's screen (so he knows how much it will cost).

The computers are linked together trough tons of router and servers I can't tell exactly but it's all local.

I wanted to introduce hotkeys, 1 to unlock the client's computer from my computer and start the counter, another one to pause the script on both computer and lock the client's computer and one to reset the counter to zero.

I dont care if i have to install AU3 on other computer or whatever I would just like it to work so i can control it all from my computer.

My client's computers use Win2000/XP

I dont know if this is asking too much but I ask it because I don't have much time to look how AU3 works (12 to 14 hours of work a day belive it or not). Don't worry, I don't just blindly put the code in the compiler, I look how it works and learn so i can make the desired changes and create new scripts later. I really appreciate the time you are giving me and I already learned a couple cool things about AU3 in the last couple of days. Thanks again !!!

BeZ

Edited by BeZ
Link to comment
Share on other sites

Hi,

you can just use this:

For $i = 0.01 To 3600 Step 0.01
    ToolTip(StringFormat( "%.2f", $i) & ' $ (Dollars)', 0, 0)
    Sleep(120)
Next
Exit

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

Link to comment
Share on other sites

Alright.

Also, after a littble bit of time the number stop beeing only "#.##". They turn to "#.##9999999". How can i fix this ?

use this as the code

#include<GuiConstants.au3>
$x = 0.25

GuiCreate("compteur", 54, 14, 0, 0, BitOR($WS_BORDER, $WS_POPUP), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GuiSetState()

$Label_1 = GuiCtrlCreateLabel ($x & '$ +tx.', 0, 0, 56, 16)
Sleep (288000)
For $x = 0.25 to 3600 step 0.01
GUICtrlSetData($Label_1, Round($x,2) & '$ +tx.'); round keeps it a t 2 dec places
Sleep (12000)
Next
Exit
Link to comment
Share on other sites

Works and works. Any way that i can put the Round($x,2) command in Mega's script ? i tryed couple of things but still getting error message.

Yes, this is easy, meger did it a hard way :P

For $i = 0.01 To 3600 Step 0.01
    ToolTip("$ "&Round($i,2), 0, 0)
    Sleep(1000)
Next
Exit

EDIT:

is this supposed to be in minutes or seconds?

Edited by Paulie
Link to comment
Share on other sites

3$/hour = 1 cent/12 second

Thank you again and again and again... my only problem is I don't know in what order to put the parameters and where to put the quotes... I guess a day I will be a good AU3 programmer. This scripting language is really cool I've started using it a couple months ago using simple send&sleep command and make couple nice bots for games lol.

I still don't understand the TCPSend and TCPRecv much... Making this script start on another computer from my computer would be really great.

I suppose that if I put the script on my other computers I can find a way to start and stop it from my computer... I think I can find how to open a socket and all by myself but I really don't know how a script to do this would look like.

BeZ

Link to comment
Share on other sites

I have another problem I can't solve:

$cout = 0.75
    ToolTip(Round($cout,2)&"$ +tx.", 0, 0)
    Sleep (5000)

For $cout = 0.75 To 2.5 Step 0.01
    ToolTip(Round($cout,2)&"$ +tx.", 0, 0)
    Sleep(120)
Next

MsgBox (0, "Cout", $cout & " $ + taxes")

When the message box pop it says $cout = 0.75 $ + taxes .... Isn't it supposed to say 2.5 $ + taxes ??

Instead of having to wait for $cout to get to 2.5 I would like to add a "stop" button wich would end the loop. How do I add a button in a tooltip ?

Link to comment
Share on other sites

I have another problem I can't solve:

$cout = 0.75
    ToolTip(Round($cout,2)&"$ +tx.", 0, 0)
    Sleep (5000)

For $cout = 0.75 To 2.5 Step 0.01
    ToolTip(Round($cout,2)&"$ +tx.", 0, 0)
    Sleep(120)
Next

MsgBox (0, "Cout", $cout & " $ + taxes")

When the message box pop it says $cout = 0.75 $ + taxes .... Isn't it supposed to say 2.5 $ + taxes ??

Instead of having to wait for $cout to get to 2.5 I would like to add a "stop" button wich would end the loop. How do I add a button in a tooltip ?

Just as a question, have you looked into 'TimerInt'/'TimerDiff'

Correct me if i'm wrong, but this seems to be what you want right?

HotKeySet("{ESC}", "End_Timer")

Global $Timer= "",$Total, $Charge, $LegTime, $Final[3]
Sleep(3000)
Start_Timer()

While 1
        If not $Timer = "" then
        $Dif = TimerDiff($Timer)
        $Final = Calculate($Dif)
        $Display = StringTrimRight($Final, 1)
        ToolTip("Total: $"&$Display,0,0)
        Else
        Sleep(200)
        Endif
WEnd

Func Start_Timer()
    $Timer = TimerInit()
EndFunc

Func End_Timer()
    $FinalDiff = TimerDiff($Timer)
    $Charge = Calculate($FinalDiff)
    MsgBox(0, "Total", "Your Total With Tax Comes to:"&@CRLF&"$"&Round($Charge*1.07),2)
    $Timer = ""
EndFunc

Func Calculate($A_Time)
    Global $LegTime = Round($A_Time/1000,2)
    $RetData = Round(($LegTime/1200),3)
    Return $RetData
EndFunc

It's dirty, but way easier to balence the times this is perfectly in sync with the $3/hr rate

Edited by Paulie
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...