jbennett Posted October 16, 2008 Posted October 16, 2008 (edited) Hi everyone, Got a bit of an issue with reading an ini file in AutoIT and was wondering if anyone knows what could be wrong, so here goes. 1 - My Ini file [TARGET] targetlocation="notepad.exe" [PARAMETERS] theparameters="" 2 - AutoIT read ini $targetlocation = IniRead("C:\Configuration.ini", "TARGET", "targetlocation", "") $parameters = IniRead("C:\Configuration.ini", "PARAMETERS", "theparameters", "") 3 - AutoIT code shellexecute ($targetlocation,$parameters,"") I think the problem is with "3 - AutoIT code" Hope someone knows what's going wrong here. Thanks Edited October 16, 2008 by jbennett
Scriptonize Posted October 16, 2008 Posted October 16, 2008 I can't see what's wrong with your code. I normally use the 'Run' command: Dim $App2Launch Dim $App2Launch_Path Dim $App2Launch_CmdLineParam Dim $RunMode .....Iniread section, assigning values to the vars.... $App2Launch_PID=Run($App2Launch_Path & $App2Launch & " " & $App2Launch_CmdLineParam,"",$RunMode) If you learn from It, it's not a mistake
jbennett Posted October 16, 2008 Author Posted October 16, 2008 (edited) It seems to work out of a loop, but as soon as I put it in my loop it decides to fail.While 1Sleep(1000)If int(@HOUR)=$hour1 And int(@Min)=$minute1 And int(@Sec)=$second1 Then Sleep(1000)shellexecute ($targetlocation,$parameters) endifWENdand the code above works fine if I put shellexecute ("notepad.exe","")Very strange? Edited October 16, 2008 by jbennett
Developers Jos Posted October 16, 2008 Developers Posted October 16, 2008 (edited) It seems to work out of a loop, but as soon as I put it in my loop it decides to fail. and the code above works fine if I put shellexecute ("notepad.exe","") How are these variables set and aqre you sure they are numeric and not strings? Its risky business to sleep 1 second and test for : If int(@HOUR)=$hour1 And int(@Min)=$minute1 And int(@Sec)=$second1 Then I would change that to Sleep(500) to ensure you are not skipping the second you are testing for. also: what is failing? are you getting any kind of error? Edited October 16, 2008 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
jbennett Posted October 16, 2008 Author Posted October 16, 2008 (edited) Nope, not getting any errorThis worksWhile 1Sleep(1000)If int(@HOUR)=$hour1 And int(@Min)=$minute1 And int(@Sec)=$second1 Then Sleep(1000)shellexecute ("notepad.exe","") endifWENdThis doesn't workWhile 1Sleep(1000)If int(@HOUR)=$hour1 And int(@Min)=$minute1 And int(@Sec)=$second1 Then Sleep(1000)shellexecute ($targetlocation,$parameters) endifWENdand the only different is the shellexecute bit.I'm not using notepad.exe. Im using ($targetlocation,$parameters) cheers Edited October 16, 2008 by jbennett
enaiman Posted October 16, 2008 Posted October 16, 2008 IMO - there is nothing wrong with ShellExecute. From my experience - if you try to match a time high chances are that it will fail. Why? Because of the Sleep inside the loop and the time it takes to execute the code; it is very easy that $second1 to be missed. I bet either code will be executed flawlessly if you change this line: If int(@HOUR)=$hour1 And int(@Min)=$minute1 And int(@Sec)>$second1 Then But in order to do that you will need to add something extra (to increment the time so the script won't run every cycle). $targetlocation = "notepad.exe" $parameters = "" $hour1 = 9 ;change values for your time $minute1 = 59 $second1 = 15 While 1 Sleep(500) If int(@HOUR)=$hour1 And int(@Min)=$minute1 And int(@Sec)>$second1 Then Sleep(1000) shellexecute ($targetlocation,$parameters) $second1 += 30 ;adds 30 sec = it will run notepad again after 30 sec endif WENd Change the time values to suit your needs and test it, you will see how well it works. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
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