Jump to content

sleepydvdr

Active Members
  • Posts

    562
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sleepydvdr

  1. You can replace Sleep(500) With: WinWaitActive("[CLASS:Notepad]") And Local $sSrcAppPath = "C:\Windows\System32\notepad.exe"     ; -----------------------------------------------     Run($sSrcAppPath) With simply: Run("notepad") And the same would go for WinClose("notepad") I'm not sure if these would speed up your script. The WinWaitActive would be better because some computers may take longer than 500ms and super fast computers won't need to wait that long. And the other suggestions just simplifies the code a little (and the script would work on computers where the OS is installed on a different partition than C:. Your script was not sluggish on my computer, btw.
  2. The line you posted didn't seem to do anything for me. I assume that is an IP address, so I changed it to mine and still nothing. However, try this: ShellExecute('"Log" java', "-jar Log.jar 121.128.133.28 15777") The cd is a command. It stands for change directory. You have to be in the correct directory to run an executable.
  3. in the bat file, you will need to change directories. Something like: cd "c:Program FilesCasetalk" But why are you using a batch file? Why not cut out the middle man and do everything with AutoIt?
  4. You could put in some code that prevents the error in the first place. Example: #include <array.au3> Local $array[5] For $i = 0 to 10 step 1 ; loops 11 times, but the array only has 5 slots If $i <= UBound($array) - 1 Then $array[$i] = "information" EndIf Next _ArrayDisplay($array)
  5. I use Inno Setup to create installers. It's pretty easy to learn and makes your program look professional. Plus, it supports silent switches. Just another thing to consider.
  6. Perhaps this reg key: HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstall
  7. Sounds like you have some kind of sandboxing program running.
  8. My best advice is to use WinGetPos to find the parent's position and WinMove to move the child window to a relative position to the parent window.
  9. Those errors are wildly different from each other. I suspect malware. Try your code on another computer (one that you are sure is clean).
  10. You can get regsistry information in a user account, so Xandy's code works. You may have a problem with getting the GPU info. I looked up mine and it was listed here: [HKEY_LOCAL_MACHINESYSTEMControlSet001ControlClass{4D36E968-E325-11CE-BFC1-08002BE10318}0000] I have a feeling that every video card will have a different class. You may have to write code that reads all classes and search the entries for major name brands (intel, amd, trident, voodoo, etc). Once you find a match, you could read registry entries from that class. So far, I don't know how to find the memory type.
  11. I can only address #2 and #3. You do not need an outside program to draw gridlines. Below is an example of your screen getting split up in to 100 equal sections. Press the ESC key to exit. #include <WinAPI.au3> #include <WindowsConstants.au3> #include <FontConstants.au3> #NoTrayIcon $width = @DesktopWidth $height = @DesktopHeight Global $tRECT, $hFont, $hOldFont, $hDC HotKeySet("{ESC}", "_Exit") $tRECT = DllStructCreate($tagRect) DllStructSetData($tRECT, "Left", 5) DllStructSetData($tRECT, "Top", 5) DllStructSetData($tRECT, "Right", 250) DllStructSetData($tRECT, "Bottom", 50) $hDC = _WinAPI_GetDC(0) $hFont = _WinAPI_CreateFont(50, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _ $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial') $hOldFont = _WinAPI_SelectObject($hDC, $hFont) _WinAPI_SetTextColor($hDC, 0x0000FF) _WinAPI_SetBkColor($hDC, 0x000000) While 1 For $i = 1 To 100 step 1 _WinAPI_DrawLine($hDC, $width / 100 * $i, 0, $width / 100 * $i, $height) Next Sleep(100) WEnd Func _Exit() _WinAPI_SelectObject($hDC, $hOldFont) _WinAPI_DeleteObject($hFont) _WinAPI_ReleaseDC(0, $hDC) _WinAPI_InvalidateRect(0, 0) $tRECT = 0 Exit EndFunc ;==>_Exit
  12. I modified the example in the AutoIt help file to show you a way it can be done. It works by pressing the PageDown button manually or by clicking a button. Or you could send it silently. If you are afraid of losing focus to the IE window later on, you could set a hotkey for PageDown and run a function that activates the window. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> _IEErrorHandlerRegister() Local $oIE = _IECreateEmbedded() GUICtrlSetState($oIE, $GUI_FOCUS) GUICreate("Embedded Web control Test", 640, 580, _ (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) GUICtrlCreateObj($oIE, 10, 40, 600, 360) Local $GUI_Button_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30) Local $GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30) Local $GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30) Local $GUI_Button_Stop = GUICtrlCreateButton("Stop", 340, 420, 100, 30) Local $GUI_Button_PGDown = GUICtrlCreateButton("PG Down", 450, 420, 100, 30) GUISetState() _IENavigate($oIE, "http://www.autoitscript.com") ControlFocus("Embedded Web control Test", "", "[CLASS:Internet Explorer_Server; INSTANCE:1]") ; This line sets focus to the IE window ; Waiting for user to close the window While 1 Local $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $GUI_Button_Home _IENavigate($oIE, "http://www.autoitscript.com") Case $msg = $GUI_Button_Back _IEAction($oIE, "back") Case $msg = $GUI_Button_Forward _IEAction($oIE, "forward") Case $msg = $GUI_Button_Stop _IEAction($oIE, "stop") Case $msg = $GUI_Button_PGDown ; This is your Page Down ControlFocus("Embedded Web control Test", "", "[CLASS:Internet Explorer_Server; INSTANCE:1]") ; You have to add it here because when you click the button, you lose focus of the IE Window Send("{PGDN}") EndSelect WEnd GUIDelete() Exit
  13. This could simulate what you want. I made it show the scroll bars after 14 lines (the limit of this particular GUI). If you go over 14 lines and then back to 14 or less, it takes away the scrollbars. It does not account for horizontal scrollbars. That might prove to be more difficult. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiScrollBars.au3> #include <GuiEdit.au3> $scroll = 0 $Form1 = GUICreate("Form1", 362, 211, 193, 125) $Edit1 = GUICtrlCreateEdit("", 16, 8, 329, 193, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN)) GUICtrlSetData(-1, "1" & @crlf & "2" & @crlf & "3" & @crlf & "4" & @crlf & "5" & @crlf & "6" & @crlf & "7" & @crlf & "8" & @crlf & "9" & @crlf & "10" & @crlf & "11" & @crlf & "12" & @crlf & "13"); & @crlf & "14" & @crlf & "15" & @crlf & "16" & @crlf & "17" & @crlf & "18") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() $lineCount = _GUICtrlEdit_GetLineCount($Edit1) If $lineCount > 14 AND $scroll = 0 Then GUICtrlSetStyle($Edit1, BitOR($ES_AUTOVSCROLL,$WS_VSCROLL,$ES_WANTRETURN)) $scroll = 1 ElseIf $lineCount <= 14 AND $scroll = 1 Then GUICtrlSetStyle($Edit1, BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN)) $scroll = 0 EndIf sleep (50) Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd
  14. Instead of sending keys to a control, try using _INetMail to create the email message. I have used that many times in the past without any problems.
  15. Are you looking for something along these lines? If $text = "Your IP" Then $text = StringReplace($text, "Your IP" Or $fr, @IPAddress1) Else $text = StringReplace($text, $fr, @IPAddress1) EndIf
  16. Yes, there is. The function is @ScriptDir. MsgBox(0, "", @ScriptDir)
  17. It sounds like you want to do some object oriented stuff. AutoIt is not an object oriented language, but there is a UDF to provide some of that kind of functionality. I'm not familiar with it, so I can't help you. Below is a link to the UDF:
  18. I created a survey for someone at work. But she wanted to change it too much and create new ones, so I gave up that idea. I did some research and the best software I found was called QuizCreator. I think it is primarilary for creating quizzes, but it creates surveys, too. It's very easy to use and can be exported as an exe or a flash/html page. Normally, I like to recommend freeware, but since it's for your job, it might be a justifiable expense. I found no easy, good freeware options other than some online websites, which my company did not care for. http://www.wondershare.com/pro/quizcreator.html
  19. Well, I learned something today. I always thought Dim was required for declaring arrays. I just tried Global to declare an array and it worked... I suppose you still need to use ReDim for reisizing arrays, right?
  20. It would be very hard to help you without knowing what program you are referring to. I googled HBCI and that seems to be a generic term for home banking software. Hard to troubleshoot without something to work with.
  21. Amazing work, João Carlos. I didn't think AutoIt was capable of creating such an advanced program.You proved that it is possible.
  22. The first script I posted creates the ini file. This is what I used for testing purposes: [0] Question=How many days are in a week? 1=4 2=8 3=7 4=3 Correct=7 [1] Question=What color is the sky? 1=Blue 2=Red 3=Green 4=Purple Correct=Blue [2] Question=How old are you? 1=24 2=99 3=88 4=6 Correct=24
  23. I modified the previous script, so be sure to use the newer version. Here's the console to be asked the questions: #include <GUIConstants.au3> #include <Array.au3> Dim $aArray[4] $iniFile = @ScriptDir & "AlphaTest.ini" Global $question, $correctAns, $error = 0 _GetQuestion() $Form1 = GUICreate("Study Helper", 633, 341, 193, 125) $Label1 = GUICtrlCreateLabel($question, 32, 48, 572, 73) $Label2 = GUICtrlCreateLabel("Question:", 24, 16, 49, 17) $Radio1 = GUICtrlCreateRadio($aArray[0], 40, 168, 545, 17) $Radio2 = GUICtrlCreateRadio($aArray[1], 40, 192, 545, 17) $Radio3 = GUICtrlCreateRadio($aArray[2], 40, 216, 545, 17) $Radio4 = GUICtrlCreateRadio($aArray[3], 40, 240, 545, 17) $Button1 = GUICtrlCreateButton("Submit", 264, 288, 75, 25, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _CheckAnswer() $error = 0 EndSwitch WEnd Func _GetQuestion() $namesOfSections = IniReadSectionNames($iniFile) $numberOfQuestions = $namesOfSections[0] $randomNumber = Random(0, $numberOfQuestions - 1, 1) $question = IniRead($iniFile, $randomNumber, "Question", "") $aArray[0] = IniRead($iniFile, $randomNumber, "1", "") $aArray[1] = IniRead($iniFile, $randomNumber, "2", "") $aArray[2] = IniRead($iniFile, $randomNumber, "3", "") $aArray[3] = IniRead($iniFile, $randomNumber, "4", "") $correctAns = IniRead($iniFile, $randomNumber, "Correct", "") Local $iRandom, $iBound = UBound($aArray) -1 For $i = 0 To $iBound $iRandom = Random(0, $iBound, 1) If $i <> $iRandom Then _ArraySwap($aArray[$i], $aArray[$iRandom]) Next EndFunc Func _CheckAnswer() If GUICtrlRead($Radio1) = 1 Then $answer = $aArray[0] ElseIf GUICtrlRead($Radio2) = 1 Then $answer = $aArray[1] ElseIf GUICtrlRead($Radio3) = 1 Then $answer = $aArray[2] ElseIf GUICtrlRead($Radio4) = 1 Then $answer = $aArray[3] Else MsgBox(0, "Error", "You did not select anything") $error = 1 EndIf If $error <> 1 Then If $answer = $correctAns Then MsgBox(0, "Correct", "You got the question correct!") Else MsgBox(0, "Incorrect", "Sorry, wrong answer. The correct answer is:" & @CRLF & @CRLF & $correctAns) EndIf EndIf _ResetQuestion() EndFunc Func _ResetQuestion() _GetQuestion() GUICtrlSetData($Label1, $question) GUICtrlSetData($Radio1, $aArray[0]) GUICtrlSetData($Radio2, $aArray[1]) GUICtrlSetData($Radio3, $aArray[2]) GUICtrlSetData($Radio4, $aArray[3]) EndFunc
  24. Just for the fun of it, I wrote a version of your script. Maybe it will give you a different perspective. For my scirpt, I used just numbers for the section names and values in the .ini file. I think that will make it easier to work with randomly picking questions and answers. I will try to work on a console for asking you questions. This one is just for adding questions to the ini file. #include <GUIConstants.au3> $iniFile = @ScriptDir & "AlphaTest.ini" $Form1_1 = GUICreate("Form1", 679, 365) $Edit1 = GUICtrlCreateEdit("", 32, 32, 537, 105) $Label1 = GUICtrlCreateLabel("Enter your question:", 32, 8, 98, 17) $Label2 = GUICtrlCreateLabel("Answer pool:", 32, 168, 65, 17) $Input1 = GUICtrlCreateInput("", 32, 192, 537, 21) $Input2 = GUICtrlCreateInput("", 32, 224, 537, 21) $Input3 = GUICtrlCreateInput("", 32, 256, 537, 21) $Input4 = GUICtrlCreateInput("", 32, 288, 537, 21) $Button1 = GUICtrlCreateButton("Save Question", 272, 328, 115, 25) $Label3 = GUICtrlCreateLabel("Correct Answer", 584, 160, 76, 17) $Radio1 = GUICtrlCreateRadio("", 584, 192, 113, 17) $Radio2 = GUICtrlCreateRadio("", 584, 224, 113, 17) $Radio3 = GUICtrlCreateRadio("", 584, 256, 113, 17) $Radio4 = GUICtrlCreateRadio("", 584, 288, 113, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _WriteToIni() EndSwitch WEnd Func _WriteToIni() Local $error = 0 $question = GUICtrlRead($Edit1) $ans1 = GUICtrlRead($Input1) $ans2 = GUICtrlRead($Input2) $ans3 = GUICtrlRead($Input3) $ans4 = GUICtrlRead($Input4) $readradio1 = GUICtrlRead($Radio1) $readradio2 = GUICtrlRead($Radio2) $readradio3 = GUICtrlRead($Radio3) $readradio4 = GUICtrlRead($Radio4) If $readradio1 = 1 Then $correctAns = $ans1 ElseIf $readradio2 = 1 Then $correctAns = $ans2 ElseIf $readradio3 = 1 Then $correctAns = $ans3 ElseIf $readradio4 = 1 Then $correctAns = $ans4 Else MsgBox(0, "Error", "Please select which answer is correct") $error = 1 EndIf If $error <> 1 Then $sectionNames = IniReadSectionNames($iniFile) $nextQuestion = UBound($sectionNames) - 1 If $nextQuestion < 1 Then $nextQuestion = 0 EndIf IniWrite($iniFile, $nextQuestion, "Question", $question) IniWrite($iniFile, $nextQuestion, "1", $ans1) IniWrite($iniFile, $nextQuestion, "2", $ans2) IniWrite($iniFile, $nextQuestion, "3", $ans3) IniWrite($iniFile, $nextQuestion, "4", $ans4) IniWrite($iniFile, $nextQuestion, "Correct", $correctAns) EndIf EndFunc
  25. If you gave us a link to the exact page, that would help us to help you.
×
×
  • Create New...