Sign in to follow this  
Followers 0
UQOII

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

9 posts in this topic

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]

Share this post


Link to post
Share on other sites



can you post the script?

Share this post


Link to post
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

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

is it possible to set hotkeyset on only if the window is activated?


[center]uqoii.nl[/center]

Share this post


Link to post
Share on other sites

HotKeySet("{ENTER}", "funcName")

when you would to activate it

and

HotKeySet("{ENTER}")

to deactivate it

Share this post


Link to post
Share on other sites

HotKeySet("{ENTER}", "funcName")

when you would to activate it

and

HotKeySet("{ENTER}")

to deactivate it

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


[center]uqoii.nl[/center]

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

Share this post


Link to post
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

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
Sign in to follow this  
Followers 0