noobish Posted December 10, 2012 Share Posted December 10, 2012 Hi guys again. In this script i am trying to run an .exe (a script which installs a wp) in a certain time i.e. 2 hours before the New Year. But i have errors. How i could achieve this ? ( run an .exe from this script) Thank you very much. expandcollapse popup#include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <date.au3> local $target_date = '2013/01/01 00:00:00' local $hrs, $mins, $secs, $days=0, $diff, $warn = 365*24*60*60, $warn_intrvl = 2 * 60 * 60, $display_time ConsoleWrite($warn & ' ' & $warn_intrvl & @LF) local $gui010 = guicreate('',@DesktopWidth,20,(@desktopwidth)/2,20,$ws_popup,bitor($ws_ex_layered,$ws_ex_topmost)) GUISetBkColor(0xABCDEF) local $lbl010 = guictrlcreatelabel('',0,0,600,20) guictrlsetfont(-1,10,800,-1,'lucinda console') _WinAPI_SetLayeredWindowAttributes($gui010, 0xABCDEF, 250) guisetstate() adlibregister('_update',500) while guigetmsg() <> $gui_event_close wend func _update() $diff = _datediff('s',_NowCalc(),$target_date) ; calcs from UEZ Local $secs = Mod($diff, 60) Local $mins = Mod(Int($diff / 60), 60) Local $hrs = Int($diff / 60 ^ 2) If $hrs > 23 Then $days = Floor($hrs/ 24) $hrs -= $days * 24 endif local $diff_out = stringformat('%02i Days %02i Hours %02i Minutes %02i Seconds to ' & stringleft($target_date,stringinstr($target_date,' ')), $days, $hrs, $mins, $secs) guictrlsetdata($lbl010,$diff_out) $warn -= 1 if mod($warn,$warn_intrvl) = 0 then traytip('',$warn_intrvl & ' seconds have passed' & @lf & $diff_out,5) ConsoleWrite('Displaying traytip at ' & $diff_out & @LF) $display_time = 1 endif if $display_time = 10 then traytip('','',0) $display_time = 0 endif if $display_time then $display_time += 1 endfunc Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop case Run("Autoit-Sript.exe") EndIf Until False Link to comment Share on other sites More sharing options...
Gotemp Posted December 10, 2012 Share Posted December 10, 2012 I personally dont see why you have created this thread when you already have one further down that the answer could be posted in infact post #10 is you asking this very same question. < same question but you made a new post! Personally i dont see how you have tried to achieve this, to me it looks like you just thrown code in there without even reading how its ment to work, and with me being somewhat of a lerner myself trying to dismantle our code and getting it to work is just too much hassel. Do, Until False < until what is false? Like i said read and learn before throwing code into a bucket and wondering why it does not work. Link to comment Share on other sites More sharing options...
UEZ Posted December 10, 2012 Share Posted December 10, 2012 (edited) Try this: expandcollapse popup#include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <date.au3> Local $target_date = @YEAR + 1 & '/01/01 00:00:00' Local $hrs, $mins, $secs, $days = 0, $diff, $warn = 365 * 24 * 60 * 60, $warn_intrvl = 2 * 60 * 60, $display_time, $iStartApp = 2 * 60 * 60, $started = False ConsoleWrite($warn & ' ' & $warn_intrvl & @LF) Local $gui010 = GUICreate('', @DesktopWidth, 20, (@DesktopWidth) / 2, 20, $ws_popup, BitOR($ws_ex_layered, $ws_ex_topmost)) GUISetBkColor(0xABCDEF) Local $lbl010 = GUICtrlCreateLabel('', 0, 0, 600, 20) GUICtrlSetFont(-1, 10, 800, -1, 'lucinda console') _WinAPI_SetLayeredWindowAttributes($gui010, 0xABCDEF, 250) GUISetState() AdlibRegister('_update', 1000) While GUIGetMsg() <> $gui_event_close WEnd Func _update() $diff = _DateDiff('s', _NowCalc(), $target_date) If $diff < $iStartApp And Not $started Then $started = True MsgBox(0, "Test", "Start your app") EndIf ; calcs from UEZ Local $secs = Mod($diff, 60) Local $mins = Mod(Int($diff / 60), 60) Local $hrs = Int($diff / 60 ^ 2) If $hrs > 23 Then $days = Floor($hrs / 24) $hrs -= $days * 24 EndIf Local $diff_out = StringFormat('%02i Days %02i Hours %02i Minutes %02i Seconds to ' & StringLeft($target_date, StringInStr($target_date, ' ')), $days, $hrs, $mins, $secs) GUICtrlSetData($lbl010, $diff_out) $warn -= 1 If Mod($warn, $warn_intrvl) = 0 Then TrayTip('', $warn_intrvl & ' seconds have passed' & @LF & $diff_out, 5) ConsoleWrite('Displaying traytip at ' & $diff_out & @LF) $display_time = 1 EndIf If $display_time = 10 Then TrayTip('', '', 0) $display_time = 0 EndIf If $display_time Then $display_time += 1 EndFunc ;==>_update The math behind the time calculation is very simple and should be calculated in seconds! Further, don't open a new topic everytime when you got a new question for the same topic! Br, UEZ Edited December 10, 2012 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
noobish Posted December 10, 2012 Author Share Posted December 10, 2012 @UEZ Yes i will not open another topic.In the script you gave me and i thank you very much it throws some errors,and i can not understand how it executes another .exe in an exact time i.e 2 hours before new eve or when a user opens his pc and is after 00:00 and 1/1/2013.Errors i get from the above script.: ERROR: syntax errorLocal $target_date = @YEAR + 1 & '/01/01 00:00:00'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^C:\Documents and Settings\Georgios\Desktop\testtttttAuto\project.au3(8,59) : ERROR: syntax errorConsoleWrite($warn & ' ' & $warn_intrvl & @LF)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^C:\Documents and Settings\Georgios\Desktop\testtttttAuto\project.au3(10,124) : ERROR: syntax errorLocal $gui010 = GUICreate('', @DesktopWidth, 20, (@DesktopWidth) / 2, 20, $ws_popup, BitOR($ws_ex_layered, $ws_ex_topmost))~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^C:\Documents and Settings\Georgios\Desktop\testtttttAuto\project.au3(14,43) : WARNING: $gui010: possibly used before declaration._WinAPI_SetLayeredWindowAttributes($gui010,~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^C:\Documents and Settings\Georgios\Desktop\testtttttAuto\project.au3(40,179) : ERROR: syntax error Local $diff_out = StringFormat('%02i Days %02i Hours %02i Minutes %02i Seconds to ' & StringLeft($target_date, StringInStr($target_date, ' ')), $days, $hrs, $mins, $secs)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^C:\Documents and Settings\Georgios\Desktop\testtttttAuto\project.au3(41,38) : WARNING: $diff_out: possibly used before declaration. GUICtrlSetData($lbl010, $diff_out)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^C:\Documents and Settings\Georgios\Desktop\testtttttAuto\project.au3(44,92) : ERROR: syntax error TrayTip('', $warn_intrvl & ' seconds have passed' & @LF & $diff_out, 5)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^C:\Documents and Settings\Georgios\Desktop\testtttttAuto\project.au3(14,43) : ERROR: $gui010: undeclared global variable._WinAPI_SetLayeredWindowAttributes($gui010,~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^C:\Documents and Settings\Georgios\Desktop\testtttttAuto\project.au3(41,38) : ERROR: $diff_out: undeclared global variable. GUICtrlSetData($lbl010, $diff_out)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^C:\Documents and Settings\Georgios\Desktop\testtttttAuto\project.au3 - 7 error(s), 2 warning(s)!>14:22:24 AU3Check ended. Press F4 to jump to next error.rc:2Thank you very much. Link to comment Share on other sites More sharing options...
UEZ Posted December 10, 2012 Share Posted December 10, 2012 (edited) Try again please. I appeared after I edited the post and I forgot to switch to full edit mode. Just modify the $target_date value, let say e.g. $target_date = '2012/12/10 15:45:00' and wait. You have to enter a time 2h ahead from your local time. Br, UEZ Edited December 10, 2012 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
noobish Posted December 10, 2012 Author Share Posted December 10, 2012 @UEZ Yes now it works ok, i feel ashamed to bother you and all the others, but is this script suppose to run an .exe ( in my case another compiled script which installs a wallpaper at a specified time ) and if yes in which part of the script i must put the .exe i have ( the name,path). Thank you,i have no words. Link to comment Share on other sites More sharing options...
UEZ Posted December 10, 2012 Share Posted December 10, 2012 (edited) Look at line 28: MsgBox(0, "Test", "Start your app") There could be the Run() command. Br, UEZ Edited December 10, 2012 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
noobish Posted December 10, 2012 Author Share Posted December 10, 2012 @UEZ What can i say , once again Thank you very much Link to comment Share on other sites More sharing options...
guinness Posted December 10, 2012 Share Posted December 10, 2012 noobish, My advice for you is read what the error says and follow the line so you can see it for yourself. Without looking at the code I can tell the ampersand (&) is being replaced with the HTML code equivalent. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
noobish Posted December 10, 2012 Author Share Posted December 10, 2012 @guinness Thank you for the info but i got no errors for now. Thank you all 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