Jump to content

Send value to cmd console from four input box using command button


weszzer
 Share

Recommended Posts

Hi,

I'm very new to Autoit, and I have simple project that assigned to me.

Basically, what I would like to do is to send a date value to cmd-console from four input box (inputbox1=YYYY, inputbox2=MM, inputbox3=DD and inoutbox4=HH)and send it using button.

I can't figure on how to read the value from these inputboxs and using pushbutton it will send the value to cmd console like C:YYYY/MM/DD/HH 

I don't haven't started any code as I don't know how to start.

Appreciate your help.

Thank you.

Link to comment
Share on other sites

inputbox returns strings, so no need to read just set a variable

$inputbox# = inputbox(...)

https://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateButton.htm

in the example the case for the button runs notepad, in your case it should

run("cmd /k " & $inputbox1 & "/" & $inputbox2 & "/" & $inputbox3 & "/" $inputbox4)

though i dont think its going to like your forward slashes very much unless the month day and hour are arguments for Year.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

inputbox returns strings, so no need to read just set a variable

$inputbox# = inputbox(...)

https://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateButton.htm

in the example the case for the button runs notepad, in your case it should

run("cmd /k " & $inputbox1 & "/" & $inputbox2 & "/" & $inputbox3 & "/" $inputbox4)

though i dont think its going to like your forward slashes very much unless the month day and hour are arguments for Year.

 

Many thanks boththose.

Just a follow-up question, how to I add the code inside the button.?

below is my code created in ISN

#include-once

; -- Created with ISN Form Studio 2 for ISN AutoIt Studio -- ;
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiButton.au3>

$Form1 = GUICreate("Form1",295,179,-1,-1,-1,-1)
GUICtrlCreateInput("",40,40,150,20,-1,512)
GUICtrlCreateInput("",40,70,150,20,-1,512)
GUICtrlCreateInput("",40,100,150,20,-1,512)
GUICtrlCreateButton("Button1",100,140,100,30,-1,-1)

Thank you.

Edited by weszzer
Link to comment
Share on other sites

There are many differences between inputbox and GuiCtrlCreateInput, you need to read the helpfile on both and decide the route that best suits you.  There is no code "inside" a button, its just a control like everything else.  You should use the helpfile example for GuiCtrlCtreateButton and work backwards, the magic happens in the case statements.

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

weszzer,

Instead of multiple input controls you might consider a date control.  The values are changed by selecting the value (year, day, month, hour) and using the UP/DOWN control to change them...

#include <DateTimeConstants.au3>
#include <GUIConstantsEx.au3>

local $gui010 = GUICreate('Date Example', 200, 100)
Local $cDate  = GUICtrlCreateDate("", 10, 10, 185, 20, $DTS_UPDOWN)
local $cbtn1  = GUICtrlCreateButton("OK", 10, 50, 185, 20)

; This sets how the date is displayed
GUICtrlSendMsg($cDate, $DTM_SETFORMATW, 0, "yyyy/MM/dd/HH")

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $cbtn1
            ;
            ; do whatever you want with the date...in this case write it to the console
            ;
            ConsoleWrite('C:\' & guictrlread($cDate) & @CRLF)
    EndSwitch
WEnd

kylomas

edit: spelling

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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

×
×
  • Create New...