Sign in to follow this  
Followers 0
meows

wonder why ini file written to before runwait finishes

7 posts in this topic

Func Button2Click()   ;==>        SonoLvl2 *******************************************************
SoundPlay(@ScriptDir &  "\schoolbell.wav", 1)
Local $Test2 = IniRead(@ScriptDir &  "\runer.ini", "Levels", "LComplete1", "Default Value")
If $Test2 = 1 Then
;       $updatepid =
        RunWait(@ScriptDir & "\SonoLvl2\SonoLvl2_.exe", "", @SW_SHOWDEFAULT)
Else
    MsgBox(4096, "", "You did not complete Lesson1")

 EndIf
;MsgBox($MB_SYSTEMMODAL, "Bug Report Environment", _DebugBugReportEnv())


IniWrite(@ScriptDir &  "\runer.ini", "Levels", "LComplete2", "2")

EndFunc ;==>Button2Click

I have tried PID checks and updatepid per the help file and they just didn't work out. and usually caused errors. Then (not included I tried making a separate function to write to a INI file. that was a lesson in frustration and defeat. It worked.. just the same as the code in the function now. as soon as you click the button and the runwait line starts the ini gets updated. The file can only be written to after runwait is running is closed. Also tried the ProcessWait, ProcessWaitCloseShellExecute, ShellExecuteWait

Then in desperation I tried a Debug i read about

Func Button2Click()   ;==>        SonoLvl2 *******************************************************
$__iLineNumber=162 & ' - SoundPlay(@ScriptDir &  "\schoolbell.wav", 1)•'
SoundPlay(@ScriptDir &  "\schoolbell.wav", 1)
$__iLineNumber=163 & ' - Local $Test2 = IniRead(@ScriptDir &  "\runer.ini", "Levels", ...•'
Local $Test2 = IniRead(@ScriptDir &  "\runer.ini", "Levels", "LComplete1", "Default Value")
$__iLineNumber=164 & ' - If $Test2 = 1 Then•'
If $Test2 = 1 Then
        $__iLineNumber=165 & ' - $updatepid = RunWait(@ScriptDir & "\SonoLvl2\SonoLvl2_.exe", ...•'
        $updatepid = RunWait(@ScriptDir & "\SonoLvl2\SonoLvl2_.exe", "", @SW_SHOWDEFAULT)
Else
    $__iLineNumber=167 & ' - MsgBox(4096, "", "You did not complete Lesson1")•'
    MsgBox(4096, "", "You did not complete Lesson1")

 EndIf
;MsgBox($MB_SYSTEMMODAL, "Bug Report Environment", _DebugBugReportEnv())


$__iLineNumber=173 & ' - IniWrite(@ScriptDir &  "\runer.ini", "Levels", "LComplete2", ...•'
IniWrite(@ScriptDir &  "\runer.ini", "Levels", "LComplete2", "2")

EndFunc ;==>Button2Click

unfortunately I was not smart enough to get it to work for me. What I wanted was a Debugger that explains what each line does and why. Then I figured out that isn't happening.

Share this post


Link to post
Share on other sites



If SonoLvl2 is a script you've written, does it have a #requireadmin line in it?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

meows,

Runwait is indeed waiting as demonstrated by this code...

; *** Start added by AutoIt3Wrapper ***
#include <GUIConstantsEx.au3>
; *** End added by AutoIt3Wrapper ***

#AutoIt3Wrapper_Add_Constants=n

Local $gui010 = GUICreate('')
Local $aSize = WinGetClientSize($gui010)
Local $Button2 = GUICtrlCreateButton('Test INI', 0, 20, $aSize[0], 50)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $gui_event_close
            Exit
        Case $Button2
            Button2Click()
    EndSwitch
WEnd


Func Button2Click() ;==>        SonoLvl2 *******************************************************
    SoundPlay(@ScriptDir & "\schoolbell.wav", 1)
    Local $Test2 = IniRead(@ScriptDir & "\runer.ini", "Levels", "LComplete1", "Default Value")
    If $Test2 = 1 Then
        ;       $updatepid =.
        ;RunWait(@ScriptDir & "\SonoLvl2\SonoLvl2_.exe", "", @SW_showdefault)
        RunWait("notepad.exe", "", @SW_SHOWDEFAULT)
        ConsoleWrite(@error & @CRLF)
    Else
        MsgBox(4096, "", "You did not complete Lesson1")
    EndIf

    IniWrite(@ScriptDir & "\runer.ini", "Levels", "LComplete2", "2")

EndFunc   ;==>Button2Click

Try adding a test of @ERROR following the RunWait...

Hope this helps,

kylomas

edit: additional info 

If @error is returning non 0 then there is a problem with finding or executing your program (as BrewmanNH suggests).

If @error is 0 then SonoLvl2.exe may be spawning another program as Jos suggests.  From the Help file...

Some programs will appear to return immediately even though they are still running; these programs spawn another process - you may be able to use the ProcessWaitClose() function to handle these cases.

 

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

Oh my gosh this just keeps getting deeper and deeper.. I have the unfortunate or fortunate gift from the Lord to know a bit about a lot but not a lot about much and the more I know, the more I need to know. 2 year project oct 2011 start date.  At one time DOS4 I could make anything. even the first passenger boarding program for Bonanza airlines at McCarren Airport. Then having a few children and +8 years later I wake up and discover I was now dumb and stupid. +20 years and the world moved on. Now with forced medical retirement at 64 trying to learn things all over and WOW.

Yes #RequireAdmin is the first line. in the file.

My brain works by knowing the why and how of how of things and their works.

now not being really up to speed and finding the howto i need. i use what I can get,, I have 5 programs that are called at special times as needed. one must complete and I test that is is completed then the option to continue is presented.

SO I added more checks and Yes

What exactly does SonoLvl2_.exe do?
Does it maybe shell another program?

Jos

yes a required wrapper of my program. it runs my software with a security wrap.. SO I am told.

If SonoLvl2 is a script you've written, does it have a #requireadmin line in it?

yes first line is #requireadmin

However I am confused by the second tab in Compile and the ExecutionLevel radio buttons and what they imply. Does require Administrator mean they have to be the admin to run the program? Reason I ask is the highestavailable button that I would think is the Administrator .. either way where is the I am just a nobody wanting to run this software button?

meows,

Runwait is indeed waiting as demonstrated by this code...

; *** Start added by AutoIt3Wrapper ***
#include <GUIConstantsEx.au3>
; *** End added by AutoIt3Wrapper ***

#AutoIt3Wrapper_Add_Constants=n

Local $gui010 = GUICreate('')
Local $aSize = WinGetClientSize($gui010)
Local $Button2 = GUICtrlCreateButton('Test INI', 0, 20, $aSize[0], 50)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $gui_event_close
            Exit
        Case $Button2
            Button2Click()
    EndSwitch
WEnd


Func Button2Click() ;==>        SonoLvl2 *******************************************************
    SoundPlay(@ScriptDir & "\schoolbell.wav", 1)
    Local $Test2 = IniRead(@ScriptDir & "\runer.ini", "Levels", "LComplete1", "Default Value")
    If $Test2 = 1 Then
        ;       $updatepid =.
        ;RunWait(@ScriptDir & "\SonoLvl2\SonoLvl2_.exe", "", @SW_showdefault)
        RunWait("notepad.exe", "", @SW_SHOWDEFAULT)
        ConsoleWrite(@error & @CRLF)
    Else
        MsgBox(4096, "", "You did not complete Lesson1")
    EndIf

    IniWrite(@ScriptDir & "\runer.ini", "Levels", "LComplete2", "2")

EndFunc   ;==>Button2Click

Try adding a test of @ERROR following the RunWait...

Hope this helps,

kylomas

edit: additional info 

If @error is returning non 0 then there is a problem with finding or executing your program (as BrewmanNH suggests).

If @error is 0 then SonoLvl2.exe may be spawning another program as Jos suggests.  From the Help file...

You are right.

I did

If @error is returning non 0 then there is a problem with finding or executing your program (as BrewmanNH suggests).

>>Non issue it finds and run the program as requested

If @error is 0 then SonoLvl2.exe may be spawning another program as Jos suggests.  From the Help file...

Yes it does spawn a additional program it is a security wrapper. And that seems to be the issue..

SO to Fix this I think the answer is to use the DATE.au3

I put in

Func Button2Click()   ;==>        SonoLvl2 *******************************************************
MsgBox($MB_SYSTEMMODAL, "", "The current working directory: " & @CRLF & @WorkingDir)   ;test check remove if compile
$newdir1=@ScriptDir & "\00\Files\core"
 FileChangeDir($newdir1)

    ; Display the working directory after setting it to the core directory.
    MsgBox($MB_SYSTEMMODAL, "", "The current working directory: " & @CRLF & @WorkingDir) ;test check remove if compile

RunWait(@ComSpec & " /c " & "filetouch.exe /d 09-09-2000 *.jpg") ; don't forget " " before "/c"
SoundPlay(@ScriptDir &  "\schoolbell.wav", 1)
Local $Test2 = IniRead(@ScriptDir &  "\runer.ini", "Levels", "LComplete1", "Default Value")
If $Test2 = 1 Then
;        $updatepid =
        ProcessWaitClose(@ScriptDir & "\SonoLvl2\SonoLvl2_.exe")
Else
    MsgBox(4096, "", "You did not complete Lesson1")

 EndIf
;MsgBox($MB_SYSTEMMODAL, "Bug Report Environment", _DebugBugReportEnv())

Call Func Timecheck()
                        ;$file1_1 = FileGetTime("C:\file1.txt", 2, 1)
    $file1_1 = FileGetTime(@ScriptDir & "\00\Files\core\2a.jpg", 2, 1)   ;program file time
    $file1_2 = FileGetTime(@ScriptDir & "2a.jpg", 2, 1)   ;placeholder time
    If $file1_1 > $file1_2 Then
        ; They Completed task Do something here
    EndIf
    If $file1_2 == $file1_1 Then 
do nothing return to program

to me this is the answer to update the ini file. touch 2 image files. one in the program root dir the other in the called program directory, when a internal program ends the images are compared, if any time is different they did indeed complete the task and we continue. Now to make it happen.

Many thanks guys. you really made this old brain work.. and I think this is the way to handle this.. as soon as i figure it out.

suggestions ? am I totally off??

Many thanks for using your time to assist,, a blessing you are..

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

A script with #requireadmin will restart itself when not running with the right level credentials, meaning the first instances will end right away and shelling a new instance of the script.
Using one of these with force the original script (SonoLvl2_.au3) to start at the right level and should fix your issue:

#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
-or-
#pragma compile(ExecLevel, requireAdministrator)

Jos

ps.. I also started in the punchcard and CP/M era. :)

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

A script with #requireadmin will restart itself when not running with the right level credentials, meaning the first instances will end right away and shelling a new instance of the script.

Using one of these with force the original script (SonoLvl2_.au3) to start at the right level and should fix your issue:

#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
-or-
#pragma compile(ExecLevel, requireAdministrator)

Jos

ps.. I also started in the punchcard and CP/M era. :)

Going to try this asambfh (as soon as make breakfast for husband)

RE: ps.. I also started in the punchcard and CP/M era

Pre what we call a computer now// sitting on the floor with a TV for a monitor and a tape deck to store files. wow.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • breakbadsp
      By breakbadsp
      I want to run a python script from autoit. 
      I know we can do this with shellexecute or run , but this python script takes 3 cmd line arguments.
      How to pass them from autoit script?
      I tried many ways.
      Following solution also not working 
      e.g. 
      RunWait( 'fullpath\Python.exe Scriptpath\ReadLog.py  -f "file.log" -k "key" -e "errMsg" ') Found solution:
      RunWait( 'fullpath\Python.exe ReadLog.py -f "file.log" -k "key" -e "errMsg" ', 'Working_directory_path')  
      PFB description:
      https://stackoverflow.com/questions/45757834/how-to-pass-command-line-arguments-to-a-python-script-anyscript-while-executin
       
    • mati
      By mati
      Hi,
      I wonder if
      AutoIt3Wrapper_run_debug_mode = Y can include run information about functions which are called within the main code. So far I noticed in the console that the function itself is called but no specific run information from  inside the function is provided. Is there a chance to show the entire debug log including functions in the console?
      I furthermore noticed a stop of information when a loop is entered. What could be the reason for that?
       
      Thanks for help.
    • TrashBoat
      By TrashBoat
      Is this possible:
      Executing a function from an include, but taking the function name from a gui input and then executing that function using the include:
      #include <Something.au3> ;input reads "Tree" $functionName = GuiCtrlRead($input1) $functionName(1) And the include is gonna have
      Func Tree($x) If $x = 1 Then $this = "text" MsgBox(0,$this,"whatever") EndFunc is it possible?
    • hcI
      By hcI
      Hello, i'm making a little script that lets users enter a question and if the script can't answer to, it ask what would be the answer (a bit like siri on IPhones). And I try to display the "supposed array" I still have an error.. I searched on Google and got nothing looked in the help file too.. I'm here to know if someone have a solution to my error please.
      Here is where $a and $b should become arrays :
      Dim $dossier = @AppDataDir & "\Siri2" Dim $chemin = $dossier & "\data.ini" Global $a = _InfoRead($chemin, 0) Global $b = _InfoRead($chemin, 1) with this function :
      Func _InfoRead($path, $mode = 0) If DirGetSize($dossier) = -1 Then Return SetError(-4) If Not FileExists($chemin) Then Return SetError(-5) Local $readed = IniReadSection($path, "data") If @error Then Return SetError(-3) $size = $readed[0][0] Local $return[$size] For $i = 1 To $size Step 1 $return[$i - 1] = $readed[$i][$mode] Next Return $return EndFunc and the thing that i don't understand is that, after _InfoRead return affected to $a, I can't use _ArrayDisplay because of  error 1 "$aArray is not an array" (and same fpr the variable $b)..
      Can please someone help me to understand why is it doing this ?

      -hcI
    • kawliga751
      By kawliga751
      I'm new to Auotit but I have built a simple script that "runs" a different "batch" file based on certain days of the workweek. The script works now, but I was wanting to eliminate the need for a manual date entry. For example "First Batch' needs to run every Tuesday thru Thursday however "Second Batch" needs to run only on Friday and "Third Batch" needs to run only on Monday. In addition the 1st batch file runs on Tuesday, say 06/06 (the "FW" section) but then needs to actually report (the F4 date) the next weekday so this Batch actually needs 2 dates verified. 
      What I'm trying to do is when the script is initiated it gets the date, verifies if and which weekday it is and in turn goes to and runs the appropriate "Batch' file.  
      I've found ways to verify weekdays but can't find anything to do all of the above.
      Any help is MUCH appreciated.
       
      ;P10
      ShellExecute("C:\Program Files (x86)\Ericom Software\PowerTerm Enterprise\Sessions\mir00p10.PTS")

      WinWait('(A) Soutwest P10 : PowerTerm Pro Enterprise Suite')
      WinActivate('(A) Soutwest P10 : PowerTerm Pro Enterprise Suite')
      Send('$Login)
      Sleep(3000)
      Send('{Enter}')
      Sleep(3000)
      Send($Password)
      Send('{Enter}')
      Sleep(3000)
      ; ****First Batch file run
      Send('Batch')
      Sleep(3000)
      Send('{Enter}')
      Send('FW')
      Send('{Enter}')
      Send('{DOWN}')
      Send($Date)
      Send('{Enter}')
      Send('{Enter}')
      Send($Date)
      Send('{F9}')
      Send('Y')
      Sleep(3000)
      Send('{Enter}')
      Send('{F4}')
      Send('Y')
      Sleep(3000)
      Send('{Enter}')
      Send($Date)
      Send('{Enter}')
      Send('0620')
      Send('{Enter}')
      SEND('{!}SW0410PM.FWR')
      Send('{Enter}')
      Sleep(3000)
      Send('Y')
      Send('{Enter}')
      Sleep(3000)
      Send('{F9}')
      Sleep(3000)
      ; ****Second Batch file run
      Send('Batch')
      Sleep(3000)
      Send('{Enter}')
      Send('FW')
      Send('{Enter}')
      Send('{DOWN}')
      Send($Date)
      Send('{Enter}')
      Send('{Enter}')
      Send($Date)
      Send('{F9}')
      Send('Y')
      Sleep(3000)
      Send('{Enter}')
      Send('{F4}')
      Send('Y')
      Sleep(3000)
      Send('{Enter}')
      Send($Date)
      Send('{Enter}')
      Send('0620')
      Send('{Enter}')
      SEND('{!}SO0411AM.FWR')
      Send('{Enter}')
      Sleep(3000)
      Send('Y')
      Send('{Enter}')
      Sleep(3000)
      Send('{F9}')
      Sleep(3000)
      ; ****Third Batch file run
      Send('Batch')
      Sleep(3000)
      Send('{Enter}')
      Send('FW')
      Send('{Enter}')
      Send('{DOWN}')
      Send($Date)
      Send('{Enter}')
      Send('{Enter}')
      Send($Date)
      Send('{F9}')
      Send('Y')
      Sleep(3000)
      Send('{Enter}')
      Send('{F4}')
      Send('Y')
      Sleep(3000)
      Send('{Enter}')
      Send($Date)
      Send('{Enter}')
      Send('0620')
      Send('{Enter}')
      SEND('{!}SW0411AM.LOA')
      Send('{Enter}')
      Sleep(3000)
      Send('Y')
      Send('{Enter}')
      Sleep(3000)
      Send('{F9}')
      Sleep(3000)
      Send('EXIT')