Autoit

Tutorials

29/07/2009 15:41
Tutorial - HelloWorld This tutorial explains the basics of creating an AutoIt script and running it. The tutorial assumes that you have already fully installed AutoIt v3 using the supplied installer.   First open a folder where you wish to create the script. Right-click in the folder and...

Information

29/07/2009 15:35
Introduction AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or...

Autoit Forum

Date 05/08/2009

By admin

Subject check if software is running

Reply

used in stop debugging
Code:

Dim processes() As Process
Dim instance As Process
Dim process As New Process()
processes = process.GetProcesses
For Each instance In processes
If instance.ProcessName = "Notepad" Then
'Do something to or with this process or set a flag indicating that the desired process exists...
End If
Next



Be aware that you could have multiple instances or no instances of Notepad.exe (or whatever) running.

You could also do something like this:

Code:

Dim myProcesses() As Process
Dim instance As Process
myProcesses = Process.GetProcessesByName("Notepad")
For Each instance In myProcesses
'Do something to or with each instance of "Notepad" or set a flag if an instance is found...
Next







That is Exactly what I was looking for. I actuly combined both of your ideas and got it working just the way I wanted. I was looking to make sure my app didn't run while another app was running. I actually had it work with a twist of your first idea. But this way I have more control and let the User know to stop the other app first. Thank you so much foryour assistance in this matter. Her is a example of what I have that is working. Maybe it may be of help to others here.



Code:
Imports System.Threading

Module modMain
Public mtx As Mutex

Public Sub Main()
Dim bCreated As Boolean
Dim myProcesses() As Process
Dim instance As Process
myProcesses = Process.GetProcessesByName("NotePad")
For Each instance In myProcesses
MsgBox("Please Exit NotePad Application... Then Try Again.", MsgBoxStyle.Critical, "NotePad Application Still Running?")
End
Next
mtx = New Mutex(False, "MyApp", bCreated)
If bCreated = True Then
Application.Run(New Form1())
Else
End
End If

End Sub


Thanks
PBSnake

https://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/ff61633b-9115-4161-be8d-d59c0b4aa51f/
https://visualbasic.ittoolbox.com/groups/technical-functional/vb-dotnet-l/is-excel-installed-615453




Date 01/08/2009

By Administrator

Subject Creating a Command using if statement to open/close cd tray in autoit

Reply

;====================================================
;================= Example of a GUI =================
;====================================================
; AutoIt version: 3.0.103
; Language: English
; Author: "nativman"
;
; ----------------------------------------------------------------------------
; Script Start
; ----------------------------------------------------------------------------

;Include constants
#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

_Main()

Func _Main()

;Initialize variables
Local $GUIWidth = 300, $GUIHeight = 250
local $me,$y,$msg

#forceref $Edit_1

;Create window
GUICreate("New GUI", $GUIWidth, $GUIHeight)
$me = inputbox("Runner","Commander","open")

GUISetState(@SW_SHOW)

;Loop until:
;- user presses Esc
;- user presses Alt+F4
;- user clicks the close button
While 1
;After every loop check if the user clicked something in the GUI window
$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE
GUIDelete()
Exit
case $msg = $me
if $me = "open" Then
CDTRAY("E:","open")
elseif $me = "close" Then
CDTRAY("E:","closes")
EndIf
GUIDelete()
Exit
EndSelect

WEnd
EndFunc ;==>_Main

Date 01/08/2009

By Administrator

Subject Creating a Run in autoit

Reply

code:

local $d
$d = inputbox("Program Launcher","Command","cmd")
Run($d)