Jump to content

Creating a IE Pop-up to run Once-a-day only


Recommended Posts

Hi there, I need some help please to get my pop-up script to run once-a-day

At present I am using this simple call script to open IE and point to a Sharepoint location to present a file to users when they log in. The problem is that with each login the IE pop-up appears, and my team is looking for some form of intelligence to work out that its already "run-once" that day and not re-run the script...

Script details:

#include <IE.au3>
$oIE = _IECreate ("https://sharepoint_server/popup1.png")
WinSetState ( "title", "text", @SW_MAXIMIZE )
Exit

Oh, and I can't get the IE window to maximize, any idea why? Any help will be greatly appreciated!!

Link to comment
Share on other sites

my team is looking for some form of intelligence to work out that its already "run-once" that day and not re-run the script...

When it runs, have it store a variable with the date either in the registry or in a config file. Then before running, have it check the value of that variable and if it's the current date, don't run.

Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Link to comment
Share on other sites

You could do it the simple way, with an INI file that has the last run date stored in it, and have your script read from that INI file to see if today's date <> last run date. Also, instead of using _IECreate, you could use ShellExecute("https://sharepoint_server/popup1.png").

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

Link to comment
Share on other sites

Iniread/IniWrite or RegRead/RegWrite depending on the path you want to take to accomplish this.

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

Link to comment
Share on other sites

Iniread/IniWrite or RegRead/RegWrite depending on the path you want to take to accomplish this.

Ok so something like this:

IniWrite("C:Tempmyfile.ini", "section1", "key", "date")

My next question would then be - how do we do the "IniRead" to check dates? (need some spoon feeding i'm afraid as my scripting skills are toliet)

Link to comment
Share on other sites

You can get the current date using the _NowDate() function, and compare it to the stored date. You can tailor the ini filename to the user's login name (@UserName macro), so that it will check for who ever logs in, rather than only running it once per computer per day. Change the "test.ini" to something like IniRead(@UserName & ".ini", "RunDate", "LastRunDate", "N/A"), you might want to include the path to the ini file in there as well.

#include <Date.au3>
If IniRead("test.ini", "RunDate", "LastRunDate", "N/A") <> _NowDate() Then ; checks to see if the stored date matches today's date
    MsgBox(64, "No match", "The stored date: " & IniRead("test.ini", "RunDate", "LastRunDate", "") & " doesn't match todays date: " & _NowDate()) ; if it doesn't match, displays this msgbox (demo only)
    IniWrite("test.ini", "RunDate", "LastRunDate", _NowDate()) ; because it hasn't been run today, we store today's date in the INI file
    ; place your code here
Else
    MsgBox(64, "Match", "The stored date: " & IniRead("test.ini", "RunDate", "LastRunDate", "") & " matches today's date: " & _NowDate()) ; we've already run this today
    Exit ; so we exit the script without doing anything more.
EndIf

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

Link to comment
Share on other sites

I'm glad that I could help, if you have any questions, please ask.

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

Link to comment
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
 Share

  • Recently Browsing   0 members

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