Jump to content

Storing an entered value as a variable


Project2501
 Share

Recommended Posts

Gday, new to autoit. If anyones familiar with the tv viewing program dscaler I'm basically trying to make a scheduled recording script for it using autoit. I've pretty much done with the script and have started trying to write a GUI. What i want to be able to do is allow the user to put in the time and date when the recording starts and then the time and date when the recording should end. I'm trying to get to grips with this concept by modifying one of the example scripts provided. What it should do is allow the user to enter text in the edit box and then when they click open notepad the text entered should then be displayed in notepad (did this to make sure it's writing the value entered to a variable) for some reason though nothing is displayed in notepad. This is a pretty nooby error but any help would be appreciated.

#include <GUIConstants.au3>

GUICreate("My GUI Button"); will create a dialog box that when displayed is centered

Opt("GUICoordMode")
$Button = GUICtrlCreateButton ("Run Notepad",  10, 30, 100)
$text=GUICtrlCreateEdit ("", 150,32,100,20,$ES_AUTOVSCROLL)
$display = GUICtrlRead($text, 1)

GUISetState ()   ; will display an  dialog box with a button

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button
            Run('Notepad2.exe')   ; Will Run/Open Notepad
            WinWaitActive("Untitled - Notepad2")
            Send($display)
    EndSelect
Wend

fyi this is the script ill be using once i get to grips with changing variables through the gui. (it runs notepad and enters text at a specific time but once i get the gui working i'll change it so it opens dscaler and presses record/stop)

;Start recording
$Smins = "10"
$Shour = "12"
$Sday = "30"
$Smonth = "12"

;End recording
$Emins = "11"
$Ehour = "12"
$Eday = "30"
$Emonth = "12"
;___________________________________________________________________________________________________

________________________________

$var = 0

While $var = 0
   
   $Start = @hour & ":" & @Min & ":" & @MDAY & ":" & @MON
   
   If $Start = $Shour & ":" & $Smins & ":" & $Sday & ":" & $Smonth then
      Run("notepad2.exe")
      $var = 1
   endif
   Sleep(50)
WEnd

WinWaitActive("Untitled - Notepad2")
Send("This is some text.")


While $var = 1
   
   $End = @hour & ":" & @Min & ":" & @MDAY & ":" & @MON
   
   If $End = $Ehour & ":" & $Emins & ":" & $Eday & ":" & $Emonth then
      
      WinClose("* Untitled - Notepad2")
      WinWaitActive("Notepad2", "Save changes to")
      Send("!n")
      $var = 0
   endif
   Sleep(50)
WEnd
Link to comment
Share on other sites

Do you actually have an application named "notepad2.exe"?

You do have a program named "notepad.exe". Also an easier way to see if a variable is being written to is using a MsgBox() or alternately use ClipPut($display) then paste it into a notepad window to see what the result was.

Edit:Typo

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

yeah its like a coder friendly version of notepad. Notepad2 opens alright but nothing is displayed in it. if i put something in the "" eg.

$text=GUICtrlCreateEdit ("", 150,32,100,20,$ES_AUTOVSCROLL)

to

$text=GUICtrlCreateEdit ("empty box", 150,32,100,20,$ES_AUTOVSCROLL)

then the default text inside the edit box will be "empty box" and when notepad opens "empty box" will appear but know matter what you change the text to inside the edit box "empty box" will still appear in notepad. Its like its not registering when you change the value of the text inside that edit box.

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