kendhc

Creating a command window- cant get an input

6 posts in this topic

Hey,

im relatively new to AutoIT and want to create a command window to run various functions. when i press - i want the input window to come up and let me type in what i want and it will then store that in a variable to be used. however, it doesnt seem to be taking what i type as the input.

 

how can i make this work. i know i could use InputBox(), but i am trying to use GUIs as i want it to have a custom look.

Global $GUIstate = 0
Global $inputer

Func openGUI()
   #Region ### START Koda GUI section ### Form=
   $Command = GUICreate("Command", 286, 21, 10, 620)
   GUISetIcon("C:\Windows\System32\cmd.exe", -1)
   GUISetBkColor(0xC0C0C0)
   $inputer = GUICtrlCreateInput("", 1, 0, 300, 23)
   GUICtrlSetFont(-1, 10, 400, 0, "Times New Roman")
   GUICtrlSetColor(-1, 0x000000)
   GUISetState(@SW_SHOW)
   #EndRegion ### END Koda GUI section ###
   $GUIstate = 1
EndFunc

Func closeGUI()
   $input = GUICtrlRead("$inputer")
   GUIDelete("Command")
   $GUIstate = 0
   MsgBox(0,"command given",$input);;Want to know what I put in the box
EndFunc

While 1
   If  $GUIstate = 0 Then
      HotKeySet("-",openGUI)
   EndIf
   If  $GUIstate = 1 Then
      HotKeySet("-",closeGUI)
   EndIf
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   sleep(10)
WEnd

thanks in advance for your help <3

Share this post


Link to post
Share on other sites



If you want to use already declared variable you use it without quotes, what you have done in your line with MsgBox() function like this 

GUICtrlRead($inputer)

There is another posibiility, using Eval, but you should read remarks for that function first:

GuiCtrlRead(Eval("inputer"))

Same goes for line where you delete your GUI.

Share this post


Link to post
Share on other sites

this still doesnt seem to read the value, it just comes back with 0 despite what is typed in

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

thank you so much <3:D

;)

When you create the control you are storing the control id in the variable that you submit:

$inputer = GUICtrlCreateInput("", 1, 0, 300, 23)

$inputer have the value (Auto Increment) of the control ID. In your case $inputer have the value of 3. This can change if you put a code to create another control above this line.

Edited by GordonFreeman

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