Jump to content

Endless loop of executing the .exe file


icek93
 Share

Go to solution Solved by BrewManNH,

Recommended Posts

Hi!
I am new to AutoIT and I would like to ask a question about my simple script, which I have written. When I am Run it (F5) in SciTE Script Editor everything works great but when I build it to .exe (F7) and then open this file everything is ruined. Exe application starts over and over so in the end i have something about ~50 programs opened and my system crashes.
What have I done wrong?
 
 
PS. If there exist topic which could answer my questions i would be delighted if you can post it here. I have searched but everything i have seen did not answer my questions.

Run("notepad.exe")
WinWaitActive("Bez tytułu — Notatnik")
WinActivate("Bez tytułu — Notatnik")
Global $var2, $var1

;WinSetState("Font", "Cancel", @SW_HIDE)
;WinSetState("Bez tytułu — Notatnik", "", @SW_MAXIMIZE)
;$format = GUICtrlCreateMe
Func toType()
For $i=0 To 1 Step 1
    Send("Próba nr : " & $i & @CRLF)
    $var2="Próba nr : " & $i
Next
$var1 = "Próba nr : 2"
$toCompare = StringCompare("$var1","$var2")

If $toCompare==0 Then
    Send("Są równe")
    Sleep(1000)
Else
    Send("Nie sa rowne "& @LF)
    Sleep(1000)
EndIf

EndFunc
Func toPrint()
Local $toTest
$toTest = ClipPut($var1)
Send("^v")
Sleep(1000)
EndFunc
Func toChangeWords()
Send("^h")
WinWaitActive("Zamienianie","",0)
Sleep(500)
Send("Próba {TAB} Nastąpiła zamiana ")
Sleep(500)
ControlClick("Zamienianie", "",1025)
Sleep(500)
ControlClick("Zamienianie", "", 2)
EndFunc
Func font()

Send("{LALT}")
Send("{M}")
Send("{DOWN} {ENTER}")
Sleep(500)
WinWaitActive("Czcionka","")
Send("Papyrus {TAB} Pogrubiona Pochyła {TAB} 15")
Sleep(500)
ControlClick("Czcionka", "", 1)

EndFunc
Func rowsChange()
    Send("{LALT}")
    Send("{M} {ENTER}")
EndFunc
Func toSave()
    Send("^s")
    WinWaitActive("Zapisywanie jako")
    Send("Nazwa")
    Sleep(500)
    ControlClick("Zapisywanie jako", "", 1)
    Send("!{F4}")
EndFunc

font()
toType()
toPrint()
toChangeWords()
rowsChange()
toSave()

And second one, the same problems :

Run("calc.exe")
WinWaitActive("Kalkulator")
WinActivate("Kalkulator")

Func sciCalc()
    Send("{altdown}{2}{altup}")
    Sleep(1500)
    Send("{Enter}")
EndFunc

Func simpleMultiplication()
    ControlClick("Kalkulator", "", 131)
    Sleep(500)
    ControlClick("Kalkulator", "", 92 )
    Sleep(500)
    ControlClick("Kalkulator", "", 135)
    Sleep(500)
    ControlClick("Kalkulator", "", 121)
    Sleep(1000)
    ControlClick("Kalkulator", "", 81 )
EndFunc

Func simpleAdding()
    ControlClick("Kalkulator", "", 138)
    Sleep(500)
    ControlClick("Kalkulator", "", 93)
    Sleep(500)
    ControlClick("Kalkulator", "", 136)
    Sleep(500)
    ControlClick("Kalkulator", "", 121)
    Sleep(1000)
    ControlClick("Kalkulator", "", 81 )
EndFunc

Func converUnits()
    Send("{CTRLDOWN}{F4}{CTRLUP}")
    Sleep(1000)
    Send("^u")
    For $i=0 To 8 Step 1
        Send("{DOWN}")
        Sleep(450)
    Next
    Send("{TAB}")
    Send("150")
    Send("{TAB}")
    ControlClick("Kalkulator", "" ,224)
    For $i=0 To 2 Step 1
        Send("{DOWN}")
        Sleep(450)
    Next
    Send("{ENTER}")
    $k=1
    While $k >=0
        Send("{TAB}")
        $k = $k - 1
    WEnd

    $a = 2
    While $a >0
    Send("{DOWN}" & $a)
    $a = $a - 1
    Sleep(500)
WEnd
    Sleep(1000)
EndFunc

Func changeRadioButton()
    Send("{CTRLDOWN}{F4}{CTRLUP}")
    MsgBox(0,"Opis","Operacja, gdy argument funkcji podany w stopniach...")
    ControlClick("Kalkulator","",321)
    Sleep(500)
    ControlClick("Kalkulator", "", 139)
    Sleep(500)
    ControlClick("Kalkulator", "", 130)
    Sleep(500)
    ControlClick("Kalkulator", "", 102)
    Sleep(500)
    MsgBox(0,"Opis cd.","... w porównaniu do wyniku, gdy argument jest w radianach")
    ControlClick("Kalkulator","",322)
    Sleep(500)
    ControlClick("Kalkulator", "", 139)
    Sleep(500)
    ControlClick("Kalkulator", "", 130)
    Sleep(500)
    ControlClick("Kalkulator", "", 102)
EndFunc

Func cleanAfterWork()

    MsgBox(0,"Koniec", "Na koniec posprzątamy czyszcząc historię.")
    Send("{CTRLDOWN}{h}{CTRLUP}")
    WinActivate("Kalkulator")
    Local $param[4] = ["{ALT}", "{E}","{H}","{W}"]

    For $w = 0 To 3 Step 1
        Send($param[$w])
        Sleep(450)
    Next

EndFunc

sciCalc()
simpleMultiplication()
simpleAdding()
converUnits()
changeRadioButton()
cleanAfterWork()
Link to comment
Share on other sites

  • Moderators

icek93,

Welcome to the AutoIt forum. :)

Are you naming these 2 scripts notepad.exe and calc.exe when you compile them? ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Solution

If you name your script the same name as the program you're trying to run, when you compile it your script will run itself instead of the program you wanted to run.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...