caramen Posted January 28, 2019 Posted January 28, 2019 (edited) Hello guys, I have this sample of code : Func _EnumBoites () Local $cKey ="HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Search" Local $sSubKey = "", $sEnumBoite = $cKey & @CRLF & @CRLF , $sEnumBoiteFTV ; Loop from 1 to 20 times, displaying registry keys at the particular instance value. $ListView2 = GUICtrlCreateTreeView ( 260,150,200,100) $cCombo0002 = GUICtrlCreateCombo ("Choisir une boite" ,300,260 , 150 , 50 ) For $i = 1 To 20 ;~ MsgBox(0, "debug $i boite:", $i) $sSubKey = RegEnumVal("HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Search", $i) ;~ MsgBox(0, "Debug SubKey", $sSubKey) If @error Then ExitLoop $StringRight = StringRight ( ""&$sSubKey , 4 ) ;~ MsgBox(0, "Debug StringTrim", $StringRight) If $StringRight = ".ost" Or $StringRight = ".pst" Then If $StringRight = ".ost" Then $NombreBoites += 1 If $StringRight = ".pst" Then $NombrePst += 1 ========================================================================== ;~ MsgBox(0, "Debug", @UserName) ;~ $StringToFind = @UserName ;~ $StringCount = StringInStr ( ""&$sSubKey, ""&$StringToFind ,0,1 , 11) ;~ MsgBox(0, "Debug", $debug) ;~ If $StringCount > 0 Then $MailPrincipal = "" GUICtrlSetBkColor ( $cLabel00013 , 0x00FF01 ) GUICtrlSetData ( $cLabel0004 , "Nombre de PST : "&$NombrePst ) $sEnumBoite &= "#" & $i & @TAB & $sSubKey & @CRLF $sEnumBoiteFTV = $cKey & "\" & $sSubKey & @TAB & @CRLF GUICtrlCreateTreeViewItem($sSubKey,$ListView2) GUICtrlSetData($cCombo0002, ""&$sSubKey) ;~ MsgBox(0, "Debug", $sEnumBoite) Else EndIf Next $_EnumBoites = 1 EndFunc I want to make a line to replace ============================ by a variable $Var I want to say : If $StringRight = ".pst" Then $NombrePst += 1 $PstNumero1 = $sSubKey EndIF My problem is here how to increment $PstNumero1 at each for loop And say PstNumero2 PstNumero3 etc... I did that : If $StringRight = ".ost" Or $StringRight = ".pst" Then If $StringRight = ".ost" Then $NombreBoites += 1 If $StringRight = ".pst" Then $NombrePst += 1 If $NombrePst = 1 Then $PstNumero1 = $sSubKey ElseIf $NombrePst = 2 $PstNumero2 = $sSubKey ElseIf $NombrePst = 3 $PstNumero3 = $sSubKey ElseIf $NombrePst = 4 $PstNumero4 = $sSubKey ElseIf $NombrePst = 5 $PstNumero5 = $sSubKey ElseIf $NombrePst = 6 $PstNumero6 = $sSubKey ElseIf $NombrePst = 7 $PstNumero7 = $sSubKey ElseIf $NombrePst = 8 $PstNumero8 = $sSubKey ElseIf $NombrePst = 9 $PstNumero9 = $sSubKey EndIf ;~ MsgBox(0, "Debug", @UserName) ;~ $StringToFind = @UserName ;~ $StringCount = StringInStr ( ""&$sSubKey, ""&$StringToFind ,0,1 , 11) ;~ MsgBox(0, "Debug", $debug) ;~ If $StringCount > 0 Then $MailPrincipal = "" GUICtrlSetBkColor ( $cLabel00013 , 0x00FF01 ) Maybe there is a better way to do same ? Edited January 28, 2019 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
FrancescoDiMuro Posted January 28, 2019 Posted January 28, 2019 Hi @caramen Since we can't use your code, we can only guess that in the second script you want to increment by 1 the variable $PstNumero1 if $StringRight = ".pst". Why don't you just increment it using +=1 as you are already doing with the variable $NombrePst? Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
caramen Posted January 28, 2019 Author Posted January 28, 2019 Here is the full code: expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.5 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <GUIConstantsEx.au3> #include <ColorConstantS.au3> #include <WindowsConstants.au3> Global $ScanOutlook Global $PresenceOutlook= "" , $PresenceProfilOutlook = "" , $i = "" , $Background = 0 , $_EnumBoites = 0 , $NombreBoites = 0 , $NombrePst = 0,$PstNumero1 = "",$PstNumero2 = "",$PstNumero3 = "",$PstNumero4 = "",$PstNumero5 = "",$PstNumero6 = "",$PstNumero7 = "",$PstNumero8 = "",$PstNumero9 = "",$PstNumero10 = "", $hGUI = GUICreate ( "ITMigra", 600 , 600 ) $Tab01 = GUICtrlCreateTab ( 5,5 ) $Tabitem00001 = GUICtrlCreateTabItem ("Outlook") $cLabel0001 = GUICtrlCreateLabel ("Outlook Présent :",10,30) $cLabel00011 = GUICtrlCreateLabel ("",250,30) $cLabel0002 = GUICtrlCreateLabel ("Profil Outlook Présent :",10,60) $cLabel00012 = GUICtrlCreateLabel ("",250,60) $cLabel0003 = GUICtrlCreateLabel ("Présence de PST :",10,90,100,100) $cLabel00013 = GUICtrlCreateLabel ("",250,90) $cLabel0004 = GUICtrlCreateLabel ("Nombre de PST :",10,120,100,100) GUISetBkColor($COLOR_RED) GUISetState( @SW_SHOW , $hGUI ) ; 0x00FF01 );Vert vif ; 0xFB1924 );Rouge vif ; 0x4486FA );Bleu google ; 0x00A2E8 );Bleu autre While 1 Sleep (10) _ScanComputer () $msg = GUIGetMsg () Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _ScanComputer () If $PresenceOutlook= "" Then _ScanOutlook () EndIf If $PresenceOutlook= "Oui" Then GUICtrlSetBkColor ( $cLabel00011 , 0x00FF01 );Vert vif Else GUICtrlSetBkColor ( $cLabel00011 , 0xFB1924 );Rouge vif EndIf If $PresenceProfilOutlook = "" Then _EnumProfil () EndIf If $PresenceProfilOutlook = "Oui" Then GUICtrlSetBkColor ( $cLabel00012 , 0x00FF01 );Vert vif Else GUICtrlSetBkColor ( $cLabel00012 , 0xFB1924 );Rouge vif EndIf $Background += 1 If $Background > 100 Then If $PresenceOutlook= "Oui" And $PresenceProfilOutlook = "Oui" Then GUISetBkColor ( 0x00A2E8) ;~ MsgBox ( 0 , "debug GUI COLOR" , 'Color should be Green' ) Else GUISetBkColor ( 0xFB1924) EndIf $Background = 0 EndIf If $_EnumBoites = 0 Then _EnumBoites () EndIf EndFunc Func _ScanOutlook () $ScanOutlook = _RegKeyExists("HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles") If $ScanOutlook = "" Then $PresenceOutlook= "Oui" ;~ MsgBox ( 0 , "debug" , '$PresenceOutlook= "Oui"' ) EndFunc Func _EnumProfil () Local $cKey ="HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles" Local $sSubKey = "", $sEnumKey = $cKey & @CRLF & @CRLF , $sEnumKeyFTV ; Loop from 1 to 10 times, displaying registry keys at the particular instance value. $ListView1 = GUICtrlCreateTreeView ( 30,150,200,100) $cCombo0001 = GUICtrlCreateCombo ("Choose a Profil" ,30,260 , 150 , 50 ) For $i = 1 To 10 ;~ MsgBox(0, "debug $i:", $i) $sSubKey = RegEnumKey("HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles", $i) If @error Then ExitLoop $sEnumKey &= "#" & $i & @TAB & $sSubKey & @CRLF $sEnumKeyFTV = $cKey & "\" & $sSubKey & @TAB & @CRLF GUICtrlCreateTreeViewItem($sEnumKeyFTV,$ListView1) GUICtrlSetData($cCombo0001, ""&$sEnumKeyFTV) Next _i () ;~ MsgBox(0, "Profils:", $sEnumKey) If $i = 0 Then ;~ MsgBox(0, "Debug", '$PresenceProfilOutlook = "Non"') $PresenceProfilOutlook = "Non" Else ;~ MsgBox(0, "Profils:", $sEnumKey) $PresenceProfilOutlook = "Oui" ;~ MsgBox(0, "Debug", '$PresenceProfilOutlook = "Oui"') EndIf EndFunc Func _i () If $i = 1 Then $i=0 ;~ MsgBox(0, "Debug $i", "I WAS 1 now IT IS 0") Else EndIf EndFunc Func _EnumBoites () Local $cKey ="HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Search" Local $sSubKey = "", $sEnumBoite = $cKey & @CRLF & @CRLF , $sEnumBoiteFTV ; Loop from 1 to 20 times, displaying registry keys at the particular instance value. $ListView2 = GUICtrlCreateTreeView ( 260,150,200,100) $cCombo0002 = GUICtrlCreateCombo ("Choisir une boite" ,300,260 , 150 , 50 ) For $i = 1 To 20 ;~ MsgBox(0, "debug $i boite:", $i) $sSubKey = RegEnumVal("HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Search", $i) ;~ MsgBox(0, "Debug SubKey", $sSubKey) If @error Then ExitLoop $StringRight = StringRight ( ""&$sSubKey , 4 ) ;~ MsgBox(0, "Debug StringTrim", $StringRight) If $StringRight = ".ost" Or $StringRight = ".pst" Then If $StringRight = ".ost" Then $NombreBoites += 1 If $StringRight = ".pst" Then $NombrePst += 1 If $NombrePst = 1 Then $PstNumero1 = $sSubKey ElseIf $NombrePst = 2 $PstNumero2 = $sSubKey ElseIf $NombrePst = 3 $PstNumero3 = $sSubKey ElseIf $NombrePst = 4 $PstNumero4 = $sSubKey ElseIf $NombrePst = 5 $PstNumero5 = $sSubKey ElseIf $NombrePst = 6 $PstNumero6 = $sSubKey ElseIf $NombrePst = 7 $PstNumero7 = $sSubKey ElseIf $NombrePst = 8 $PstNumero8 = $sSubKey ElseIf $NombrePst = 9 $PstNumero9 = $sSubKey EndIf ;~ MsgBox(0, "Debug", @UserName) ;~ $StringToFind = @UserName ;~ $StringCount = StringInStr ( ""&$sSubKey, ""&$StringToFind ,0,1 , 11) ;~ MsgBox(0, "Debug", $debug) ;~ If $StringCount > 0 Then $MailPrincipal = "" GUICtrlSetBkColor ( $cLabel00013 , 0x00FF01 ) GUICtrlSetData ( $cLabel0004 , "Nombre de PST : "&$NombrePst ) $sEnumBoite &= "#" & $i & @TAB & $sSubKey & @CRLF $sEnumBoiteFTV = $cKey & "\" & $sSubKey & @TAB & @CRLF GUICtrlCreateTreeViewItem($sSubKey,$ListView2) GUICtrlSetData($cCombo0002, ""&$sSubKey) ;~ MsgBox(0, "Debug", $sEnumBoite) Else EndIf Next $_EnumBoites = 1 EndFunc Func _RegKeyExists($_sRegKey) Local $sDefault = RegRead($_sRegKey, "") ;~ Try to read default value Switch @error Case 1, 2 ;~ Unable to open requested key | Unable to open requested main key Return SetError(@error, 0, 'Error: Registry Key: "' & $_sRegKey & '" does not exist.') Case Else ; Registry Key Exists | Return (Default) value Return SetError(0, 0, $sDefault) EndSwitch EndFunc My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
Danp2 Posted January 28, 2019 Posted January 28, 2019 Why not use an array for $PstNumero and then just increment the index value? Latest Webdriver UDF Release Webdriver Wiki FAQs
Developers Jos Posted January 28, 2019 Developers Posted January 28, 2019 The easy way really is to use an array for $PstNumero[$NombrePst]. ...else use assign(). Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
caramen Posted January 28, 2019 Author Posted January 28, 2019 I want to be able to select each return after the function have finished. For obvius reason. I want to record each pst in a $variable. like that with the return value : PSTnumero1 = C:\blablabalblaa My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
Nine Posted January 28, 2019 Posted January 28, 2019 use assign () “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
caramen Posted January 28, 2019 Author Posted January 28, 2019 Yeah i thought about an array but I was wondering if there is a "trick" to do it with some lines easyer that store everything in an array. Seem like to be the best way ... hmmm My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
Developers Jos Posted January 28, 2019 Developers Posted January 28, 2019 Just now, caramen said: if there is a "trick" There is and it is called assign() as stated. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
caramen Posted January 28, 2019 Author Posted January 28, 2019 (edited) Ah yeah i will give it a try i am going to do : Assign ("PSTNumero"&$NombrePst , ""&$sSubKey ) Will be very good for my case. @Jos Yeah no time to reply xD Thanks Thanks all. Edited January 28, 2019 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now