Jump to content

Is it possible to do?


Recommended Posts

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

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

_Singleton() is your friend here.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

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.

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...