Jump to content

How to place number list to my MsgBox?


gracea
 Share

Go to solution Solved by gracea,

Recommended Posts

.

 

Wheew! I give up again.

Twerked around google and this forum. Found somewhat similar but - again too many codes. Found from autoit samples - less code. Then got headaches again. This is where the code originates: '?do=embed' frameborder='0' data-embedContent>>

Do it guys..Please.

Got to hibernate now.

#include <array.au3>


Local $ProcessListss[3]               ; [N] = TOTAL LIST COUNT
$ProcessListss[0] = "calc.exe"        ; CALCULATOR
$ProcessListss[1] = "notepad.exe"     ; NOTEPAD
$ProcessListss[2] = "mspaint.exe"     ; MSPAINT

Local $ListToMsgBoxx
Local $NumberListss

For $i = 0
$NumberListss = $NumberListss[$i] +1
Next

For $ProcessNamee IN $ProcessListss
     If ProcessExists($ProcessNamee) Then
         ;MsgBox(4096,"",$ProcessNamee)
         $ListToMsgBoxx &= $NumberListss & ". " & $ProcessNamee & @CRLF
     EndIf
     Sleep (100)
Next


MsgBox(4096,"",$ListToMsgBoxx)

.

 

Thanks.

:P " Loved It ! " :wub:

Link to comment
Share on other sites

So read the help file and understand the fundamental basics. Your code is a mess as it's using variables which aren't arrays and vice versa.

Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

 

Do it guys..Please.

 

I see I was mistaken giving you the solution to your last problem.  Time to start reading the Help file.  You might start with how a "for...to" loop is constructed.

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

hi lady,

 
Did you mean to write this?
#include <array.au3>


Local $ProcessListss[4]
$ProcessListss[0] = 3                 ; [N] = TOTAL LIST COUNT
$ProcessListss[1] = "calc.exe"        ; CALCULATOR
$ProcessListss[2] = "notepad.exe"     ; NOTEPAD
$ProcessListss[3] = "mspaint.exe"     ; MSPAINT

Local $ListToMsgBoxx
Local $NumberListss = 0

;For $i = 0
;$NumberListss = $NumberListss[$i] +1
;Next



For $a = 1 to $ProcessListss[0]
     If ProcessExists($ProcessListss[$a]) Then
         $ListToMsgBoxx &= $ProcessListss[$a]
         $NumberListss += 1
         If $a < $ProcessListss[0] Then $ListToMsgBoxx &= @CRLF
     EndIf
 Next

If $NumberListss > 0 Then
    $ListToMsgBoxx = $NumberListss&" Processes running:"&@CRLF&$ListToMsgBoxx
Else
    $ListToMsgBoxx = "No Processes running"
EndIf

MsgBox(4096,"",$ListToMsgBoxx)
Link to comment
Share on other sites

I see I was mistaken giving you the solution to your last problem.  Time to start reading the Help file.  You might start with how a "for...to" loop is constructed.

You weren't to know. I just had a hunch that handing out free would code would be a bad idea in this instance.

gil900,

That really doesn't help the user if they have zero clue of what is happening in AutoIt.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

You weren't to know. I just had a hunch that handing out free would code would be a bad idea in this instance.

gil900,

That really doesn't help the user if they have zero clue of what is happening in AutoIt.

I thought that if she edited the code so she tried to figure out what's going on and what needs to happen ..

So if I give corrected code(And that code is what she might intend to write) in that case, maybe she will understand how it works because maybe she was going to write such logic anyway

Edited by Guest
Link to comment
Share on other sites

czardas..

from script example from post #1 try not to change much of the code.

if calculator, notepad and mspaint are opened.

the result of msgbox should be

1. calc.exe

2. notepad.exe

3. mspaint.exe

if notepad and mspaint only opened msgbox result should be

1. notepad.exe

2. mspaint.exe

:P " Loved It ! " :wub:

Link to comment
Share on other sites

gil900.. still no luck.. ill try again..

kylomas.. sorry for the frustration.. i frequently use it - soon my neighbors will - it wont be wasted.

guinness.. please dont hold them how to help - its not a bad thing.

try this:

#include <array.au3>


MsgBox(0,"Step 1 [Line 4 in the code]","I create a table of all the processes that you want to check")
Local $ProcessListss[4]
$ProcessListss[0] = 3                 ; [N] = TOTAL LIST COUNT
$ProcessListss[1] = "calc.exe"        ; CALCULATOR
$ProcessListss[2] = "notepad.exe"     ; NOTEPAD
$ProcessListss[3] = "mspaint.exe"     ; MSPAINT
_ArrayDisplay($ProcessListss,"The table is [Line 10 in the code]")
MsgBox(0,"[Line 11 in the code]","$ProcessListss[0] = how many processes in that table.")

MsgBox(0,"Step 2.1 [Line 13 in the code]","I create $ListToMsgBoxx that is the text in the final MsgBox")
Local $ListToMsgBoxx
MsgBox(0,"Step 2.2 [Line 15 in the code]","I create $NumberListss Which will be used to count the running processes in the table above")
Local $NumberListss = 0

;For $i = 0
;$NumberListss = $NumberListss[$i] +1
;Next


MsgBox(0,"Step 3 - Starting loop [Line 23 in the code]","Now I starting a loop from 1($a = 1) to 3($ProcessListss[0])")
For $a = 1 to $ProcessListss[0]
    MsgBox(48,"[Line 25 in the code]","Loop round "&$a&"($a):")
    MsgBox(0,"[Line 26 in the code]","I check if the processes "&$ProcessListss[$a]&" (raw number "&$a&" ($a) in the tabel and round number "&$a&" ($a) in the loop) is running")
     If ProcessExists($ProcessListss[$a]) Then
         MsgBox(64,"[Line 28 in the code]","the processes "&$ProcessListss[$a]&" ($ProcessListss[$a]) is running!"&@CRLF&"So now:")
         $ListToMsgBoxx &= $ProcessListss[$a]&@CRLF
         MsgBox(0,"[Line 29 in the code]",'By "$ListToMsgBoxx &= $ProcessListss[$a]" I adding to the string $ListToMsgBoxx a new string that is the running processes ($ProcessListss[$a])'&@CRLF& _
         "The result is:"&@CRLF&$ListToMsgBoxx)
         $NumberListss += 1
         MsgBox(0,"[Line 33 in the code]",'By "$NumberListss += 1" i Increases the nummber of the running processes by 1'&@CRLF& _
         "Number of processes that in the table and are also running."&@CRLF&"$NumberListss is now = "&$NumberListss)
     EndIf
 Next

MsgBox(0,"Step 4 - Building the text for the OutPut message [Line 38 in the code]",'"If $NumberListss > 0 Then" = If more then 0 process are running')
If $NumberListss > 0 Then
    $ListToMsgBoxx = $NumberListss&" Processes running:"&@CRLF&$ListToMsgBoxx
    MsgBox(0,"[Line 39 in the code]","Because there are some processes that run i did the following:"&@CRLF& _
    "I added the number ($NumberListss) that i built before during the loop in step 3 to the stirng($ListToMsgBoxx)")
Else
    $ListToMsgBoxx = "No Processes running"
    MsgBox(0,"[Line 45 in the code]","Because no processes running i did the following:"&@CRLF& _
    'I change the output string($ListToMsgBoxx) to: "No Processes running"')
EndIf


MsgBox(4096,"",$ListToMsgBoxx)
Link to comment
Share on other sites

That's easy. Comments explaining each step are in green. I decided to change the variable names - to hopefully make the code easier to understand.

;

Local $aProcessList[4] ; Declare an array with four elements.

; Assign values to the elements of the array.
$aProcessList[0] = 3                 ; [N] = TOTAL LIST COUNT
$aProcessList[1] = "calc.exe"        ; CALCULATOR
$aProcessList[2] = "notepad.exe"     ; NOTEPAD
$aProcessList[3] = "mspaint.exe"     ; MSPAINT

Local $sMessage ; This will be the information displayed in the message box.
Local $iItemsFound = 0

For $a = 1 to $aProcessList[0] ; Loop through the array
     If ProcessExists($aProcessList[$a]) Then ; Test to see if the process is running.
         $iItemsFound += 1 ; The number of processes found so far.
         $sMessage &= $iItemsFound & ". " & $aProcessList[$a] & @CRLF ; Add each new line to the message
     EndIf
 Next

If $iItemsFound = 0 Then $sMessage = "No Processes running" 

MsgBox(4096,"",$sMessage)

;

Edit

Modified - I forgot to include the dot after each number.

Edited by czardas
Link to comment
Share on other sites

  • Solution

gil900..

sorry for misunderstanding its not like that. Thanks :wub:  for your effort.

 

czardas..

It does what i wanted. quite confusing for this ($aProcessList[$a]).. but i see it clearly .. i could easily understood it. Then i see the solution through your sample to my sample above which provided by kylomas :P .

I prefer this one because its too simple. [N] is my personal reference when i add more elements.

#include <array.au3>


Local $ProcessListss[3]               ; [N] = TOTAL LIST COUNT
$ProcessListss[0] = "calc.exe"        ; CALCULATOR
$ProcessListss[1] = "notepad.exe"     ; NOTEPAD
$ProcessListss[2] = "mspaint.exe"     ; MSPAINT


Local $ListToMsgBoxx
Local $NumberListss


For $ProcessNamee IN $ProcessListss
     If ProcessExists($ProcessNamee) Then
         $NumberListss += 1
         $ListToMsgBoxx &= $NumberListss & ". " & $ProcessNamee & @CRLF
     EndIf
     Sleep (100)
Next


MsgBox(4096,"",$ListToMsgBoxx)

.

 

Thanks czardas for sample. :wub:

:P " Loved It ! " :wub:

Link to comment
Share on other sites

Good, I'm happy to see you are getting there - making modifications yourself. What people were saying about reading the help file and trying the examples is well worth the effort. Try to stay on the good side of the fence. Many people have helped me here a lot over the years.

Edited by czardas
Link to comment
Share on other sites

Good, I'm happy to see you are getting there - making modifications yourself. What people were saying about reading the help file and trying the examples is well worth the effort. Try to stay on the good side of the fence. Many people have helped me here a lot over the years.

 

 

:wub:

:P " Loved It ! " :wub:

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