Jump to content
Sign in to follow this  
SirDarknight1200

Is it possible to do?

Recommended Posts

SirDarknight1200

I was thinking if it is possible :

When I first open my script it will show a msgbox/gui etc.... but other time I'll run it it won't show it

Example :

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

MsgBox(0, "Test", "Welcome to my project") ;~It will only be shown on the first run of this app 

$Form1 = GUICreate("Form1", 448, 276, 321, 124)
$Button1 = GUICtrlCreateButton("This is a button", 56, 104, 329, 81)
GUISetState(@SW_SHOW)


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

    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
Starg

One solution is create a file so your script can tell if it is the first run.

Example :

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$myFile = @ScriptDir & "\MyFile.dat"

If Not FileExists( $myFile ) Then
      MsgBox(0, "Test", "Welcome to my project") ;~It will only be shown on the first run of this app 
      FileWrite( $myFile, "Already run" )
EndIf


$Form1 = GUICreate("Form1", 448, 276, 321, 124)
$Button1 = GUICtrlCreateButton("This is a button", 56, 104, 329, 81)
GUISetState(@SW_SHOW)


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

    EndSwitch
WEnd
Edited by Starg

Share this post


Link to post
Share on other sites
orbs

_Singleton() is your friend here.

Share this post


Link to post
Share on other sites
PhoenixXL

If both your apps would run at the same time then the app can change operations for when it is run at the second time or third...

_Singleton would help you in this case as Orbs suggested.

If both your apps won't run at the same time then you would have to have something permanent to find out if the app is already executed before.

for this you can go as Starg suggested. Other alternatives are writing to the Registry or INI file, having a server-check ( Internet connection required )...

Regards 

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

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  

×