Jump to content

Recommended Posts

Posted

This is definitely simple to the people here but not to me.

I assign a "0" value to "Interval" in the input box. But I still need to type a "0" and press enter before the box quits to execute. How do I just press enter without having to type the default value again?

GUICtrlCreateLabel("Interval", 10, 105)
$Interval = GUICtrlCreateInput("0", 90, 105, 15)
GUICtrlCreateLabel("and press Enter", 90, 135)
 
GUISetState()
While 1
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $Interval
   _Change()
   Exit
    EndSelect
WEnd
Posted

It seems Inputs need to have something written in them before that functionality is enabled.

Workaround could be to automate some writing, example:

$poop = GUICreate("poop", 256, 256)
GUICtrlCreateLabel("Interval", 10, 105)
$Interval = GUICtrlCreateInput("", 90, 105, 15)
GUICtrlCreateLabel("and press Enter", 90, 135)
 
GUISetState()
ControlSend($poop, "", GUICtrlGetHandle($Interval), "0")
While 1
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = -3
            Exit
        Case $nMsg = $Interval
            _Change()
            Exit
    EndSelect
WEnd
 
Func _Change()
    ConsoleWrite(1 & @LF)
EndFunc   ;==>_Change

Next time, post your whole script (if it is short) or write a reproducer (short working example script) to show your issue. We should not have to rewrite the script to see the issue. The problem could very well be a mistake in the "deleted" parts, making rewriting it a fruitless experience, since whoever is doing that is not likely to do the same mistake.

If you make it hard for people to help you, you will find less and less people willing to help.

Posted

Admiral,

Your answer works well on its own. But when I transfer it to my script, it did not work. Looks like you're right about not posting my whole script issue.

Below is a reproducer script. The "Interval" box does not show "0" and hitting enter does not work the script unless I enter a value unlike yours.

Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",2)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
Opt("TrayIconHide", 0)
Opt("TrayIconDebug", 1)
#include <GUIConstants.au3>
#Include <GuiEdit.au3>
#include <Sound.au3>
#include <Date.au3>
#include <File.au3>
#include <Array.au3>
#include <Misc.au3>

Dim $Chart_Period, $NameChecksum1, $NameChecksum2, $Template, $Interval, $InputScreen
Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "On_Exit")
$InputScreen = GUICreate("Change Chart Duration", 230, 200, -1, -1)
GUICtrlCreateLabel("1 = 4 mins, 2 = 10, 3 = 15 , 4 = 30, 5 = 60", 10, 15)
GUICtrlCreateLabel("6 = 45, 7 = 120, 8 = 180, 9 = 240", 10, 30)
GUICtrlCreateLabel("Chart Minutes", 10, 60)
$Chart_Period = GUICtrlCreateInput("0", 90, 55, 15)
GUICtrlCreateLabel("Template", 10, 85)
$Template = GUICtrlCreateInput("0", 90, 85, 15)
GUICtrlCreateLabel("Interval", 10, 115)
$Interval = GUICtrlCreateInput("", 90, 115, 15)
GUICtrlCreateLabel("and press Enter", 90, 150)

GUISetState()
ControlSend($InputScreen, "", GUICtrlGetHandle($Interval), "0")
While 1
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = -3
            Exit
        Case $nMsg = $Interval
            _Change()
            Exit
    EndSelect
WEnd

Func _Change()
    ConsoleWrite(1 & @LF)
MsgBox(4096,"Changing Chart",0)
EndFunc   ;==>_Change
;;;;;;;;;;;
 
Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func On_Exit()  
Exit 0
EndFunc
Func _WinWaitActivate($title,$text,$timeout=0)
WinWait($title,$text,$timeout)
If Not WinActive($title,$text) Then WinActivate($title,$text)
WinWaitActive($title,$text,$timeout)
EndFunc
Posted (edited)

By adding some extra letters to the ControlSend I noticed it was sent to the first Input (not sure why)

ControlSend($InputScreen, "", GUICtrlGetHandle($Interval), "0SomeExtraLetters")

I tried ControlSetText() instead, it goes to the right control but causes 1 event ($nMsg = $Interval) to fire the first time you write something in ANY of the inputs (not what I expected). So that's of no use...

Until someone else comes with a (more?) proper solution, all I can suggest is to "cheat" by creating the $Interval Input first, or use an Accelerator to catch the ENTER press. Melba23 posted an example of that a few days ago, (would probably be best).

Edited by AdmiralAlkex

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...