stafe Posted February 18, 2007 Share Posted February 18, 2007 I am a new user and just written my first script but I am having trouble getting it working. The aim of the script is to pull up a graphical date box where I can then select the date and on clicking okay it will insert the selected date into the underlying document. The problem is twofold. The most important issue is that the send commands does not seem to send the contents of the variable into my underlying document. The second problem is that occasionally one click on the okay button nothing happens. I would appreciate any assistance. The code that I have written is as follows:- *************************************************************** #include <GuiConstants.au3> #include <Date.au3> dim $mydate2 ; GUI GuiCreate("Select Date", 210, 90) GuiSetIcon(@SystemDir & "\mspaint.exe", 0) ; DATE $MyDate = GuiCtrlCreateDate("bla", 5, 60, 200, 20, $DTS_SHORTDATEFORMAT) ;Create an "OK" button $OK_Btn = GUICtrlCreateButton("OK", 20, 21, 70, 25) ;Create a "CANCEL" button $Cancel_Btn = GUICtrlCreateButton("Cancel", 110, 21, 70, 25) ; GUI MESSAGE LOOP GuiSetState() While GuiGetMsg() <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() $MyDate2 = GUICtrlRead($myDate) ; $MyDate2 = _DateTimeFormat($MyDate2,2) Select ;Check if user clicked on the "OK" button Case $msg = $OK_Btn ClipPut($myDate2) WinClose("Select Date") Send($myDate2) ExitLoop ;Check if user clicked on the "CANCEL" button Case $msg = $Cancel_Btn ExitLoop EndSelect WEnd ************************************************************************************ Thanks for any help Stafe Link to comment Share on other sites More sharing options...
BrettF Posted February 18, 2007 Share Posted February 18, 2007 Try this: #include <GuiConstants.au3> #include <Date.au3> Global $mydate2 GUICreate("Select Date", 210, 90) GUISetIcon(@SystemDir & "\mspaint.exe", 0) $MyDate = GUICtrlCreateDate("bla", 5, 60, 200, 20, $DTS_SHORTDATEFORMAT) $OK_Btn = GUICtrlCreateButton("OK", 20, 21, 70, 25) $Cancel_Btn = GUICtrlCreateButton("Cancel", 110, 21, 70, 25) GUISetState() While 1 $msg = GUIGetMsg() $mydate2 = GUICtrlRead($MyDate) ; $MyDate2 = _DateTimeFormat($MyDate2,2) Select Case $msg = $OK_Btn GUISetState (@SW_MINIMIZE) ExitLoop Case $msg = $Cancel_Btn Or $msg = $GUI_Event_Close ExitLoop EndSelect WEnd Send($mydate2) Exit Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
stafe Posted February 18, 2007 Author Share Posted February 18, 2007 Thank you Bert That works many thanks One further enhancement that I am looking to do with it is that if the enter key is pressed it executes as though the OK key is pressed and if the escape key is pressed it executes as though the cancel key is pressed. If possible could you please advise me. Stafe Link to comment Share on other sites More sharing options...
BrettF Posted February 18, 2007 Share Posted February 18, 2007 Thank you Bert That worksmany thanksOne further enhancement that I am looking to do with it is that if the enter key is pressed it executes as though the OK key is pressed and if the escape key is pressed it executes as though the cancel key is pressed. If possible could you please advise me.StafeChange:Case $msg = $OK_BtntoCase $msg = $OK_Btn or _IsPressed ("0D") Simple! Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
stafe Posted February 19, 2007 Author Share Posted February 19, 2007 Change:Case $msg = $OK_BtntoCase $msg = $OK_Btn or _IsPressed ("0D") Simple!Thanks again - you have been a great helpstafe 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