Leaderboard
Popular Content
Showing content with the highest reputation on 03/22/2019 in all areas
-
One way to face your problem is to think the opposite direction. Instead of trying to find the windows of a pid, you could try to find the pid of the windows. To do that : Use WinList to get all windows Use WinGetProcess for each handle you have to get the pids Compare the pids with the one you are looking for.2 points
-
Just this part made me understand the correct way of declaring everything.1 point
-
Correct [in the global scope]. Local applies to the scope in which the declaration is made. If declared outside a function, then the variable is created in the global scope which is the (current local) scope as seen by the interpreter. Edit: Think of local as being in the same neighborhood.1 point
-
Here's @iAmNewbe's script modified to eliminate most of the global variables completely. I could probably get rid of a lot of the other code in here that is not necessary as well, but I don't really have the time. This should be used as nothing more than a learning experience, and not a critique because your code works, it can just work a lot better. You might also notice that I cleaned up some of the code to eliminate unnecessary variables as well as redundant code in the readstring function. HotKeySet("{F2}", "_ReadString") HotKeySet("{F3}", "_Exit") ;~ Global $Ticket , $MotClef1 , $MotClef2 , $MotClef3 , $MotClef4 , $MotClef5 ;~ Global $MotPresent1 = 0 , $MotPresent2 = 0 , $MotPresent3 = 0 , $MotPresent4 = 0 , $MotPresent5 = 0 ;~ Global $SuccessText = "", Global $MyToolTip = 0, $MyTimer = 0, $SuccessText2 = "" While 1 Sleep(100) If $MyToolTip = 0 Then Else $MyTimer += 100 If $MyTimer > 5000 Then $MyTimer = 0 ToolTip("") $SuccessText2 = "" EndIf EndIf WEnd ; Test Field: ; The word Bouteilles is here ; But the word Tourtle is not here. Func _ReadString() ;Lit le texte compare les chaines de charactères puis agis $Ticket = _ClipGetClip() $SuccessText = "Check 1 " If _CheckTest($Ticket, "Bouteilles") Then $SuccessText &= "OK" & @CRLF & @CRLF Else $SuccessText &= "NON OK" & @CRLF & @CRLF EndIf _Tooltip($SuccessText) ConsoleWrite($SuccessText) $SuccessText = "Check 2 " If _CheckTest2($Ticket, "Bouteilles", "Bertt", "word", "test") Then $SuccessText &= "OK" & @CRLF & @CRLF Else $SuccessText &= "NON OK" & @CRLF & @CRLF EndIf _Tooltip($SuccessText) ConsoleWrite($SuccessText) EndFunc ;==>_ReadString Func _CheckTest($sTicket_in, $MotClef1 = "0", $MotClef2 = "0", $MotClef3 = "0", $MotClef4 = "0", $MotClef5 = "0") ;Test d'une fonction de comparaison de chaine de charactères avec un mot. If $MotClef1 = "0" Then Else $MotClef1 = _StringInString($sTicket_in, $MotClef1) EndIf If $MotClef2 = "0" Then Else $MotClef2 = _StringInString($sTicket_in, $MotClef2) EndIf If $MotClef3 = "0" Then Else $MotClef3 = _StringInString($sTicket_in, $MotClef3) EndIf If $MotClef4 = "0" Then Else $MotClef4 = _StringInString($sTicket_in, $MotClef4) EndIf If $MotClef5 = "0" Then Else $MotClef5 = _StringInString($sTicket_in, $MotClef5) EndIf ;MsgBox(0,"_CheckTest2", $MotClef1 &" || "&$MotClef2&" || "&$MotClef3&" || "&$MotClef4&" || "&$MotClef5);DEBUG If $MotClef1 = "" Then Return 0 ElseIf $MotClef2 = "" Then Return 0 ElseIf $MotClef3 = "" Then Return 0 ElseIf $MotClef4 = "" Then Return 0 ElseIf $MotClef5 = "" Then Return 0 Else Return 1 EndIf ;~ $MotPresent1 = 0 ;~ $MotPresent2 = 0 ;~ $MotPresent3 = 0 ;~ $MotPresent4 = 0 ;~ $MotPresent5 = 0 ;~ $MotClef1 = 0 ;~ $MotClef2 = 0 ;~ $MotClef3 = 0 ;~ $MotClef4 = 0 ;~ $MotClef5 = 0 EndFunc ;==>_CheckTest Func _CheckTest2($sTicket_in, $MotClef1 = "0", $MotClef2 = "0", $MotClef3 = "0", $MotClef4 = "0", $MotClef5 = "0") ;Test d'une fonction de comparaison de chaine de charactères avec plusieurs mots. If $MotClef1 = "0" Then Else $MotClef1 = _StringInString($sTicket_in, $MotClef1) EndIf If $MotClef2 = "0" Then Else $MotClef2 = _StringInString($sTicket_in, $MotClef2) EndIf If $MotClef3 = "0" Then Else $MotClef3 = _StringInString($sTicket_in, $MotClef3) EndIf If $MotClef4 = "0" Then Else $MotClef4 = _StringInString($sTicket_in, $MotClef4) EndIf If $MotClef5 = "0" Then Else $MotClef5 = _StringInString($sTicket_in, $MotClef5) EndIf ;MsgBox(0,"_CheckTest2", $MotClef1 &" || "&$MotClef2&" || "&$MotClef3&" || "&$MotClef4&" || "&$MotClef5);DEBUG If $MotClef1 = "" Then Return 0 ElseIf $MotClef2 = "" Then Return 0 ElseIf $MotClef3 = "" Then Return 0 ElseIf $MotClef4 = "" Then Return 0 ElseIf $MotClef5 = "" Then Return 0 Else Return 1 EndIf ;~ $MotPresent1 = 0 ;~ $MotPresent2 = 0 ;~ $MotPresent3 = 0 ;~ $MotPresent4 = 0 ;~ $MotPresent5 = 0 ;~ $MotClef1 = 0 ;~ $MotClef2 = 0 ;~ $MotClef3 = 0 ;~ $MotClef4 = 0 ;~ $MotClef5 = 0 EndFunc ;==>_CheckTest2 Func _StringInString($sTicketIn, $sMotClefIn) ;Comparaison de la chaine au ticket $StringChecking = StringInStr($sTicketIn, $sMotClefIn) $MotDeLaFin = $sMotClefIn If $StringChecking > 1 Then $sMotClefIn = 1 ;Est la $SuccessText2 = $SuccessText2 & $MotDeLaFin & " est detecté!" & @CRLF Else $sMotClefIn = "" ;N'est pas $SuccessText2 = $SuccessText2 & $MotDeLaFin & " n'est pas detecté!" & @CRLF EndIf Return $sMotClefIn EndFunc ;==>_StringInString Func _Tooltip($SuccessText) $MyToolTip = 1 $SuccessText2 &= $SuccessText Global $MyToolTip = ToolTip($SuccessText2, 0, 0, "Checks results") EndFunc ;==>_Tooltip Func _ClipGetClip() ;On integre la selection dans la mémoire $OldClip = ClipGet() ;ClipGetp précédent Send("^c") $NewClip = ClipGet() ;Integration selection ClipPut($OldClip) ;Restauration clip précédent Return $NewClip EndFunc ;==>_ClipGetClip Func _Exit() MsgBox(0, "Arret...", "Extinction...") Exit ;Quitter EndFunc ;==>_Exit1 point
-
I fully understand the purpose of this project and am just curious how far it will get to be able to compile AutoIt3 code without any adaption and all the safeguards build in like is done in AutoIt3. Not trivial, but as stated, a nice challenge.1 point
-
@ghost911, You started a nice little project which is growing rapidly I see. When AutoIt3 started it was around the 80 Kb if I remember well and it started to grow as many internal function were added. You will find that there are several commands that aren't really simply to implement but just see that as a challenge. Just a few comments I would like to make: skip adding the compiled autoit3 exe to your 7z as people around here can compile the au3 file themselfs Also no need to include UPX.exe as that is also already available to everybody here, so you keep your repository nice and small. I see you are using the word Fonction all over the place but it is really spelled Function. Curious about how this is going to turn out when it gets more functions available. Jos1 point
-
Logic help
FrancescoDiMuro reacted to BrewManNH for a topic
Your code isn't good, you're making the exact same mistake as caramen, you're using Global variables in a function call that references the global variables you created in the first place. Unless the variables inside the function aren't supposed to be trying to redefine the contents of your Global variables, then you should use different names for them in the functions. That code is a nightmare when trying to figure out if you're working with the global variables or the local variables, and most of them are totally unnecessary if you're just using local variables and passing them back and forth in the function calls.1 point -
Simply put.. #include <WinAPIEx.au3> MsgBox(0, "Windowed ?", _isWindowed("SciTE.exe")) Func _isWindowed($sTitle) Local $iPid = ProcessExists($sTitle) If Not $iPid Then Return False Local $bRet = Not _WinAPI_EnumProcessWindows($iPid) Return ($bRet ? $bRet : False) EndFunc Deye1 point
-
The function can be even smaller Func _CheckTest($stringToCheck, $exclusionString) If StringInStr($stringToCheck, $exclusionString, 0) Then Return True Return False EndFunc1 point
-
Here is an altered version that is more what you want without using arrays Func _CheckTest($stringToCheck, $exclusionString) $result = StringInStr($stringToCheck, $exclusionString, 0) If($result <> "") Then return True ; The $exclusionString is in $stringToCheck Else Return False ; A Okay, $exclusionString not in $stringtoCheck EndIf EndFunc Function used #include <String.au3> Local $string = "The girl rode her bicycle carrying bouteilles of fermented grape juice for her dinosaur" If _CheckTest($string, "Bouteilles") Then MsgBox(0,"",'"Bouteilles" exists in string' & @CRLF) If _CheckTest($string, "Boutt") Then MsgBox(0,"",'"Boutt" exists in string' & @CRLF) If _CheckTest($string, "Apple") Then MsgBox(0,"",'"Apple" exists in string' & @CRLF) If _CheckTest($string, "Dino") Then MsgBox(0,"",'"Dino" exists in string' & @CRLF) If _CheckTest($string, "Girl") Then MsgBox(0,"",'"Girl" exists in string' & @CRLF) If _CheckTest($string, "Bicycle") Then MsgBox(0,"",'"Bicycle" exists in string' & @CRLF) If _CheckTest($string, "Gaff") Then MsgBox(0,"",'"Gaff" exists in string' & @CRLF) Func _CheckTest($stringToCheck, $exclusionString) $result = StringInStr($stringToCheck, $exclusionString, 0) If($result <> "") Then return True ; The $exclusionString is in $stringToCheck Else Return False ; A Okay, $exclusionString not in $stringtoCheck EndIf EndFunc1 point
-
He's not passing the global variables into the functions, he's creating new local variables inside the function, they just confusingly have the same name. Once that function ends, anything inside those variables will disappear, and any other function that tries to access them will get the contents of the global variables, unless he creates new local variables in other functions the same way. This is a great example of how not to use Global variables, and the confusion that can arise when you reuse the Global variable's name in a Local variable inside a function.1 point
-
I agree the question is ill-posed. If the question is to determine which language fulfills the broadest "general" needs and hence is the most "useful" (in a sense), then there is a single and easy answer: Ada. That's because Ada is the result of the largest research by the most brilliant minds and worldwide competition to satisfy this precise requirement. It's recent revision, Ada2012, is extremely safe, robust and powerful. Yet its use is surprisingly rare in IT (go figure, see below). As others have already pointed out, AutoIt is a surprisingly capable language for a very significant number of use cases and if it suits your needs, why not keep enjoying its simplicity of implementation. As an aside, I've worked for Ada's author team (led by Jean Ichbiah) and I can tell you that producing Ada compilers isn't a light and easy task! I've also worked later with the B formal method (team led by Jean-Raymond Abrial), which may deliver Ada* or C* code along with a formal proof of correctness. (The star denotes the limitation to the safe and provable part of the language.) So we have methods and tools to produce software formally (= mathematically) proven 100% correct with respect of formal specifications, still we see in practice that these tools and languages are only used in niches where dependability is an absolute concern, else they're not used at all in general software development. The contrapositive of this is "if your context doesn't impose to you extremely strong requirements, safety and robustness proofs, then use inferior methods and languages". No wonder why a huge number of software pieces are riddled with bugs and need daily, weekly, monthly, yearly so-called "updates"...1 point
-
IE.au3 - Reading css properties
seadoggie01 reacted to MichaelHB for a topic
Try this: ConsoleWrite(@CRLF & '$my_div.currentStyle.backgroundImage - ' & $my_div.currentStyle.backgroundImage)1 point