
niubbone
Active Members-
Posts
101 -
Joined
-
Last visited
Everything posted by niubbone
-
No, You do send("{a down"}).To keep it pressed, put a sleep(x) between send("{a down"}) and send("{a up"}) Example send("{a down"}) Sleep(2000) send("{a up"}) Keeps a pressed for 2 seconds and exits.
-
LOL! AWESOME! That is crazy
-
If you don't post the code we can't help you
-
Managing variables in and outside functions.
niubbone replied to niubbone's topic in AutoIt General Help and Support
Thanks, I'm still waiting the day I could adventure myself into such technical questions. -
Hi all. My problem is pretty simple. I have a starting date i decide. I have a function that everytime i press a button in a guy it adds up a day to the previous said date with _DateAdd. This should simulate a monthly work routine, so, every 30 days, salary adds up day by day and the full salary is paid every 30 days. Something like this 2010/06/30 Day 1; Starting date, Salary is 0$ Click on the button--> A day passes, salary +50$ 2010/07/01 Day 2; Salary is 5$ Click on the button--> A day passes, salary +50$ 2010/07/02 Day 3; Salary is 10$ Click on the button--> A day passes, salary +50$ 2010/07/01 Day 4; Salary is 10$ ...... Click on the button--> A day passes, salary +50$ 2010/07/30 Day 30; Salary is 1500$ My question is: How i manage a function like this? Global $StartingDate="2010/30/06" Global $SalaryDate="2010/30/06" Global $Daycount=1 Func DateAdd($Date) Local $NewDate = $Date $NewDate = _DateAdd('d', 1, $NewDate) $StartingDate=$NewDate $DayCount+=1 Salary($StartingDate) Endfunc I was thinking something like this Func Salary($Day) Local $StartCountDate=$Day If $StartCountDate=$x=_DateAdd('d',30,$StartCountDate) Then ;PAY SALARY (i won't write this code as it's not the problem) $SalaryDate=StartingDate Endfunc This is the raw code i had in mind. Could it work or there are more smart ways of doing it?
-
List files in a folder in alphabetical order
niubbone replied to happy2help's topic in AutoIt General Help and Support
Hi I'm pretty new to autoit, so this is the first solution it comes in mind to me. Since the name format of your camera files is always something like blahblha222.JPG I think you should use a mix between StringMid and StringCompare (Check help file for infos). Also, if StringCompare is "clever enough" to recognise and analyse the file names itself it may be sufficient alone. I was thinking something like you StringCompare file names to get them in the order. -
somdcomputerguy Thanks but that's what i did. jhcd thanks, would have liked more code though. Melba23 Seems best solution. Thanks KaFu Thanks but way tooooo advanced for me. Works but I don't get anything there.
-
Hi. Looking into the forum for date format and date type didn't showed up any result. I'm sure there's something about in forum though. Anyways, I implemented a little internal calendar in a program based on _DateAdd Function. _DateAdd wants the date input in the YYYY/MM/DD format. I need to show up the date in the whole program in DD/MM/YYYY european format. Checking in the help file I managed to catch up some of the date handling related functions. But if there is a way to easily convert dates from a format to another remains a mistery to me. Global $BeginDate="2010/01/01" Func DayAfter($Date) Local $NewDate = $Date $NewDate = _DateAdd('d', 1, $NewDate) Global $BeginDate=$NewDate $DateFormatted=StringRight($NewDate,2) & '/' & StringMid($NewDate,6,2) & '/' & StringLeft($NewDate,4) Return $DateFormatted EndFunc This basically adds a day up everytime it's called and convert the date in the Euro Format I need. There is a fast way of doing it, like some autoit Opt settings or some function to convert it or would be better to create a new one?
-
Finding unknown strings in files
niubbone replied to niubbone's topic in AutoIt General Help and Support
Thanks. On my way to learning. -
Hi community, I'm almost sure you can do this, and i think it may be a bit hard, so it's just an idea more than a real project. I was wondering if it's possible to open any kind of file in txt format (also by renaming them .txt) and check into them full lenght deep for the largest recursive string. The main idea behind this is: 1)Do some exercise with strings. 2)While doing point 1, creating a very rough compression algorithm to compress files. So the idea behind this is this: For example i have a txt file like this: abcdedf34rf4rg45gt4kkkefglo6ssas-èàpoªבᇖ㱠݊abcderhukty45tttttttr4tttrtrr4fqqf657kkksdfgvrtg56h67i8ok,poòèàè+ùuylktttttttr4tttfvtyh87i795tr653 And so on. I colored some recursive strings you can find in the file. The idea is to open any file, scan the given file for the largest recursive string, then convert it to a shorter one and substitute it to the original one. Example: tttttttr4ttt would become a random charachters set(maybe done with Chr(Random(1,500,1) or just decided by me) like 12XY. So all the tttttttr4ttt would be replaced with 12XY and the file would be smaller. Decompressing would be the opposite. All the corrispondences (12XY would be stored in the file or in a ini file and deleted after decompressing is done. Is this possible/worth a try?
-
Checking result of a test with radios
niubbone replied to niubbone's topic in AutoIt General Help and Support
Again, a big thanks to all of you. -
Checking result of a test with radios
niubbone replied to niubbone's topic in AutoIt General Help and Support
Thanks to all for the HUGE help. Thanks to Melba23 for explaining his code. Needed it. Thanks to Yoriz Which gave me 2 versions. The first allowed me to better understand Spiff59 "method of coding", The second fitted more my problem, and also if doesnt solve it, it gave me a great input to solve it myself. Thanks to Spiff59, as now I start getting (still have to work on it) the concept behind his code, and looks pretty good. Great work guys, When I solve it I'll post the code. One more question: How autoit assigns control IDs? I have always seen that radios control id never starts from 1 or so. Sometimes starts from 2 sometimes from 5 and so on. What is counted first? As you see in Melba23 Code: a1 - 3 a2 - 4 a3 - 5 a4 - 6 b1 - 7 b2 - 8 b3 - 9 b4 - 10 c1 - 11 The first radio starts with 3.... but before there aren't any gui elements.... #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Local $GUITestLavoro = GUICreate("Test Colloquio Lavorativo", 468, 643, 402, 7) GUICtrlCreateLabel("TEST DI IDONEITA' AL POSTO DI LAVORO", 48, 16, 377, 28) GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif") GUICtrlCreateLabel("Mi raccomando, non faccia il coglione come al suo solito....", 104, 56, 282, 17) GUICtrlCreateLabel("1)", 8, 88, 17, 22) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUIStartGroup() Local $LabelRadioDom1 = GUICtrlCreateLabel("dom1", 32, 88, 30, 17) Local $Radio1 = GUICtrlCreateRadio("Radio1", 8, 112, 425, 17) Local $Radio2 = GUICtrlCreateRadio("Radio2", 8, 136, 425, 17) Local $Radio3 = GUICtrlCreateRadio("Radio3", 8, 160, 425, 17) Local $Radio4 = GUICtrlCreateRadio("Radio4", 8, 184, 425, 17) GUICtrlCreateLabel("2)", 12, 211, 17, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUIStartGroup() Local $LabelRadioDom2 = GUICtrlCreateLabel("dom2", 36, 211, 30, 17) Local $Radio5 = GUICtrlCreateRadio("Radio1b", 12, 235, 425, 17) Local $Radio6 = GUICtrlCreateRadio("Radio2b", 12, 259, 425, 17) Local $Radio7 = GUICtrlCreateRadio("Radio3b", 12, 283, 425, 17) Local $Radio8 = GUICtrlCreateRadio("Radio4b", 12, 307, 425, 17) GUICtrlCreateLabel("3)", 12, 340, 17, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUIStartGroup() Local $LabelRadioDom3 = GUICtrlCreateLabel("dom3", 36, 340, 30, 17) Local $Radio9 = GUICtrlCreateRadio("Radio1c", 12, 364, 425, 17) Local $Radio10 = GUICtrlCreateRadio("Radio2c", 12, 388, 425, 17) Local $Radio11 = GUICtrlCreateRadio("Radio3c", 12, 412, 425, 17) Local $Radio12 = GUICtrlCreateRadio("Radio4c", 12, 436, 425, 17) GUICtrlCreateLabel("4)", 12, 462, 17, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUIStartGroup() Local $LabelRadioDom4 = GUICtrlCreateLabel("dom4", 36, 462, 30, 17) Local $Radio13 = GUICtrlCreateRadio("Radio1d", 12, 486, 425, 17) Local $Radio14 = GUICtrlCreateRadio("Radio2d", 12, 510, 425, 17) Local $Radio15 = GUICtrlCreateRadio("Radio3d", 12, 534, 425, 17) Local $Radio16 = GUICtrlCreateRadio("Radio4d", 12, 558, 425, 17) Local $BottoneScappaTest = GUICtrlCreateButton("Scappa....", 8, 592, 177, 41, $WS_GROUP) Local $BottoneConsegnaTest = GUICtrlCreateButton("Consegna il test", 280, 592, 177, 41, $WS_GROUP) Local $CompilaTest = ColloquioDomande() GUICtrlSetData($LabelRadioDom1, $CompilaTest[0][0]) GUICtrlSetData($LabelRadioDom2, $CompilaTest[0][1]) GUICtrlSetData($LabelRadioDom3, $CompilaTest[0][2]) GUICtrlSetData($LabelRadioDom4, $CompilaTest[0][3]) GUICtrlSetData($Radio1, $CompilaTest[1][0]) GUICtrlSetData($Radio2, $CompilaTest[1][1]) GUICtrlSetData($Radio3, $CompilaTest[1][2]) GUICtrlSetData($Radio4, $CompilaTest[1][3]) GUICtrlSetData($Radio5, $CompilaTest[1][4]) GUICtrlSetData($Radio6, $CompilaTest[1][5]) GUICtrlSetData($Radio7, $CompilaTest[1][6]) GUICtrlSetData($Radio8, $CompilaTest[1][7]) GUICtrlSetData($Radio9, $CompilaTest[1][8]) GUICtrlSetData($Radio10, $CompilaTest[1][9]) GUICtrlSetData($Radio11, $CompilaTest[1][10]) GUICtrlSetData($Radio12, $CompilaTest[1][11]) GUICtrlSetData($Radio13, $CompilaTest[1][12]) GUICtrlSetData($Radio14, $CompilaTest[1][13]) GUICtrlSetData($Radio15, $CompilaTest[1][14]) GUICtrlSetData($Radio16, $CompilaTest[1][15]) GUISetState(@SW_SHOW) For $i=$Radio1 To $Radio16 MsgBox(0,"i",$i) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $BottoneScappaTest ExitLoop EndSwitch WEnd Func ColloquioDomande() Local $DomandaA[5] = ["domA", "a1", "a2", "a3", "a4"], $DomandaB[5] = ["domB", "b1", "b2", "b3", "b4"], $DomandaC[5] = ["domC", "c1", "c2", "c3", "c4"] _ , $DomandaD[5] = ["domD", "d1", "d2", "d3", "d4"], $DomandaE[5] = ["domE", "e1", "e2", "e3", "e4"] Local $aArrays[5] = [$DomandaA, $DomandaB, $DomandaC, $DomandaD, $DomandaE] _ArrayShuffle($aArrays) Local $MultiDomERisp[2][16], $aTemp, $num = 0 For $iArrNo = 0 To 3 $aTemp = $aArrays[$iArrNo] _ArrayShuffle($aTemp, 1) $MultiDomERisp[0][$iArrNo] = $aTemp[0] For $x = 1 To UBound($aTemp) - 1 $MultiDomERisp[1][$num] = $aTemp[$x] $num += 1 Next Next Return $MultiDomERisp EndFunc ;==>ColloquioDomande ; http://www.autoitscript.com/forum/index.php?s=&showtopic=79564&view=findpost&p=573531 Func _ArrayShuffle(ByRef $aArray, $iBase = 0, $iUBound = Default) If Not IsArray($aArray) Then Return SetError(1, 0, 0) If UBound($aArray, 0) <> 1 Then Return SetError(2, 0, 0) Local $temp, $rand If $iUBound = Default Or $iUBound = 0 Then $iUBound = UBound($aArray) - 1 For $i = $iBase To $iUBound $temp = $aArray[$i] $rand = Random($iBase, $iUBound, 1) $aArray[$i] = $aArray[$rand] $aArray[$rand] = $temp Next EndFunc ;==>_ArrayShuffle Example, this code. They start from 7 and number is even greater than Radio controls. Don't get it... PS: Run it. I Included a msgbox that shows control ID from Radio1 to Radio16. -
SplashImageOn is what you are looking for. Look at it in help file.
-
Checking result of a test with radios
niubbone replied to niubbone's topic in AutoIt General Help and Support
Thanks for your time guys. Melba23 I used Advanced setting in my code ;P look at it xD Btw I don't fully understand your code. Case $hButton ; Check each group of radios in turn For $j = 0 To 3 ; Calculate ControlID of first radio in group $iStartControlID = $hRadio_a1 + (4 * $j);what this does? How you switch from a group to another? Don't get the idea behind this ; Check each radio in the group For $i = $iStartControlID To $iStartControlID + 3 ; If the radio is checked If GUICtrlRead($i) = 1 Then ; Check if the text for this radio matches the answer If GUICtrlRead($i, 1) = $aCorrect[$j] Then ; I don't get the point behind this $iStartControlID = $hRadio_a1 + (4 * $j) If i got it right this is what you are doing. Initialize a $j counter from 0 to 3, With $iStartControlID You initialize a counter which as you say calculates the controlIDs but I don't get how it does it, The following For statement make the IDs add 4 each time to control them with the if statements like this Id=5 then 6,7,8 and so on till 16; Then If Radio with control ID $i is 1 (CHECKED) then control it; Here another point I have a doubt on. If GUICtrlRead($i, 1) = $aCorrect[$j] Then Here, the code would work only if the question for the test are only the same 4 everytime right? but this test is going to be repeated many times and I am planning to make question picked randomly from an array of over 50 questions. So there will be not only question A with replies A1 A2 A3 A4, B with B1 B2 B3 B4, but there will be also many more possibilities, like R with R1 R2 R3 R4, and so on because there will be much questions. Am i right? There is a way to make it work with multiple randomly picked questions? Spiff59 I don't even know where to start... way too much complicated for me... Sorry but I think it would take me a month to understand it.... Thanks anyway.... Any further explanation would be appreciated -
Also, would like to add a tip for anyone reading this. Before asking in the forum, use everytime (I did and saved me many times instead of coming here asking) the help file Index section typing for any keyword that can lead to the function you are looking for. If you still don't find it, put some function related symbol in front of it. Example: In your case you had to find your ip address. First keywords I would search for in help file would be IP, IPAddress, Find, FindIP. These result wouldn't bring me to what I was looking for. So I would start to adding function symbols in front of it, like (respectively @, _ , # in order of common sense to me) and so on. So put it like this @IP and tadahhhh you found it! You can do this process everytime and after this, if you still can't find anything then ask here. Sometimes happens that functions have odd or multiple shortened names in it and you can't find it by common sense keywords, but it's rare. Other thing is searching by Search. It looks up things by argument. Not as efficent as Index search but helpful sometimes.
-
Took me some days to figure out how checking multiple grouped radios works. Now i would like to check the result of multiple radios. This is what i made As you can see i will select 4 radios each time the test will pop up. Question is simple. I have to check every single radio for every group like this: If (GUICtrlRead($radio_1)=$GUI_CHECKED) Then If (GUICtrlRead($Radio1,1)="Right Answer Text") Then for every radio button, or there is a way to just check if the checked radio is containing the right text? Ex: If Current Checked Radio Box = Right answer text then etc etc Thanks in advance.
-
Well, Yoriz, I looked at the topic an hour ago and I think I'm slowly grasping the concept. Many thanks. Anyway, I want to share my personal opinion with you. Autoit is the 1st programming language i learn. (Started about 1 month and half ago) Till now I've seen that the biggest problem I get when coding something is how autoit manages variable types. For example string and numbers are problematic to get to work togheter and so on. But this thing of radio buttons, I must say, is the most twisted, complicated and odd way to manage such a simple thing. Maybe It's just because I still didn't grasped the concept properly (going to practice right now, as I asked because in need), but I doubt that later on my opinion will change. Very awkward to me. Anyway really many thanks for the explanation, has been incredibly helpful, considering also that the help file about this subject, it's very poorly detailed. Whenever you like, i would like to see other ways of managing multiple radios, also link to other posts would be appreciated.
-
Surely the most helpful. Many thanks man. Awesome. By the way I still have to figure out how this works. #Include <Array.au3> Dim $Data[10] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] _ArrayDisplay($Data) For $i = 1 To 100 $A = Random(0, UBound($Data) - 1, 1) $B = Random(0, UBound($Data) - 1, 1) $Temp = $Data[$A] $Data[$A] = $Data[$B] $Data[$B] = $Temp Next _ArrayDisplay($Data) Seems simple but I don't get how it works...
-
Well, why I would like to make a random generator myself? Because the one give doesn't allow a simple task: to take a set of random numbers not picking the same numbers. It's 3 weeks I am trying to get out of this code and I am became so mad that i thought to make a random number generator myself (I know it doesn't do what i said, but first i was going to make it work, then the rest). #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> Local $GUITestLavoro = GUICreate("Test Colloquio Lavorativo", 468, 643, 402, 7) GUICtrlCreateLabel("TEST DI IDONEITA' AL POSTO DI LAVORO", 48, 16, 377, 28) GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif") GUICtrlCreateLabel("Mi raccomando, non faccia il coglione come al suo solito....", 104, 56, 282, 17) GUICtrlCreateLabel("1)", 8, 88, 17, 22) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUIStartGroup() Local $LabelRadioDom1 = GUICtrlCreateLabel("dom1", 32, 88, 30, 17) Local $Radio1 = GUICtrlCreateRadio("Radio1", 8, 112, 425, 17) Local $Radio2 = GUICtrlCreateRadio("Radio2", 8, 136, 425, 17) Local $Radio3 = GUICtrlCreateRadio("Radio3", 8, 160, 425, 17) Local $Radio4 = GUICtrlCreateRadio("Radio4", 8, 184, 425, 17) GUICtrlCreateLabel("2)", 12, 211, 17, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUIStartGroup() Local $LabelRadioDom2 = GUICtrlCreateLabel("dom2", 36, 211, 30, 17) Local $Radio5 = GUICtrlCreateRadio("Radio1b", 12, 235, 425, 17) Local $Radio6 = GUICtrlCreateRadio("Radio2b", 12, 259, 425, 17) Local $Radio7 = GUICtrlCreateRadio("Radio3b", 12, 283, 425, 17) Local $Radio8 = GUICtrlCreateRadio("Radio4b", 12, 307, 425, 17) GUICtrlCreateLabel("3)", 12, 340, 17, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUIStartGroup() Local $LabelRadioDom3 = GUICtrlCreateLabel("dom3", 36, 340, 30, 17) Local $Radio9 = GUICtrlCreateRadio("Radio1c", 12, 364, 425, 17) Local $Radio10 = GUICtrlCreateRadio("Radio2c", 12, 388, 425, 17) Local $Radio11 = GUICtrlCreateRadio("Radio3c", 12, 412, 425, 17) Local $Radio12 = GUICtrlCreateRadio("Radio4c", 12, 436, 425, 17) GUICtrlCreateLabel("4)", 12, 462, 17, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUIStartGroup() Local $LabelRadioDom4 = GUICtrlCreateLabel("dom4", 36, 462, 30, 17) Local $Radio13 = GUICtrlCreateRadio("Radio1d", 12, 486, 425, 17) Local $Radio14 = GUICtrlCreateRadio("Radio2d", 12, 510, 425, 17) Local $Radio15 = GUICtrlCreateRadio("Radio3d", 12, 534, 425, 17) Local $Radio16 = GUICtrlCreateRadio("Radio4d", 12, 558, 425, 17) Local $BottoneScappaTest = GUICtrlCreateButton("Scappa....", 8, 592, 177, 41, $WS_GROUP) Local $BottoneConsegnaTest = GUICtrlCreateButton("Consegna il test", 280, 592, 177, 41, $WS_GROUP) Local $CompilaTest=ColloquioDomande() GUICtrlSetData($LabelRadioDom1,$CompilaTest[0][0]) GUICtrlSetData($LabelRadioDom2,$CompilaTest[0][1]) GUICtrlSetData($LabelRadioDom3,$CompilaTest[0][2]) GUICtrlSetData($LabelRadioDom4,$CompilaTest[0][3]) GUICtrlSetData($Radio1,$CompilaTest[1][0]) GUICtrlSetData($Radio2,$CompilaTest[1][1]) GUICtrlSetData($Radio3,$CompilaTest[1][2]) GUICtrlSetData($Radio4,$CompilaTest[1][3]) GUICtrlSetData($Radio5,$CompilaTest[1][4]) GUICtrlSetData($Radio6,$CompilaTest[1][5]) GUICtrlSetData($Radio7,$CompilaTest[1][6]) GUICtrlSetData($Radio8,$CompilaTest[1][7]) GUICtrlSetData($Radio9,$CompilaTest[1][8]) GUICtrlSetData($Radio10,$CompilaTest[1][9]) GUICtrlSetData($Radio11,$CompilaTest[1][10]) GUICtrlSetData($Radio12,$CompilaTest[1][11]) GUICtrlSetData($Radio13,$CompilaTest[1][12]) GUICtrlSetData($Radio14,$CompilaTest[1][13]) GUICtrlSetData($Radio15,$CompilaTest[1][14]) GUICtrlSetData($Radio16,$CompilaTest[1][15]) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $BottoneScappaTest Exitloop EndSwitch WEnd Func ColloquioDomande() Local $DomandaA[5]=["domA","a1","a2","a3","a4"],$DomandaB[5]=["domB","b1","b2","b3","b4"],$DomandaC[5]=["domC","c1","c2","c3","c4"] _ ,$DomandaD[5]=["domD","d1","d2","d3","d4"],$DomandaE[5]=["domE","e1","e2","e3","e4"] Local $DomandeDifferenti[4] Local $RisposteMischiate[16] Local $i=1 Local $r=4 For $z=1 To 4 Local $numeridom[5]=[1,2,3,4,5] Local $GiroDomande=$numeridom[Random(0,UBound($numeridom)-1,1)] MsgBox(0,"e",$GiroDomande) _ArrayDelete($numeridom,$GiroDomande-1) Select Case $GiroDomande=1 $DomandeDifferenti[$z-1]=$DomandaA[0] If $DomandaA[0]="DomA" Then _ArrayDelete($DomandaA,0) else ContinueCase EndIf Local $RisposteInOrdine[4]=[$DomandaA[0],$DomandaA[1],$DomandaA[2],$DomandaA[3]] Case $GiroDomande=2 $DomandeDifferenti[$z-1]=$DomandaB[0] If $DomandaB[0]="DomB" Then _ArrayDelete($DomandaB,0) else ContinueCase EndIf Local $RisposteInOrdine[4]=[$DomandaB[0],$DomandaB[1],$DomandaB[2],$DomandaB[3]] Case $GiroDomande=3 $DomandeDifferenti[$z-1]=$DomandaC[0] If $DomandaC[0]="DomC" Then _ArrayDelete($DomandaC,0) else ContinueCase EndIf Local $RisposteInOrdine[4]=[$DomandaC[0],$DomandaC[1],$DomandaC[2],$DomandaC[3]] Case $GiroDomande=4 $DomandeDifferenti[$z-1]=$DomandaD[0] If $DomandaD[0]="DomD" Then _ArrayDelete($DomandaD,0) else ContinueCase EndIf Local $RisposteInOrdine[4]=[$DomandaD[0],$DomandaD[1],$DomandaD[2],$DomandaD[3]] Case $GiroDomande=5 $DomandeDifferenti[$z-1]=$DomandaE[0] If $DomandaE[0]="DomE" Then _ArrayDelete($DomandaE,0) else ContinueCase Endif Local $RisposteInOrdine[4]=[$DomandaE[0],$DomandaE[1],$DomandaE[2],$DomandaE[3]] Case $GiroDomande $DomandeDifferenti[$z-1]="DomRiserva" Local $RisposteInOrdine[4] $RisposteInOrdine[0]="RisA" $RisposteInOrdine[1]="RisB" $RisposteInOrdine[2]="RisC" $RisposteInOrdine[3]="RisD" EndSelect For $k=$i To $r Local $numeririsp[4]=[0,1,2,3] Local $CopiaRispOrdine=$RisposteInOrdine Local $GiroRispInOrdine=$numeririsp[Random(0,Ubound($numeririsp)-1,1)] MsgBox(0,"w",$GiroRispInOrdine) _ArrayDelete($numeririsp,$GiroRispInOrdine) $RisposteMischiate[$k-1]=$CopiaRispOrdine[$GiroRispInOrdine] _ArrayDelete($CopiaRispOrdine,$GiroRispInOrdine) Next $i+=4 $r+=4 Next Local $MultiDomERisp[2][16]=[[$DomandeDifferenti[0],$DomandeDifferenti[1],$DomandeDifferenti[2],$DomandeDifferenti[3]], _ [$RisposteMischiate[0],$RisposteMischiate[1],$RisposteMischiate[2],$RisposteMischiate[3],$RisposteMischiate[4], _ $RisposteMischiate[5],$RisposteMischiate[6],$RisposteMischiate[7],$RisposteMischiate[8],$RisposteMischiate[9], _ $RisposteMischiate[10],$RisposteMischiate[11],$RisposteMischiate[12],$RisposteMischiate[13],$RisposteMischiate[14], _ $RisposteMischiate[15]]] Return $MultiDomERisp EndFunc I have simply to fill that damn test with 4 random questions and to be sure that the replies are taken from the correspoding set of replies and randomized every time. It's 3 week I am trying and can't get out with a satisfying result. I've changed countless times the code and can't arrive at a solution. To make a different set of random numbers i tried to pick numbers from an array of numbers, then deleting it, but it seems useless. Now, can you find a solution to this? because i wasn't able to, and i asked to friends, in this forum, and in other forums, and noone seemed to be able to. PS: To immediately get the grip of the problem, try to run it a few times (and if needed to remove the message boxes) and check the result a few times.
-
hi all.. Honestly i'm getting tired of this, every project i make, there is always some kind of problem... now, i made a customized random number generator. Someone has an explanation why this get stuck infinitely? $R2=Randomize(10100,113210) MsgBox(0,"Random",$R2) Func Randomize($Val1,$Val2) $RandF1=@MSEC $RandF2=@MSEC*(@MIN/$RandF1/10) $RandF3=@YDAY/@Min*($RandF1/10) $Numero=$RandF1*$RandF1/@MSEC While 1 If $Numero<$Val1 Then Do $Numero=$Numero*$RandF2 Until $Numero>=$Val1 ElseIf $Numero>$Val2 Then Do $Numero=$Numero/$RandF3 Until $Numero<=$Val2 Else ExitLoop EndIf WEnd EndFunc
-
Can someone explain what this does?
niubbone replied to Jason786's topic in AutoIt General Help and Support
Since i'm pretty new to it i can perfectly understand what you are asking. Global $Active = 0 While 1 If $Active = 1 Then As said, $active will stay 0 forever. Now I'll explain your piece of code line by line very clearly. Global $Active = 0 We state that the Global variable $Active is 0. While 1 We set an infinite loop. This will keep running infinitely the code below, since there isn't a condition that makes it exit. That is because 1 its like True boolean operator, so it's like While True. If $Active = 1 Then This is where you got stuck. We just check continuosly IF THE VARIABLE $Active IS EQUAL TO 1, we DON'T STATE that is equal to 1. That $Active is a condition of the If statement. To make a more humanlike example: You want to exit from house, but door it's locked with a key. Global $Active = Door it's locked While 1; I keep continuosly pulling the handle to see if door is open If $Active = Door isn't locked anymore Then; the door it's open and i can go out. Exit and go out with friends As you can see, the door won't magically unlock by itself. It needs you to pick the key and open it. So if you put it like this Global $Active = 0 Door it's locked $Active = 1; I pick the key and open the door While 1; Keeping pulling the handle to see if door is open If $Active = 1 Then If door it's open Exit and go out with friends That's it. Sounds ridiculous, i know, but i think it gave the idea -
About the pixel searching: PixelSearch: Search a rectangle of the screen, specified by you, for a certain color. Returns @error=1 if not found, @error=0 if color is found. Color must be expressed in Hexadecimals. Look in help file for further infos. PixelGetColor: Get the color of the pixel specified by the user. Look help file. PixelChecksum may be of help, just look help file.
-
Test Generator. Problem making random questions.
niubbone replied to niubbone's topic in AutoIt General Help and Support
EDIT: Found solution for the before problem, which is making a case like this: Case $GiroDomande=1 $DomandeDifferenti[$z-1]=$DomandaA[0] If $DomandaA[0]="DomA" Then _ArrayDelete($DomandaA,0) EndIf Local $RisposteInOrdine[4]=[$DomandaA[0],$DomandaA[1],$DomandaA[2],$DomandaA[3]]So it won't run more than once. Now the form shows everytime withouth errors. Though, question are still badly randomized like in the picture below. ------------------- Thanks very much bo8ster! At least now I have a clue of what it is... Been for long time correcting and modifying the code ending with same result. So, from what you discovered I guess i have to rewrite this. Though I'm new, I always liked to make the code the most smart I can get, which from my point of view so if is putting up the most useful function/code in the smallest number of lines of code. So I like to spend more time becoming crazy on a function like this (which is now a bit advanced for me) than making a simpler but longer code. Another note: maybe this depend by the wrong gestion of the code by autoit, or it's just me, don't know, but when the code luckily (yeah, sometimes it's just fine and doesn't finds missing elements arrays) the result is screwed anyways: As you see correspondances are always violated. Before getting to the problem I am now, these were my easier solutions: 1)Separating the choiche of questions and answer in 2 different functions, so the first choses a question, the second choses 4 answers related to the Return value of the first, and a third functions runs the whole process of the 2 functions 4 times. Something like this Func Compiletest() for $i=1 to 4 ChooseQuestion() ChooseAnswer() Next Return $Result[4] EndFunc Func ChooseQuestion() Randomly Choose 1 question Return $question EndFunc Func ChooseAnswer() Randomly mixes 4 answers based on the output of ChooseQuestion() EndFunc and then compile the test screen. 2) Easiest solution. Divide the test in 4 pages, every page with a question. This would simplify also the multiple radio button problem, since I don't know how to handle all those radio buttons and I didn't find much help in the forum about it. So the test would be 4 pages, you reply one question and click next and so on. Since this seems a limit of autoit, I can't think of other solutions... -
Test Generator. Problem making random questions.
niubbone replied to niubbone's topic in AutoIt General Help and Support
Thanks again for the replies. As you can see I'm trying hard and still didn't came up with nothing. It's lot of time I am trying this.... The output in the GUI should be like this: 1)DomA a1 a3 a2 a4 2)DomE e2 e1 e4 e3 3)DomB b3 b1 b4 b2 And so on. Everytime Different but whichever question it's chosen it should respect a link with his replies (DomA with a1-a4 replies, DomB with b1-b4 and so on) I tried hard for over a month but can't solve this... Anyone of you see where the problem is? Keep giving this error: (107) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: Local $RisposteInOrdine[4]=[$DomandaE[0],$DomandaE[1],$DomandaE[2],$DomandaE[3]] Local $RisposteInOrdine[4]=[$DomandaE[0],$DomandaE[1],$DomandaE[2],^ ERROR but not in the same line, everytime is different (some times $DomandaE[2],^ ERROR, others $DomandaB[2],^ ERROR, depending on the random case...) Many thanks... and sorry for bothering #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> Local $GUITestLavoro = GUICreate("Test Colloquio Lavorativo", 468, 643, 402, 7) GUICtrlCreateLabel("TEST DI IDONEITA' AL POSTO DI LAVORO", 48, 16, 377, 28) GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif") GUICtrlCreateLabel("Worktest", 104, 56, 282, 17) GUICtrlCreateLabel("1)", 8, 88, 17, 22) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUIStartGroup() Local $LabelRadioDom1 = GUICtrlCreateLabel("dom1", 32, 88, 30, 17) Local $Radio1 = GUICtrlCreateRadio("Radio1", 8, 112, 425, 17) Local $Radio2 = GUICtrlCreateRadio("Radio2", 8, 136, 425, 17) Local $Radio3 = GUICtrlCreateRadio("Radio3", 8, 160, 425, 17) Local $Radio4 = GUICtrlCreateRadio("Radio4", 8, 184, 425, 17) GUICtrlCreateLabel("2)", 12, 211, 17, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUIStartGroup() Local $LabelRadioDom2 = GUICtrlCreateLabel("dom2", 36, 211, 30, 17) Local $Radio5 = GUICtrlCreateRadio("Radio1b", 12, 235, 425, 17) Local $Radio6 = GUICtrlCreateRadio("Radio2b", 12, 259, 425, 17) Local $Radio7 = GUICtrlCreateRadio("Radio3b", 12, 283, 425, 17) Local $Radio8 = GUICtrlCreateRadio("Radio4b", 12, 307, 425, 17) GUICtrlCreateLabel("3)", 12, 340, 17, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUIStartGroup() Local $LabelRadioDom3 = GUICtrlCreateLabel("dom3", 36, 340, 30, 17) Local $Radio9 = GUICtrlCreateRadio("Radio1c", 12, 364, 425, 17) Local $Radio10 = GUICtrlCreateRadio("Radio2c", 12, 388, 425, 17) Local $Radio11 = GUICtrlCreateRadio("Radio3c", 12, 412, 425, 17) Local $Radio12 = GUICtrlCreateRadio("Radio4c", 12, 436, 425, 17) GUICtrlCreateLabel("4)", 12, 462, 17, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUIStartGroup() Local $LabelRadioDom4 = GUICtrlCreateLabel("dom4", 36, 462, 30, 17) Local $Radio13 = GUICtrlCreateRadio("Radio1d", 12, 486, 425, 17) Local $Radio14 = GUICtrlCreateRadio("Radio2d", 12, 510, 425, 17) Local $Radio15 = GUICtrlCreateRadio("Radio3d", 12, 534, 425, 17) Local $Radio16 = GUICtrlCreateRadio("Radio4d", 12, 558, 425, 17) Local $BottoneScappaTest = GUICtrlCreateButton("Scappa....", 8, 592, 177, 41, $WS_GROUP) Local $BottoneConsegnaTest = GUICtrlCreateButton("Consegna il test", 280, 592, 177, 41, $WS_GROUP) Local $CompilaTest=ColloquioDomande() GUICtrlSetData($LabelRadioDom1,$CompilaTest[0][0]) GUICtrlSetData($LabelRadioDom2,$CompilaTest[0][1]) GUICtrlSetData($LabelRadioDom3,$CompilaTest[0][2]) GUICtrlSetData($LabelRadioDom4,$CompilaTest[0][3]) GUICtrlSetData($Radio1,$CompilaTest[1][0]) GUICtrlSetData($Radio2,$CompilaTest[1][1]) GUICtrlSetData($Radio3,$CompilaTest[1][2]) GUICtrlSetData($Radio4,$CompilaTest[1][3]) GUICtrlSetData($Radio5,$CompilaTest[1][4]) GUICtrlSetData($Radio6,$CompilaTest[1][5]) GUICtrlSetData($Radio7,$CompilaTest[1][6]) GUICtrlSetData($Radio8,$CompilaTest[1][7]) GUICtrlSetData($Radio9,$CompilaTest[1][8]) GUICtrlSetData($Radio10,$CompilaTest[1][9]) GUICtrlSetData($Radio11,$CompilaTest[1][10]) GUICtrlSetData($Radio12,$CompilaTest[1][11]) GUICtrlSetData($Radio13,$CompilaTest[1][12]) GUICtrlSetData($Radio14,$CompilaTest[1][13]) GUICtrlSetData($Radio15,$CompilaTest[1][14]) GUICtrlSetData($Radio16,$CompilaTest[1][15]) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $BottoneScappaTest Exitloop EndSwitch WEnd Func ColloquioDomande() Local $DomandaA[5]=["domA","a1","a2","a3","a4"],$DomandaB[5]=["domB","b1","b2","b3","b4"],$DomandaC[5]=["domC","c1","c2","c3","c4"] _ ,$DomandaD[5]=["domD","d1","d2","d3","d4"],$DomandaE[5]=["domE","e1","e2","e3","e4"] Local $DomandeDifferenti[4] Local $RisposteMischiate[16] Local $i=1 Local $r=4 For $z=1 To 4 Local $numeridom[5]=[1,2,3,4,5] Local $GiroDomande=$numeridom[Random(0,UBound($numeridom)-1,1)] _ArrayDelete($numeridom,$GiroDomande-1) Select Case $GiroDomande=1 $DomandeDifferenti[$z-1]=$DomandaA[0] _ArrayDelete($DomandaA,0) Local $RisposteInOrdine[4]=[$DomandaA[0],$DomandaA[1],$DomandaA[2],$DomandaA[3]] Case $GiroDomande=2 $DomandeDifferenti[$z-1]=$DomandaB[0] _ArrayDelete($DomandaB,0) Local $RisposteInOrdine[4]=[$DomandaB[0],$DomandaB[1],$DomandaB[2],$DomandaB[3]] Case $GiroDomande=3 $DomandeDifferenti[$z-1]=$DomandaC[0] _ArrayDelete($DomandaC,0) Local $RisposteInOrdine[4]=[$DomandaC[0],$DomandaC[1],$DomandaC[2],$DomandaC[3]] Case $GiroDomande=4 $DomandeDifferenti[$z-1]=$DomandaD[0] _ArrayDelete($DomandaD,0) Local $RisposteInOrdine[4]=[$DomandaD[0],$DomandaD[1],$DomandaD[2],$DomandaD[3]] Case $GiroDomande=5 $DomandeDifferenti[$z-1]=$DomandaE[0] _ArrayDelete($DomandaE,0) Local $RisposteInOrdine[4]=[$DomandaE[0],$DomandaE[1],$DomandaE[2],$DomandaE[3]] EndSelect For $k=$i To $r Local $numeririsp[4]=[0,1,2,3] Local $CopiaRispOrdine=$RisposteInOrdine Local $GiroRispInOrdine=$numeririsp[Random(0,Ubound($numeririsp)-1,1)] _ArrayDelete($numeririsp,$GiroRispInOrdine) $RisposteMischiate[$k-1]=$CopiaRispOrdine[$GiroRispInOrdine] _ArrayDelete($CopiaRispOrdine,$GiroRispInOrdine) Next $i+=4 $r+=4 Next Local $MultiDomERisp[2][16]=[[$DomandeDifferenti[0],$DomandeDifferenti[1],$DomandeDifferenti[2],$DomandeDifferenti[3]], _ [$RisposteMischiate[0],$RisposteMischiate[1],$RisposteMischiate[2],$RisposteMischiate[3],$RisposteMischiate[4], _ $RisposteMischiate[5],$RisposteMischiate[6],$RisposteMischiate[7],$RisposteMischiate[8],$RisposteMischiate[9], _ $RisposteMischiate[10],$RisposteMischiate[11],$RisposteMischiate[12],$RisposteMischiate[13],$RisposteMischiate[14], _ $RisposteMischiate[15]]] Return $MultiDomERisp EndFunc If you need better formatting, or a bit of translation on the above code just ask. -
Yes. As the program you want to write basically must keep running till you don't stop it for listening for whenever you press you selected key (spacebar in your example) you have to keep it running till you don't stop it. You do this with a While 1 loop which keeps the program running infinitely. Also always add a sleep to infinite loops because otherwise it will keep running same cicle thousands of times in a few milliseconds. In your posted code, it checks for the pression of spacebar just 1 time then the programs exits because istructions are ended. So you should press spacebar in the fraction of millisecond that the program runs to see the effect. Hope it cleared things.