Sign in to follow this  
Followers 0
Crossbow

Help please

7 posts in this topic

#1 ·  Posted (edited)

Hello all, I'm new to this au3 thingy ;)

I been doing some stuff to practice

I have a problem with this code, I need it to write to an .ini file but first it has to do a multiplication as you can see

but it doesnt .... help! :)

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
Opt("GUICloseOnESC", 1)

GUICreate("test", 300, 300)

$iniread = IniRead("myini.ini", "section", "key", "")
$input = GUICtrlCreateInput($iniread, 30, 30, 50, 20)
$readgui = GUICtrlRead($input)
$num = 1000
$mult = $num * $readgui

$bot = GUICtrlCreateButton("save", 10, 80, 110, 30)
GUICtrlSetOnEvent($bot, "bot")
$bot2 = GUICtrlCreateButton("result", 120, 80, 110, 30)
GUICtrlSetOnEvent($bot2, "bot2")

GuiSetState( )
GUISetOnEvent($GUI_EVENT_CLOSE, "CloseProgram")
While 1
WEnd

Func CloseProgram( )    
    Exit
EndFunc

Func bot()
    IniWrite("myini.ini", "section", "key", $mult)
EndFunc

Func bot2()
    MsgBox(0, "result", $mult)
EndFunc
Edited by Crossbow

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hello all, I'm new to this au3 thingy ;)

I been doing some stuff to practice

I have a problem with this code, I need it to write to an .ini file but first it has to do a multiplication as you can see

but it doesnt .... help! :)

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
Opt("GUICloseOnESC", 1)

GUICreate("test", 300, 300)

$iniread = IniRead("myini.ini", "section", "key", "")
$input = GUICtrlCreateInput($iniread, 30, 30, 50, 20)
$readgui = GUICtrlRead($input)
$num = 1000
$mult = $num * $readgui

$bot = GUICtrlCreateButton("save", 10, 80, 110, 30)
GUICtrlSetOnEvent($bot, "bot")
$bot2 = GUICtrlCreateButton("result", 120, 80, 110, 30)
GUICtrlSetOnEvent($bot2, "bot2")

GuiSetState( )
GUISetOnEvent($GUI_EVENT_CLOSE, "CloseProgram")
While 1
WEnd

Func CloseProgram( )    
    Exit
EndFunc

Func bot()
    IniWrite("myini.ini", "section", "key", $mult)
EndFunc

Func bot2()
    MsgBox(0, "result", $mult)
EndFunc

You need to read the input before you show the multiplication result. Here's one way to do it.

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
Opt("GUICloseOnESC", 1)

GUICreate("test", 300, 300)

$iniread = IniRead("myini.ini", "section", "key", "")
$input = GUICtrlCreateInput($iniread, 30, 30, 50, 20)

$mult = 0
$lastReadGui = 0
$num = 1000

$bot = GUICtrlCreateButton("save", 10, 80, 110, 30)
GUICtrlSetOnEvent($bot, "bot")
$bot2 = GUICtrlCreateButton("result", 120, 80, 110, 30)
GUICtrlSetOnEvent($bot2, "bot2")

GUISetState()
GUISetOnEvent($GUI_EVENT_CLOSE, "CloseProgram")
While 1
    $readgui = Number(GUICtrlRead($input))
    If $readgui <> $lastReadGui Then
        $lastReadGui = $readgui
        $mult = $num * $readgui
    EndIf
    Sleep(50)
WEnd

Func CloseProgram()
    Exit
EndFunc ;==>CloseProgram

Func bot()
    IniWrite("myini.ini", "section", "key", $mult)
EndFunc ;==>bot

Func bot2()
    MsgBox(0, "result", $mult)
EndFunc ;==>bot2

Welcome to AUtoIt forums :D

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

yay it works!

thx alot :)

Share this post


Link to post
Share on other sites

does anyone know where can I learn how to write code correctly, put stuff where it goes lol I dunno how to say it

I'm new to all this

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

does anyone know where can I learn how to write code correctly, put stuff where it goes lol I dunno how to say it

I'm new to all this

As well as the link Oldschool gave, this one is useful.

I think you are already going about it the right way though. Read the help, try to do something, struggle, then if stuck search and that doesn't work ask for help, then try to understand why, try something else.

While $Scripting
 ReadHelp()
 if $confused then $Result = Experiment()
 if $Result = $AllGoneWrong then
   if searchFor examples() = 0 then AskForHelp()
 endif
 WriteSomeCode()
Wend
Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Crossbow

Hi and wellcome! :)

When i begin to learn AutoIt, i was don`t know english and nothing about AutoIt, but due to this forum and nice members i was learn very many.

1. Help file - knowledgebase.

2. This wonderful forum.

3. More practice.

Good luck! ;)

Edit:

@Martin nice code :D

Edited by rasim

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