UQOII Posted October 1, 2007 Share Posted October 1, 2007 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 More sharing options...
silvano Posted October 1, 2007 Share Posted October 1, 2007 can you post the script? Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 1, 2007 Share Posted October 1, 2007 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: expandcollapse popup#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 More sharing options...
UQOII Posted October 1, 2007 Author Share Posted October 1, 2007 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: expandcollapse popup#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 More sharing options...
UQOII Posted October 1, 2007 Author Share Posted October 1, 2007 is it possible to set hotkeyset on only if the window is activated? [center]uqoii.nl[/center] Link to comment Share on other sites More sharing options...
silvano Posted October 1, 2007 Share Posted October 1, 2007 HotKeySet("{ENTER}", "funcName") when you would to activate it and HotKeySet("{ENTER}") to deactivate it Link to comment Share on other sites More sharing options...
UQOII Posted October 1, 2007 Author Share Posted October 1, 2007 HotKeySet("{ENTER}", "funcName")when you would to activate itand HotKeySet("{ENTER}")to deactivate iti mean when my script window is activated hotkey's work, but if the window is minimalized hotkeys dont work [center]uqoii.nl[/center] Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 1, 2007 Share Posted October 1, 2007 (edited) i mean when my script window is activated hotkey's work, but if the window is minimalized hotkeys dont workThat's what silvano was showing you. Set the hot key when you are displaying your GUI, and clear it when you're not. Edited October 1, 2007 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 More sharing options...
silvano Posted October 1, 2007 Share Posted October 1, 2007 i don't know all of your script but is example work with PsaltyDS script expandcollapse popup#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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now