Jump to content

Reading new data typed into the input box.... where did my data go?


 Share

Recommended Posts

Can someone help me with this.. it has to be a real simple one... but not working for me...Do I need to use GuictrlsetData or something.... don't see how on a manual input..

$nrtorun = GUICtrlCreateInput("4", 224, 136, 57, 21)

$nrsecs = GUICtrlCreateInput("60", 224, 176, 57, 21)

When I initially read the input box with the code directly below, all is well but when i type a new value into the input box both read ZERO.. I must be missing something simple.. Thanks/

Case $msg = $mystart

$nrsecs = GUICtrlRead($nrsecs)

$nrtorun = GUICtrlRead($nrtorun)

Msgbox(0,"",$nrsecs & " " & $nrtorun)

Above reads fine on the initial values of 4 and 60 but typing any manual entry gives Zero on the Msgbox above..

#include <IE.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <DATE.au3>
Dim $start, $mgs, $nrsecs, $i, $tot, $oIE
Dim $mytime, $nrwins, $num, $secdelay, $file, $dog, $i, $sync, $cat
Dim $cnt, $mynum
Global $nrtorun

#Region ### START Koda GUI section ### Form=C:\koda-form-designer\koda_1.7.2.0\Forms\form3x.kxf
;                                         W    H    L    T
$Form1_1 = GUICreate("Hud Alert Control Version 1.0", 378, 303, 750, 0)
$Tab1 = GUICtrlCreateTab(16, 32, 337, 249)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$StartUp = GUICtrlCreateTabItem("StartUp")
$Group1 = GUICtrlCreateGroup("Start Up", 32, 72, 297, 185)
$Label1 = GUICtrlCreateLabel("Number of Instances to Run", 72, 136, 137, 17)
$nrtorun = GUICtrlCreateInput("4", 224, 136, 57, 21)
$Label2 = GUICtrlCreateLabel("Number of seconds apart ", 72, 176, 126, 17)
$nrsecs = GUICtrlCreateInput("60", 224, 176, 57, 21)
$mystart = GUICtrlCreateButton("Start Now!", 136, 216, 97, 25, $WS_GROUP)
$Label3 = GUICtrlCreateLabel("Select the total number of instances to run 1-16.", 72, 96, 230, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$TabSheet2 = GUICtrlCreateTabItem("Sync")
$mysync = GUICtrlCreateButton("Begin Sync", 104, 136, 145, 25, $WS_GROUP)
$TabSheet3 = GUICtrlCreateTabItem("Test")
;                                                 L    T    W   H
$mytest   = GUICtrlCreateButton("Begin Test", 104, 120, 145, 25, $WS_GROUP)
$myreadcount = GUICtrlCreateButton("Read Count", 104, 170, 145, 25, $WS_GROUP)
$myreadtime  = GUICtrlCreateButton("Read Time",  104, 220, 145, 25, $WS_GROUP)

$TabSheet4 = GUICtrlCreateTabItem("Minimize")
;                                                 L    T    W   H
$myminimize  = GUICtrlCreateButton("Minimize All", 104, 120, 145, 25, $WS_GROUP)
$myrestore    = GUICtrlCreateButton("Restore All", 104, 170, 145, 25, $WS_GROUP)
$myclose        = GUICtrlCreateButton("Close All",  104, 220, 145, 25, $WS_GROUP)

GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
   Case $msg = $mystart
    $nrsecs = GUICtrlRead($nrsecs)
    $nrtorun = GUICtrlRead($nrtorun)
   
    Msgbox(0,"",$nrsecs & " " & $nrtorun)
   
      
    ; $mynum = ($nrsecs / 10) - 1
    ; $cat = 1
    ; DoStart()

            Case $msg = $mysync
    DoSync()
            Case $msg = $mytest
    DoTest()
   
            Case $msg = $myreadcount
    DoReadCount()
   
            Case $msg = $myreadtime
    DoReadTime()
   Case $msg = $myminimize
    DoMinimizeAll()
            Case $msg = $myrestore
    DoRestoreAll()
            Case $msg = $myclose
    DoCloseAll()
   EndSelect
  
  
IF $cat = 1 then
 
  if (StringRight(@SEC, 1)) = 0 then
    $cnt = $cnt + 1
    ; msgbox(0,"",$cnt & "  " & $mynum & "  " & @SEC, 3)
    Sleep(1000)
    if $cnt > $mynum then DoStart()
  EndIf
   
  
EndIf
   
  
    WEnd
Func DoStart()
$cnt = 0
ConsoleWrite(@HOUR & ":" & @MIN & ":" & @SEC & "  " & $nrtorun & @CRLF)
Msgbox(0,"","Time to hit.." & $cnt & "  " & $mynum  & "  " &  @SEC, 3)
$nrtorun = $nrtorun - 1
if $nrtorun = 0 then
  $cat = 0
  ConsoleWrite("All Done." & @CRLF)
EndIf

EndFunc

Func DoSync()
Local $test=0, $nrwins=0
$mytime = 13
$secdelay = 20
$num = 0

for $i = 1 to 16
if WinExists("Win " & $i) then $nrwins = $nrwins + 1
Next

if $mytime > 0 then $num = round(($mytime/$nrwins), 1)
for $i = 1 to 16
if WinExists("Win " & $i) then
  $dog = $num * $i & "|" & $secdelay & "|" & $test & "|"
  $sync = @ScriptDir & "\sync" & $i & ".txt"
  $file = FileOpen($sync, 2)
  FileWriteLine($file, $dog)
  FileClose($file)
EndIf
Next
If Not $dog then MsgBox(0,"","No Open Windows.")
$dog = ""
EndFunc

Func DoTest()
for $i = 1 to 16
if WinExists("Win " & $i) then
  $dog = "0|0|1|"
  $sync = @ScriptDir & "\sync" & $i & ".txt"
  $file = FileOpen($sync, 2)
  FileWriteLine($file, $dog)
  FileClose($file)
EndIf
Next
If Not $dog then MsgBox(0,"","No Open Windows.")
$dog = ""
EndFunc

Func DoReadCount()

for $i = 1 to 16
if WinExists("Win " & $i) then
  $oIE = _IEAttach ("Win " & $i, "embedded")
  $oDiv = _IEGetObjById ($oIE, "theTime")
  $dog = $dog &  "Win " & $i & "  " & $oDiv.innerTEXT & @CRLF
EndIf
Next
IF $i > 0 then _IEQuit($oIE)
If Not $dog then
MsgBox(0,"","No Open Windows.")
Else
Msgbox(0,"", $dog)
EndIf
$dog = ""
EndFunc

Func DoReadTime()
$file = FileOpen("hold.txt", 2)
for $i = 1 to 16
if WinExists("Win " & $i) then
  $oIE = _IEAttach ("Win " & $i, "embedded")
  $oDiv = _IEGetObjById ($oIE, "theDog")
  $dog = $dog &  "Win " & $i & "  " & $oDiv.innerHTML & @CRLF
  $dog = StringReplace($dog, '<H1>', "Count = ")
  $dog = StringReplace($dog, '</H1>', '  ')
  FileWriteLine($file,$dog)
EndIf
Next
FileClose($file)
IF $i > 0 then _IEQuit($oIE)
If Not $dog then
MsgBox(0,"","No Open Windows.")
Else
Msgbox(0,"", $dog)
EndIf
$dog = ""
EndFunc

Func DoMinimizeAll()
For $i = 1 to 16
  if WinExists("Win " & $i) then WinSetState("Win " & $i, "", @SW_MINIMIZE)
Next
EndFunc

Func DoRestoreAll()
; WinMinimizeAllUndo()
  For $i = 1 to 16
  if WinExists("Win " & $i) then WinActivate('Win ' & $i)
Next
EndFunc

Func DoCloseAll()
For $i = 1 to 16
  if WinExists("Win " & $i) then WinClose('Win ' & $i)
Next
EndFunc
Link to comment
Share on other sites

Hello Tommytx,

When you read a controls input into it's own handle pointer $nrsecs = GUICtrlRead($nrsecs), then you have cleared a way to point to the control and replaced it with the value read from the control. This variable will nolonger point to the control, and now only stores the value read into it.

Try using a seperate variable to read the control like $nrsecs_read = GUICtrlRead($nrsecs)

Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
Share on other sites

Exactly Like Realm said, Think of A variable as a postbox you can put things in it and take things out of it, Variables is just a way to store temporary data used for reading/Inserting Data to a control or even Writing Data to A file and then whenever you need it again(your application is used a few days later) for Reading it from the file and then set it to whatever control you have, remember always use $Variables created from Guicreate and Guictrlcreate, dont use hard coded Control Id's, it makes your coding A lot easier, It seems as if you're busy developing a huge dynamic application, Maybe you should do research about declaring Variables, in what ever Scope you're planning to use the Variable.

[u]My dream is to have a dream...[/u]

Link to comment
Share on other sites

Thanks.. I knew I must have been doing something dumb... as many of you have helped and also pointed out that I was doing something dumb... Thanks I am sure its not my last dumb act.. but that certainly makes sense and gives me a better handle on the handle racket..

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