Jump to content

some problems..........


UQOII
 Share

Recommended Posts

ive got some litlle problems.

i want read a number when i hit "enter".

(By the main screen i get a secondary screen, script below, and if i push in de secondary screen on "enter" he must read the number is the input)

And another problem if the secondairy window is deleted i cant exit the main window

Func _window()
    $secondwindow = GUICreate("",120,30)
    $number = GUICtrlCreateInput("",10,5,100,20)
    GUISetState()
    While 1
    $msg = GUIGetMsg()
    Switch $msg
        case "{enter}"
            GUICtrlRead($number)
            GUIDelete($window)
        Case $GUI_EVENT_CLOSE
            GUIDelete($window)
            GUISetState (@SW_SHOW,$mainwindow)
        EndSwitch
    WEnd
EndFunc

[center]uqoii.nl[/center]

Link to comment
Share on other sites

ive got some litlle problems.

i want read a number when i hit "enter".

(By the main screen i get a secondary screen, script below, and if i push in de secondary screen on "enter" he must read the number is the input)

And another problem if the secondairy window is deleted i cant exit the main window

A lot of things wrong. You cannot use "{ENTER}" as a Case like that, because GUI messages are numeric and that string evaluates as 0 in a numeric compare, so no message (0) matches immediately.

This demo approximates what you appear to have be trying:

#include <guiconstants.au3>

Global $NumVal = 0

Global $mainwindow = GUICreate("Main Window", 400, 300)
GUICtrlCreateLabel("$number = ", 10, 10, 190, 20, $SS_RIGHT)
Global $Label = GUICtrlCreateLabel($NumVal, 200, 10, 190, 20, $SS_LEFT)
$GetNum = GUICtrlCreateButton("GetNum", 150, 260, 100, 30)
GUISetState(@SW_SHOW, $mainwindow)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GetNum
            GUISetState(@SW_MINIMIZE, $mainwindow)
            _child_window()
            GUISetState(@SW_RESTORE, $mainwindow)
    EndSwitch
    If $NumVal <> GUICtrlRead($Label) Then GUICtrlSetData($Label, $NumVal)
WEnd

Func _child_window()
    $childwindow = GUICreate("Enter number", 220, 80, -1, -1, Default, Default, $mainwindow)
    $number = GUICtrlCreateInput("", 60, 10, 100, 20)
    $OK = GUICtrlCreateButton("OK", 60, 40, 100, 30)
    GUISetState(@SW_SHOW, $childwindow)
    
    While 1
        Switch GUIGetMsg()
            Case $OK
                $NumVal = GUICtrlRead($number)
                GUIDelete($childwindow)
                ExitLoop
            Case $GUI_EVENT_CLOSE
                GUIDelete($childwindow)
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>_child_window

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

A lot of things wrong. You cannot use "{ENTER}" as a Case like that, because GUI messages are numeric and that string evaluates as 0 in a numeric compare, so no message (0) matches immediately.

This demo approximates what you appear to have be trying:

#include <guiconstants.au3>

Global $NumVal = 0

Global $mainwindow = GUICreate("Main Window", 400, 300)
GUICtrlCreateLabel("$number = ", 10, 10, 190, 20, $SS_RIGHT)
Global $Label = GUICtrlCreateLabel($NumVal, 200, 10, 190, 20, $SS_LEFT)
$GetNum = GUICtrlCreateButton("GetNum", 150, 260, 100, 30)
GUISetState(@SW_SHOW, $mainwindow)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GetNum
            GUISetState(@SW_MINIMIZE, $mainwindow)
            _child_window()
            GUISetState(@SW_RESTORE, $mainwindow)
    EndSwitch
    If $NumVal <> GUICtrlRead($Label) Then GUICtrlSetData($Label, $NumVal)
WEnd

Func _child_window()
    $childwindow = GUICreate("Enter number", 220, 80, -1, -1, Default, Default, $mainwindow)
    $number = GUICtrlCreateInput("", 60, 10, 100, 20)
    $OK = GUICtrlCreateButton("OK", 60, 40, 100, 30)
    GUISetState(@SW_SHOW, $childwindow)
    
    While 1
        Switch GUIGetMsg()
            Case $OK
                $NumVal = GUICtrlRead($number)
                GUIDelete($childwindow)
                ExitLoop
            Case $GUI_EVENT_CLOSE
                GUIDelete($childwindow)
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>_child_window

:)

Many thanx, i think i can fix my script with this demo

[center]uqoii.nl[/center]

Link to comment
Share on other sites

i mean when my script window is activated hotkey's work, but if the window is minimalized hotkeys dont work

That's what silvano was showing you. Set the hot key when you are displaying your GUI, and clear it when you're not.

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

i don't know all of your script but is example work with PsaltyDS script

#include <guiconstants.au3>

Global $NumVal = 0

Global $mainwindow = GUICreate("Main Window", 400, 300)
GUICtrlCreateLabel("$number = ", 10, 10, 190, 20, $SS_RIGHT)
Global $Label = GUICtrlCreateLabel($NumVal, 200, 10, 190, 20, $SS_LEFT)
$GetNum = GUICtrlCreateButton("GetNum", 150, 260, 100, 30)
GUISetState(@SW_SHOW, $mainwindow)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GetNum
            GUISetState(@SW_MINIMIZE, $mainwindow)
            _child_window()
            GUISetState(@SW_RESTORE, $mainwindow)
    EndSwitch
    If $NumVal <> GUICtrlRead($Label) Then GUICtrlSetData($Label, $NumVal)
WEnd

Func _enterFunc()
Send("!O")
EndFunc


Func _child_window()
    HotKeySet("{ENTER}", "_enterFunc")
    $childwindow = GUICreate("Enter number", 220, 80, -1, -1, Default, Default, $mainwindow)
    $number = GUICtrlCreateInput("", 60, 10, 100, 20)
    $OK = GUICtrlCreateButton("&OK", 60, 40, 100, 30)
    GUISetState(@SW_SHOW, $childwindow)
   
    While 1
        Switch GUIGetMsg()
            Case $OK
                $NumVal = GUICtrlRead($number)
                GUIDelete($childwindow)
                ExitLoop
            Case $GUI_EVENT_CLOSE
                GUIDelete($childwindow)
                ExitLoop
        EndSwitch
    WEnd
    HotKeySet("{ENTER}")
EndFunc   ;==>_child_window
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...