Jump to content

Recommended Posts

Posted (edited)

I have a script that has a GUI and I have been running with a start button using the below code:

        Case $StartButton

 

I would also like to try scheduling this using Windows TaskScheduler to run every morning at 8 AM EST. What would be the best way to add a condition to either start with the start button OR when TaskScheduler runs at 8 AM EST (or any specific time)? I am hesitant to just do 8 AM condition as it may increase processing a lot always looking at the time.

 

Essentially what I am looking to have happen is for my computer to auto-unlock (login?) using task scheduler and run this script

Edited by Nick3399
Posted
1 hour ago, Nine said:

Just add a command line parameter when run from task scheduler.

How would I do that? Is there any documentation I can reference

Posted (edited)
1 hour ago, Jos said:

Google?

So would the Run Line in Task Manager be something along the lines of:

"C:\Program Files\Documents\MYFILE.EXE " & "/parm1=Value"

and then in my code 

 Case $StartButton OR $CmdLine[0]= "parm1"

 

The documentation is quite confusing for this and I am not really understanding 

Edited by Nick3399
Posted

You need to use $CmdLine[0] and $CmdLine[1].  See here.

You probably need to start it once.  So insert the statement before the GUI loop, something like :

....

If $CmdLine[0] and $CmdLine[1] = "Start" then StartFunction()

GuiSetState()
While True
...
WEnd

Making a runable script would greatly help us to help you.  For the next topic please provide an example script so we can adapt it more easily...

Posted
2 minutes ago, Nine said:

You need to use $CmdLine[0] and $CmdLine[1].  See here.

You probably need to start it once.  So insert the statement before the GUI loop, something like :

....

If $CmdLine[0] and $CmdLine[1] = "Start" then StartFunction()

GuiSetState()
While True
...
WEnd

Making a runable script would greatly help us to help you.  For the next topic please provide an example script so we can adapt it more easily...

I just updated my last posts code - can you tell me if that is now correct?

Posted
6 minutes ago, Nick3399 said:

can you tell me if that is now correct?

No it is not correct.

Please provide a runable script with basic statements so we can help you.  I will not repeat this request another time.

Posted (edited)
18 hours ago, Nine said:

No it is not correct.

Please provide a runable script with basic statements so we can help you.  I will not repeat this request another time.

 

FilePath is:  C:\Users\robert\OneDrive\Desktop\TempFile.exe

Block of relevant code is below:

 

While 1
    
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Save
            SaveOptions()

        Case $StartButton
            ;TAB1 of GUI
            
            
If WinExists("[CLASS:QT373947473845]") Then
$oBlah = WinGetHandle("[CLASS:QT373947473845]")
$BSLoc = WinGetPos ("[CLASS:QT373947473845]")

If $BSLoc[0] <> 0 or $BSLoc[1] <> 0 or $BSLoc[2] <> 800 or $BSLoc[3] <> 600 Then
WinSetState ( $oBlah, "", @SW_MINIMIZE )
sleep(500)
WinActivate($oBlah)
WinWaitActive($oBlah)
WinMove($oBlah, "", 0, 0, 800, 600)
sleep(2000)
Else
WinActivate($oBlah)
WinWaitActive($oBlah)
sleep(2000)
EndIf
Endif   
            
    EndSwitch
WEnd

 

The Case $StartButton is the line where I am trying to do an OR if run by TaskManager

Edited by Nick3399

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...