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                                How to post scriptsource        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

    • wakillon
      By wakillon
      SciTE Hopper : Jump to Any line by one click and many other helpfull functions !


      As Ashalshaikh suggested me after leaving me the task to continue >SciTE Hopper, i open a new Topic about it.
      It will be more easy for futures updates.

      Many helpfull functions in contextual menu.
      SciTE Hopper is now multipurpose.
      • Color Catcher added
      • BinaryToAu3Kompressor added
      • TinyAu3Search replaced by StringFinder
      • RegJumper added
      • Edit With SciTE added (available in Options)
      • SpecialCharactersViewer added (available in Tray menu)
      New Contextual Menu :

      For a right Click on a function :

      • Copy function name
      • Insert a function header
      • Cut function
      • Copy function
      • Delete function
      • Create a variables List
      • Remove usseless Blank lines
      • Remove Debug lines ( all lines starting with ConsoleWrite or _ArrayDisplay )
      • Set AutoIt Code Layout
      • Remove Comments

      For entire script :

      • Create a functions List
      • Create a variables List
      • Remove usseless Blank lines
      • Remove Debug lines ( all lines starting with ConsoleWrite or _ArrayDisplay )
      • Set AutoIt Code Layout
      • Remove Comments
      • ( Open in SciTE a ) Duplicate of current Script in Temp Dir
      • ( Open in SciTE a ) Duplicate of current Script in Same Dir
      • Explore Parent Script Folder
      • Copy Script name
      • Copy Script path
      • Find Unused Functions
      • Find Unused Variables
      • Set all functions in alphabetic order.( func headers and regions ( in fact, all lines between functions ) are not supported.)

      SciTE Editor New Contextual Menu if SciTE Hopper is added ( in Options ) to SciTE Editor :
      when you made a selection in SciTE Editor you can :

      • Open a Reg Key in Regedit using RegJumper
      • Open a Url in your default Browser
      • Search on google in your default Browser
      • Search on AutoIt Website in your default Browser
      Now Can be added to windows start (minimized)
      Options are available by Tray Menu.
      A double click on tray icon will open clipboard content to SciTE Editor ( Handy when you have copied some code from your browser )

      How to proceed for add SciTE Hopper to SciTE Editor :
      Run Scite Editor, run Scite Hopper ( compiled! ) go to Options and select Add/Remove to SciTE Tab. then click on Add button and it's done !
      Right click on SciTE Editor and choose SciTE Hopper in Contextual Menu for run it when you need it !
      Update of 07 Dec 2017
      TinyAu3Search is replaced by StringFinder

      Previous downloads : 1287
      Script and compiled version are available in the download section
       
      Thanks to Ashalshaikh, Melba23, Th3 MMA, Alzri2, taitel, Manadar, taz742, Yashield, Authenticity, Xenobiologist for their help
      and asdf8 for his >Includes Helper and azjio for his >FileSearch.

      Hope it help you and happy Scripting !

       
    • BlazerV60
      By BlazerV60
      Hello all,
      I've written the code below which launches chrome in incognito mode and then proceeds to go to the autoit website.
      From my understanding, the Run() command is also supposed to output the PID number related to the application that got launched from the Run command.
      However when I run the below lines, it outputs a PID number that is different from the newly launched chrome browser's PID number, does anyone know why and possibly explain how I could retrieve the accurate PID number associated with the newly launched browser?
      Global $iPid = Run(@ComSpec & ' /c start chrome.exe https://www.autoitscript.com/forum/ -incognito' ,"", "") msgbox(0,"",$iPid) Thank you,
      Brian
    • 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?