
dakishman
Active Members-
Posts
30 -
Joined
-
Last visited
dakishman's Achievements

Seeker (1/7)
0
Reputation
-
loop "for to" run 8 time and don`t run
dakishman replied to khang0001's topic in AutoIt General Help and Support
There is no pause in your code... Your code runs all at once... Try: #Include <FF.au3> _FFConnect () for $i= 98 to 200 _FFStart ("http://www.abc.com/join.php?g_id=" & $i ,1,0) $text1 = _FFSearch ( "xyz") $text2 = _FFSearch ( "go") if $text1 =1 Then if $text2 = 1 Then _FFClick ("Submit2","name") EndIf EndIf Sleep(5000) Next -
I think it might be because you have the wrong window title. You have: CControlSend("MegaUpper Uploader Test", "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", '{tab}{tab}{tab}{space}') But in the picture from the auto it InfoWindow the title of the screen is: >>>> Window <<<< Title: Choose File to Upload I am assuming that it isn't seeing the title window "MegaUpper Uploader Test" so it is waiting for it to exist. Try: #include <IE.au3> Global $oIE, $GUIActiveX, $GUI_Button_Back, $GUI_Button_Forward Global $GUI_Button_Home, $GUI_Button_Stop, $msg $oIE = ObjCreate("Shell.Explorer.2") GUICreate("MegaUpper Uploader Test", 800, 768, 1, 1) $GUIActiveX = GUICtrlCreateObj($oIE, 1, 1, 800, 768) GUISetState(@SW_SHOW) ;Show GUI; $oIE.navigate("http://www.megaupper.com") _IELoadWait($oIE) Sleep(500) ControlClick("MegaUpper Uploader Test", "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "left", 1, 186, 372) ControlSend("Choose File to Upload", "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", '{tab}{tab}{tab}{space}') WinWait ("Choose File to Upload","",30) ControlClick("Choose File to Upload", "", "", "left", 1, 752, 433 Hope this helps...
-
loop "for to" run 8 time and don`t run
dakishman replied to khang0001's topic in AutoIt General Help and Support
As far as I can tell there is nothing to slow it down. It exicutes 102 times as fast as it can then quits... try something like: #Include <FF.au3> _FFConnect () for $i= 98 to 200 _FFStart ("http://www.abc.com/join.php?g_id=" & $i ,1,0) $text1 = _FFSearch ( "xyz") $text2 = _FFSearch ( "go") if $text1 =1 Then if $text2 = 1 Then _FFClick ("Submit2","name") EndIf EndIf Do Sleep(100) Until WinGetText ( "http://www.abc.com/join.php?g_id=" & $i, "xyz") = 0 Next Or even more simply (But less reliable) add some "Sleep(3000)" (Stops program for 3 seconds for screen loadings or what not.) Hope this helps... P.S. Sorry about poor formatting of the Do loop, I can't seem to get it right in this editor. -
What the program does: It is a little program to just help memorize the times table. If you answer the question within 2 seconds of it displaying and you get the answer right it will display a random image from the image folder "@ScriptDir\Pics". The user can put any picture in there from puppy dogs, to cars, to anything... The program will automatically propagate the list and select one at random. If you click the wrong answer nothing happens as of yet. If you click the right answer after 2 seconds it states "Too Slow" and comes up with a new formula. If you answer correctly and in under 2 seconds it will remember that formula so that it is not called again so that you can narrow in on what you are lacking. Hope this description helps. The Problem: I can not seem to resize the image to a format that fits the screen and keeps its aspect ratio. I was thinking about keeping a height of 200 and using W\H= Ratio to recalc the new width to keep the aspect ratio. The problem is for some reason when I try to use "GUICtrlCreatePic" the image does not appear. The window is resized and to the right dimensions but it does not display the image. As of now I have the image displayed at its original size. Even now sometimes the window is not the correct size for the image What I have attempted: Before you flame I have searched the forums and I know there are a few posts about image resizing using GDI+. This is where I got my current code, however, I do not fully understand how the GDI+ works. Here is the proof of my searches: http://www.autoitscript.com/forum/index.php?showtopic=96238 However whenever I try to use "GUICtrlCreatePic" in mine the image doesn't display, but if I remove "_GDIPlus_ImageLoadFromFile" it does but I can't get the dimensions. So as of now I use "_GDIPlus_GraphicsCreateFromHWND" to create the image but I don't see how I can size the image using this. Goal: Once the answer is answered correctly and under 2 seconds the image will be displayed at 200pixels by X in the same aspect ratio. Here is my current code all commented up: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <Array.au3> #include <GDIPlus.au3> ;Sets Global Vars Global $sini = @ScriptDir & "\KnownTables.ini" ;sets INI location Global $Button[5], $X, $Y ;Declares buttons and X and Y numbers for formula Global $PicsList = _FileListToArray(@ScriptDir & "\Pics\") ;Location of the pics dir Global $timer = TimerInit() ;Starts timer. I don't know why but Site was barking at me to start it globally. So instead of arguing with Site... Global $GoodAnswers[13][13] ;This sets the array to record the correct answers ;Load from the inifile the answers that have been correctly answered from previous runs For $i = 1 To 12 For $k = 1 To 12 $GoodAnswers[$i][$k] = IniRead($sini, "KNOWN", $i & $k, 0) Next Next ;asks user if they would like to use the pics in the first place. $Answer = MsgBox(4, "UsePics?", "Would you like to use pics?") ;GUI Window to display the buttons and the formula #Region ### START Koda GUI section ### Form=c:\users\kish\documents\sync folder (netbook)\times table program\main window.kxf $DisplayWindow = GUICreate("Multi Trainer", 317, 132, 312, 133) $Button[1] = GUICtrlCreateButton("", 0, 72, 75, 25, $WS_GROUP) $Button[2] = GUICtrlCreateButton("", 80, 72, 75, 25, $WS_GROUP) $Button[3] = GUICtrlCreateButton("", 160, 72, 75, 25, $WS_GROUP) $Button[4] = GUICtrlCreateButton("", 240, 72, 75, 25, $WS_GROUP) $ExitButton = GUICtrlCreateButton("EXIT", 0, 104, 315, 25, $WS_GROUP) $DisplayArea = GUICtrlCreateLabel("DisplayArea", 0, 0, 316, 68) GUICtrlSetFont(-1, 40, 800, 0, "Vrinda") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;Start my reset func to create a formula and to create button numbers for the formula _Reset() ;Gui Loop to read the button pressed While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _SaveGoodAnswers() ;func used to save the correctly answered questions Exit Case $Button[1] $ButtonNum = GUICtrlRead($Button[1]) If Int($ButtonNum) = $X * $Y Then _Correct() Case $Button[2] $ButtonNum = GUICtrlRead($Button[2]) If Int($ButtonNum) = $X * $Y Then _Correct() Case $Button[3] $ButtonNum = GUICtrlRead($Button[3]) If Int($ButtonNum) = $X * $Y Then _Correct() Case $Button[4] $ButtonNum = GUICtrlRead($Button[4]) If Int($ButtonNum) = $X * $Y Then _Correct() Case $ExitButton Exit EndSwitch WEnd Func _Reset() ;Selects random numbers from 1-12 to propagate a formula and then randomizes the buttons. Do $X = Int(Random(1, 12)) $Y = Int(Random(1, 12)) Until $GoodAnswers[$X][$Y] <> 1; This checks to make sure that the equation is not already known. For $i = 1 To 4; This propagates all 4 buttons with random answers (Seemed to be the easiest way instead of trying to identify the correct answer button then generating after that...) $RndNum = Int(Random(1, 12)) $RndButtonNum = $RndNum * $X GUICtrlSetData($Button[$i], $RndButtonNum); Sets current button ($i) to the random number Next GUICtrlSetData($DisplayArea, " " & $X & " X " & $Y & " = ?"); Display the formula $CorrectAnswer = Int(Random(1, 4)); Randomly choose a button for the correct answer GUICtrlSetData($Button[$CorrectAnswer], $X * $Y); Sets that button to the answer $timer = TimerInit(); Starts the timer to count for the 2 seconds EndFunc ;==>_Reset Func _Correct() $beat2sec = Int(TimerDiff($timer)); Record the time diff of the button from when the formula was made till the button was pressed If IsArray($PicsList) And $Answer = 6 And $beat2sec < 2000 Then; Make sure that the user choose yes to using pictures (msg box above) That there are pictures in the folder, and that the answer was within 2 seconds (2000 because the timer is in miliseconds)) $GoodAnswers[$X][$Y] = 1; sets the current X & Y Vals used in formula to the array to 1 (1 = answered correctly) _GDIPlus_Startup() $PicNum = Int(Random(0, $PicsList[0])); randomly pic a number for the picture to display ($piclist[0] is the total values in the $picslist array) $hBitmap = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\pics\" & $PicsList[$PicNum]); create a bitmap object from file $LoadedPicH = _GDIPlus_ImageGetHeight($hBitmap); Read pics Hight $LoadedPicW = _GDIPlus_ImageGetWidth($hBitmap); read pics width $WidthRatio = $LoadedPicW / $LoadedPicH; create an aspect ratio of Hight to width $NewWidth = 200 * $WidthRatio; Multiplies the Aspect ratio to what the new Hight should be $PictureWindow = GUICreate("My GUI picture", $LoadedPicW, $LoadedPicH, 0, 0, $WS_SIZEBOX + $WS_SYSMENU); Creates the picture window in the GUI GUISetState(@SW_SHOW) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($PictureWindow); create a graphic object in $Picture Window GUICtrlSetPos($hGraphic, 0, 0, $NewWidth, 200); Not sure, was an attempt from some of the posts I read to hopefully resize the _GDIPlus_GraphicsCreateFromHWND. _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0); draws the bitmap image in the graphic Sleep(3000) GUIDelete($PictureWindow); Deletes window EndIf If $beat2sec > 2000 Then ;If was correct answer but after 2 seconds GUICtrlSetData($DisplayArea, "TOO SLOW") ; Display "Too Slow" Sleep(1000) EndIf _Reset(); Goes to reset to regenerate a new equation EndFunc ;==>_Correct Func _SaveGoodAnswers(); Attempts to save the correctly answered questions to a ini file For $i = 1 To 12 For $k = 1 To 12 IniWrite($sini, "KNOWN", $i & $k, $GoodAnswers[$i][$k]) Next Next EndFunc ;==>_SaveGoodAnswers Here is my code Not commented up: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <Array.au3> #include <GDIPlus.au3> Global $sini = @ScriptDir & "\KnownTables.ini" Global $Button[5], $X, $Y Global $PicsList = _FileListToArray(@ScriptDir & "\Pics\") Global $timer = TimerInit() Global $GoodAnswers[13][13] For $i = 1 To 12 For $k = 1 To 12 $GoodAnswers[$i][$k] = IniRead($sini, "KNOWN", $i & $k, 0) Next Next $Answer = MsgBox(4, "UsePics?", "Would you like to use pics?") #Region ### START Koda GUI section ### Form=c:\users\kish\documents\sync folder (netbook)\times table program\main window.kxf $DisplayWindow = GUICreate("Multi Trainer", 317, 132, 312, 133) $Button[1] = GUICtrlCreateButton("", 0, 72, 75, 25, $WS_GROUP) $Button[2] = GUICtrlCreateButton("", 80, 72, 75, 25, $WS_GROUP) $Button[3] = GUICtrlCreateButton("", 160, 72, 75, 25, $WS_GROUP) $Button[4] = GUICtrlCreateButton("", 240, 72, 75, 25, $WS_GROUP) $ExitButton = GUICtrlCreateButton("EXIT", 0, 104, 315, 25, $WS_GROUP) $DisplayArea = GUICtrlCreateLabel("DisplayArea", 0, 0, 316, 68) GUICtrlSetFont(-1, 40, 800, 0, "Vrinda") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _Reset() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _SaveGoodAnswers() Exit Case $Button[1] $ButtonNum = GUICtrlRead($Button[1]) If Int($ButtonNum) = $X * $Y Then _Correct() Case $Button[2] $ButtonNum = GUICtrlRead($Button[2]) If Int($ButtonNum) = $X * $Y Then _Correct() Case $Button[3] $ButtonNum = GUICtrlRead($Button[3]) If Int($ButtonNum) = $X * $Y Then _Correct() Case $Button[4] $ButtonNum = GUICtrlRead($Button[4]) If Int($ButtonNum) = $X * $Y Then _Correct() Case $ExitButton Exit EndSwitch WEnd Func _Reset() Do $X = Int(Random(1, 12)) $Y = Int(Random(1, 12)) Until $GoodAnswers[$X][$Y] <> 1 For $i = 1 To 4 $RndNum = Int(Random(1, 12)) $RndButtonNum = $RndNum * $X GUICtrlSetData($Button[$i], $RndButtonNum) Next GUICtrlSetData($DisplayArea, " " & $X & " X " & $Y & " = ?") $CorrectAnswer = Int(Random(1, 4)) GUICtrlSetData($Button[$CorrectAnswer], $X * $Y) $timer = TimerInit() EndFunc ;==>_Reset Func _Correct() $beat2sec = Int(TimerDiff($timer)) If IsArray($PicsList) And $Answer = 6 And $beat2sec < 2000 Then $GoodAnswers[$X][$Y] = 1 _ArrayDisplay($GoodAnswers) _GDIPlus_Startup() $PicNum = Int(Random(0, $PicsList[0])) $hBitmap = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\pics\" & $PicsList[$PicNum]); create a bitmap object from file $LoadedPicH = _GDIPlus_ImageGetHeight($hBitmap) $LoadedPicW = _GDIPlus_ImageGetWidth($hBitmap) $WidthRatio = $LoadedPicW / $LoadedPicH $NewWidth = 200 * $WidthRatio $PictureWindow = GUICreate("My GUI picture", $LoadedPicW, $LoadedPicH, 0, 0, $WS_SIZEBOX + $WS_SYSMENU) GUISetState(@SW_SHOW) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($PictureWindow); create a graphic object in form1 GUICtrlSetPos($hGraphic, 0, 0, $NewWidth, 200) _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0); draws the bitmap image in the graphic Sleep(3000) GUIDelete($PictureWindow) EndIf If $beat2sec > 2000 Then GUICtrlSetData($DisplayArea, "TOO SLOW") Sleep(1000) EndIf _Reset() EndFunc ;==>_Correct Func _SaveGoodAnswers() For $i = 1 To 12 For $k = 1 To 12 IniWrite($sini, "KNOWN", $i & $k, $GoodAnswers[$i][$k]) Next Next EndFunc ;==>_SaveGoodAnswers Thanks in advanced for the help. P.S. I know the read and write to the ini file is broken. I can fix this later. That isn't a big deal, it's prolly that I just used the wrong values or syntax.
-
Search for a file (I'm a noob)
dakishman replied to dakishman's topic in AutoIt General Help and Support
BTW before I get flamed... I don't have code for this program yet sept the simple GUI. I haven't progressed any farther because if I am not able to search for files, than the project is kind of useless. -
I have searched a little bit and was unsuccessful. What I am looking for: 1. Using a variable to determine a wild card to look for. (Example: *.docx) 2. The code searches though the computer to find every file ending with *.docx 3. Building an INI list of all the files and their locations (Paths) that can be recalled later. EXAMPLE: @Scriptdir\List.ini [*.DOC] File1 = c:\somefile.docx File2 = c:\somefolder\someotherfile.dox [*.BMP] File1 = C:\Somepic.BMP File2 = D:\someotherfolder\somefile.BMP What I have found so far. 1. Filefindfirstfile, and filefindnextfile: I know these will return the names of the files in a given directory, but what if the directory is unknown? 2. I need to use "DriveGetDrive" to specify a list of the drives given (I am mainly interested in the hard drives) 3. I am looking for something with a simple code or in the form of a function What I am hoping for I am hoping that someone would be so kind to build the code in the form of a function. Something to the effect where I can call the function with the name of the INI and the name of the file I am searching out. EXAMPLE: Call ("Search", $sINIFile, $sFilename) Func Search () "Code" EndFunc Is this even possible? I know you can search a specific dir for a file, but not sure about searching for a file with an unknown dir. I am hoping this is a simple task lol... but I have the feeling from what I was reading that it isn't.
-
The Problem: I want to create a small window, about 3inch². I want to be able to play a wmv file (Or even a mpg, or mpeg at this point) in this window and have very basic controls at the bottom. Such as: Play Pause Next Back Mute Volume The Reason: I want this to be completely in AutoIt and not in Windows Media Player beacuse I am going to add effects to the window such as hiding when not in focus, calling it when a button is pressed, and fading. There are also more commands but you get the idea. What I am looking for: I just need to know what command will allow me to embed the video. Also, what are the commands that will allow me to control the video. Yes I admit I have not searched for the answer hardcore in the forums, I figured I would post this then look, so that this can be brewing while I search. Please don't flame... I appreciate any help!
-
I can not figure out a way to save two radio group values too two different variables with one click of the button. For EX: ;====== ;Group 1 ;====== $Running = GUICtrlCreateGroup("Do While Running", 152, 8, 137, 137) $A1 = GUICtrlCreateRadio("A1 ", 160, 24, 49, 17) GUICtrlSetState(-1, $GUI_CHECKED) $H1 = GUICtrlCreateRadio("H1 ", 160, 40, 81, 17) $n1 = GUICtrlCreateRadio("N1!", 160, 56, 65, 17) $C1 = GUICtrlCreateGroup("C1 (Sec)", 152, 96, 137, 49) ;====== ;Group 2 ;====== $Running = GUICtrlCreateGroup("Do While not Running", 152, 8, 137, 137) $A2 = GUICtrlCreateRadio("A2 ", 160, 24, 49, 17) GUICtrlSetState(-1, $GUI_CHECKED) $H2 = GUICtrlCreateRadio("H2 ", 160, 40, 81, 17) $n2 = GUICtrlCreateRadio("N2!", 160, 56, 65, 17) $C2 = GUICtrlCreateGroup("C2 (Sec)", 152, 96, 137, 49) ;======== ;My Button ;======== $OK = GUICtrlCreateButton("OK", 8, 152, 75, 25, 0) ======== ;My Loop ======== Do $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Cancel ExitLoop Case $msg = $OK (Save Group1 radio value to $Value1) (Save Group2 radio value to $Value2) Exit EndSelect Until $exit = 1
-
The program I found a year ago would allow you to open a .au3 file and run it. It would then bring up a window showing you your program as it was being executed line by line. This was one of the most helpful tools I ever found and now it is burried in the forums and as hard as I try I can not seem to find it again. Does anyone know of this program or what post it is under? Even a name by chance?
-
Script Bogging down over time (2-3 Hours)
dakishman replied to dakishman's topic in AutoIt General Help and Support
Ok, I have an idea as to what it is, not sure though, going to test in a little. I think it was that I used "ClipPut()" in the script and used "Send ("^{v}")" it is right around this point that it slows down dramaticly. Trying to use "Send()" to send the text needed instead. Just a heads up. Will update later what happens. @valuater Tried your script man and it rocks. Seems to run faster than before. Never knew u could use a function as "_FunctionName ("Value1", "Value2")" before read the help file and I think I have it, but any help u can offer for it would be nice. Thanks again man! -
Script Bogging down over time (2-3 Hours)
dakishman replied to dakishman's topic in AutoIt General Help and Support
Just a quick reply. At work ATM. Your script looked GREAT man. Havent actualy run it yet beacuse since i sent you that code, I made a dramatic change to my code. Will look at yours and implement it into what i have or use yours. I have basicly added a loop that pulls values from a $array. ill send new code when i get home... hoping to figure this out -
Script Bogging down over time (2-3 Hours)
dakishman replied to dakishman's topic in AutoIt General Help and Support
UPDATE: It seems to get dramatically worse after the first run... I have a quad core processor, so I dont think it is the hardware, as it is really up to date. After letting it run last night, I checked the Task Manager for its memory usage, and it was almost nominal. This is what is really confusing me. However, I did observe that it was slowing dramatically at the "Sleep ()" command points. Where a "Sleep (500)" was taking almost one min. I did not notice slowing other than there. I will examine more closely when I get home... Any suggestions or ideas? -
Script Bogging down over time (2-3 Hours)
dakishman replied to dakishman's topic in AutoIt General Help and Support
Sorry man don't wanna post the script for reasons... The script runs flawless, just boggs down after time. I might find a way to post most of it after a little while. -
Script Bogging down over time (2-3 Hours)
dakishman replied to dakishman's topic in AutoIt General Help and Support
That is a real good point. I think it is beacuse I do"PixelSearch" bout once every 1/2 hour across half the screen and "PixelGetColor" Continualy throughout the script. Something to the effect of: $Colortest = PixelGetColor ( $X, $Y, $color) could this be what is slowing the program down after time? It does work fast and perfect at first. How can I fix this? I dont clear the variable out each time, and to be honest not sure what a handle is... I'm still a noob I guess. Any help appreciated, and thanks for the quick reply also. -
Clean way to declare arrays with letters...
dakishman replied to dakishman's topic in AutoIt General Help and Support
That isn't at all what im looking for. I want to stick to arrays. They are easier to manage.