Aliisonline Posted November 18, 2010 Share Posted November 18, 2010 Hi Guys! Me thankful to you people on helping me whenever i face some problem. Well this time i am facing two problems.My first problem is that i m making a script to be used on a variety of pcs. So i am getting some minor problem with the Send Command. My code is as WinActivate ( "New Microsoft Word document.doc - Microsoft Word", "")WinWaitActive ( "New Microsoft Word document.doc - Microsoft Word", "")sleep (300)Send ( "+{END}" );Right here me trying to select already written Month 0, 2010 text;but sometimes on some pcs it selects the whole text while on some pcs it is selecting incomplete text;as you can see that i have used sleep command as well after the winwaitactive command but still it sometimes doesnot select the full text on the very first line in my word document. I am now sure that it is due to the delay of the document, which Microsoft Word takes to activate the document.Send ( "+{LEFT}" )Send ( "{DEL}" )The second problem is again with send command, it is related with GUICtrlCreateDate . Again the code is as:;inserting date by asking you.Opt('MustDeclareVars', 1)Example()Func Example()Local $Button_1, $msg, $calenderGUICreate ("Select Visit Date", 300,200); BUTTON;Create an "OK" button $calender = GUICtrlCreateDate ( "", 10, 20, 200,20) $Button_1 = GUICtrlCreateButton("OK", 220, 19, 50, 20)GUISetState(@SW_SHOW);sleep (2000)WinWaitActive ("Select Visit Date", "")Send ("{RIGHT}")While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 WinActivate ( "New Microsoft Word document.doc - Microsoft Word" , "") WinWaitActive ( "New Microsoft Word document.doc - Microsoft Word", "") Send (GUICtrlRead($calender)); Right here it is sending the date in following format;Like Thursday, November 18, 2010 whereas i just want to send date as November 18, 2010 ExitLoop EndSelect WEndEndFunc ;==>Example Link to comment Share on other sites More sharing options...
James Posted November 18, 2010 Share Posted November 18, 2010 Allisonline, For the first problem, you're probably better off using the _Word* UDF functions, check out the Help File for some examples Second problem is that the Date control formats the date differently to how you want it. You'll need to strip out the first part of it. Local $strRegex = "(^.*?\W\s)" ; Removes the first word including spacing characters Local $strDirty = "Thursday, November 18, 2010"; Local $strClean $strClean = StringRegExpReplace($strDirty, $strRegex, "") ; Replace the matched text with nothing ConsoleWrite($strClean & @CRLF) James Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Aliisonline Posted November 18, 2010 Author Share Posted November 18, 2010 Thanks for the quick reply. As regards to the second problem does the solution you mentioned applies only to the date which i wrote in the post or will it apply to the general date when inserting by send command.Actually the GUI is letting the user to select the date from pop up and when the user selects the date, the script has to insert date like Month(Full Name) Date(Two Digits but if less then 10 than one Digit), YEAR(Four Digits). But by default the script is sending like Day(Full), Month(Full) Date(two digits either less than 10), Year((Four digits). Link to comment Share on other sites More sharing options...
James Posted November 18, 2010 Share Posted November 18, 2010 Thanks for the quick reply. As regards to the second problem does the solution you mentioned applies only to the date which i wrote in the post or will it apply to the general date when inserting by send command.But by default the script is sending like Day(Full), Month(Full) Date(two digits either less than 10), Year((Four digits).It will only work with the date you provided since that's the only output you'll get from the *Date control I believe.James Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Aliisonline Posted November 18, 2010 Author Share Posted November 18, 2010 (edited) It will only work with the date you provided since that's the only output you'll get from the *Date control I believe. James Thanks again for clearing the confusion but now first i can't judge that where should i write the code, which you provided, in my script. And secondly please i can't understand that why have you mentioned specifically Thursday, November 18, 2010 in your very first reply. Local $strDirty = "Thursday, November 18, 2010"; I was thinking that my script needs something like this: $calender = GUICtrlRead($Date) $calender = StringMid($date, 6, 3) & StringRight($date, 2) & "/" & StringLeft($date, 4) Send ($Date);RIGHT HERE I want to send the date (which was clicked) in format: ; Month FULL NAME then SPACE then DD then COMA then space then YYYY ;E.G ;October 3, 2008 OR August 10, 2001 ;MONTH DD,(2 Digits but 1 if less than 10)YYYY format. ;But by default it is sending in format ;Means writing full DAY name then COMA then SPACE then FULL MONTH NAME then SPACE DD ;then COMA then SPACE then YYYY ;E.G Monday, October 20, 2010 Edited November 18, 2010 by Aliisonline Link to comment Share on other sites More sharing options...
James Posted November 18, 2010 Share Posted November 18, 2010 And secondly please i can't understand that why have you mentioned specifically Thursday, November 18, 2010 in your very first reply.Because you used it as an example here:;Like Thursday, November 18, 2010 whereas i just want to send date as November 18, 2010 But it will work with any date that is in the same format.Try "Monday, October 12, 2010" for example. You'll get the data you need.James Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Aliisonline Posted November 18, 2010 Author Share Posted November 18, 2010 Because you used it as an example here:But it will work with any date that is in the same format.Try "Monday, October 12, 2010" for example. You'll get the data you need.JamesOk Dear but please do mention where to insert the code in my script Link to comment Share on other sites More sharing options...
James Posted November 18, 2010 Share Posted November 18, 2010 Allisonline, Try this, Opt('MustDeclareVars', 1) Example() Func Example() Local $Button_1, $msg, $calender Local $strRegex = "(^.*?\W\s)" ; Removes the first word including spacing characters GUICreate("Select Visit Date", 300, 200) ; BUTTON ;Create an "OK" button $calender = GUICtrlCreateDate("", 10, 20, 200, 20) $Button_1 = GUICtrlCreateButton("OK", 220, 19, 50, 20) GUISetState(@SW_SHOW) ;sleep (2000) WinWaitActive("Select Visit Date", "") Send("{RIGHT}") While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 WinActivate("New Microsoft Word document.doc - Microsoft Word", "") WinWaitActive("New Microsoft Word document.doc - Microsoft Word", "") $strDate = GUICtrlRead($calender) $strDate = StringRegExpReplace($strDate, $strRegex, "") ; Replace the matched text with nothing Send($strDate); Right here it is sending the date in following format ;Like Thursday, November 18, 2010 whereas i just want to send date as November 18, 2010 ExitLoop EndSelect WEnd EndFunc ;==>Example James Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Aliisonline Posted November 18, 2010 Author Share Posted November 18, 2010 (edited) Allisonline, Try this, Opt('MustDeclareVars', 1) Example() Func Example() Local $Button_1, $msg, $calender Local $strRegex = "(^.*?\W\s)" ; Removes the first word including spacing characters GUICreate("Select Visit Date", 300, 200) ; BUTTON ;Create an "OK" button $calender = GUICtrlCreateDate("", 10, 20, 200, 20) $Button_1 = GUICtrlCreateButton("OK", 220, 19, 50, 20) GUISetState(@SW_SHOW) ;sleep (2000) WinWaitActive("Select Visit Date", "") Send("{RIGHT}") While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 WinActivate("New Microsoft Word document.doc - Microsoft Word", "") WinWaitActive("New Microsoft Word document.doc - Microsoft Word", "") $strDate = GUICtrlRead($calender) $strDate = StringRegExpReplace($strDate, $strRegex, "") ; Replace the matched text with nothing Send($strDate); Right here it is sending the date in following format ;Like Thursday, November 18, 2010 whereas i just want to send date as November 18, 2010 ExitLoop EndSelect WEnd EndFunc ;==>Example James ME a lot thankful to you for your close attention. I tried your suggestion but me getting this error It only left behind , 2010 Edited November 18, 2010 by Aliisonline Link to comment Share on other sites More sharing options...
James Posted November 18, 2010 Share Posted November 18, 2010 ME a lot thankful to you for your close attention. I tried your suggestion but me getting this error It only left behind , 2010 Are you sure? #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $Button_1, $msg, $calender, $strDate Local $strRegex = "(^.*?\W\s)" ; Removes the first word including spacing characters GUICreate("Select Visit Date", 300, 200) ; BUTTON ;Create an "OK" button $calender = GUICtrlCreateDate("", 10, 20, 200, 20) $Button_1 = GUICtrlCreateButton("OK", 220, 19, 50, 20) GUISetState(@SW_SHOW) ;sleep (2000) WinWaitActive("Select Visit Date", "") Send("{RIGHT}") While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 ;~ WinActivate("New Microsoft Word document.doc - Microsoft Word", "") ;~ WinWaitActive("New Microsoft Word document.doc - Microsoft Word", "") $strDate = GUICtrlRead($calender) $strDate = StringRegExpReplace($strDate, $strRegex, "") ; Replace the matched text with nothing MsgBox(0, "", $strDate) ;~ Send($strDate); Right here it is sending the date in following format ;Like Thursday, November 18, 2010 whereas i just want to send date as November 18, 2010 ExitLoop EndSelect WEnd EndFunc ;==>Example Works perfect for me. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
James Posted November 18, 2010 Share Posted November 18, 2010 (edited) Allisonline,What I did notice is that I didn't format the date as you first wanted it to be. This function however will output the date exactly how you want it.ConsoleWrite(LongDateToShort("Thursday, November 18, 2010") & @CRLF) Func LongDateToShort($s_Date) Local $strRegex = "(^.*?\W\s)(.*?\W\s)([0-9]*)" ; Long, I know... $s_Date = StringRegExp($s_Date, $strRegex, 3) Return $s_Date[1] & $s_Date[2] EndFuncBetter yet,Func LongDateToShort($s_Date) Local $strRegex = "(^.*?\W\s)(.*?\W\s)([0-9]*)" ; Long, I know... Return StringRegExpReplace($s_Date, $strRegex, "$2$3") EndFuncJames Edited November 18, 2010 by JamesBrooks Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Aliisonline Posted November 18, 2010 Author Share Posted November 18, 2010 Are you sure? #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $Button_1, $msg, $calender, $strDate Local $strRegex = "(^.*?\W\s)" ; Removes the first word including spacing characters GUICreate("Select Visit Date", 300, 200) ; BUTTON ;Create an "OK" button $calender = GUICtrlCreateDate("", 10, 20, 200, 20) $Button_1 = GUICtrlCreateButton("OK", 220, 19, 50, 20) GUISetState(@SW_SHOW) ;sleep (2000) WinWaitActive("Select Visit Date", "") Send("{RIGHT}") While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 ;~ WinActivate("New Microsoft Word document.doc - Microsoft Word", "") ;~ WinWaitActive("New Microsoft Word document.doc - Microsoft Word", "") $strDate = GUICtrlRead($calender) $strDate = StringRegExpReplace($strDate, $strRegex, "") ; Replace the matched text with nothing MsgBox(0, "", $strDate) ;~ Send($strDate); Right here it is sending the date in following format ;Like Thursday, November 18, 2010 whereas i just want to send date as November 18, 2010 ExitLoop EndSelect WEnd EndFunc ;==>Example Works perfect for me. Hmmm. OK OK OK THANKS BRO IT IS WORKING NOW. Now please can you tell me some thing more. I m trying to create a word document till yet i have found that i can use #Include <Misc.au3> #include <GUIConstants.au3> GUICreate( "Get date", 210,190) $Date = GUICtrlCreateMonthCal ("",10, 10) GUISetState() While 1 Sleep ( 50 ) If _IsPressed("01") Then #include <Word.au3> $calldate = GUICtrlRead($Date) $oWordApp = _WordCreate (@DesktopDir & \"Test.doc"); RIGHT HERE I WANT TO SAVE THE FILE with the date which is ;selected in the gui and want to add some other strings also but can't make sense how ExitLoop EndIf WEnd Actually i want to create a word document with filename in following format 20100529 -- 568921(this is a string) -- SomeName(this is a string also) I can collect all strings but can't figure out how to write in _WordCreate syntax 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