Jump to content

Stopping program function with GUI


cshrem
 Share

Recommended Posts

Hey All,

First of..thanks for all your help.

With this issue I'm having I tried all the ideas in this forum, none seems to be working

Basically, the GUI pops up with a Start button, after the user hits start they have to confirm. Once they do that, the script will ALT+TAB to switch to the program I want to automate. It won't start without the prog being active using WinWaitActive("C:\WINDOWS\system32\cmd.exe", "", 5)

At this point, when I want to stop the program from runnning, I have to end the process in the task manager or task bar, no other way works. I would like some sort of stop button.

This is the code:

#include <GuiConstants.au3>
; Arcust Drop Ship v3.1
; AutoIt Version: 3.0
; Language:       English
; Platform:       Win9x/NT/XP
; Author:         Charlie Shrem (cshrem@gmail.com)
;
; Script Function:
; Drop ships and order in Arcust
; To use: Arcust needs to be turned on, go into the Open Sales Orders for a specific product. Then run the program. 
; Arcust needs to be in the correct pixel location for the mouse copy-paste to work. 
; Script will continue to run until told to stop

; run("C:\Documents and Settings\Charlie268\Desktop\GOD.BAT") 
Opt("GUIOnEventMode", 1) ; Change to OnEvent mode

$started = 0
$mainwindow = GuiCreate("Arcust Drop Ship v2.1", 300, 100)
$startbutton = GUICtrlCreateButton("Start !", 100, 50, 80, 30)
GUICtrlSetOnEvent($startbutton, "StartButton")
GUISetState(@SW_SHOW)

While 1
    Sleep(10)
    If $started Then
        ConsoleWrite("this will fire until stop button is pressed" & @LF)
    EndIf
Wend

Func StartButton()
    MsgBox(0, "GUI Event", "Starting Program, to terminate you must end the process, Hit ENTER to continue")
    Send("{ALTDOWN}{TAB}{ALTUP}")
    $started = 1
    $i = 0
While $i <= 4
opt('SendKeyDelay', 500)
WinWaitActive("C:\WINDOWS\system32\cmd.exe", "", 5)  
Send("{CTRLDOWN}{ENTER}{CTRLUP}{PGDN}")
Sleep(500)
If PixelChecksum(455,198,455,198) = 83755519 Then ; if the customer already purchased
Send("{ENTER}")
Send("{ENTER}")
Else
Send("{ENTER}")
EndIf
;;;;;;;;Mouse copy paste;;;;;;;;
Sleep(1000)
MouseMove(192,121)
MouseDown("left")
MouseMove(232,123)
MouseUp("left")
MouseClick("right",229,123,1)
MouseClick("right",501,91,1)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Send("{PGDN}")
Send("{PGDN}")
Send("{PGDN}")
Sleep(500)
Send("{F11}")
Send("S")
Send("IKD") ; enter drop ship vendor 
Send("{ENTER}")
Send("{PGDN}")
Sleep(2000)
Send("{F10}")
Sleep(2000)
If PixelChecksum(455,198,455,198) = 83755519 Then ; if the customer already purchased
    Send("{ENTER}")
      Else
       Send("{ENTER}")
       Send("{ENTER}")
EndIf
Send("{PGDN}")
Send("{PGDN}")
Send("{PGDN}")
Send("{PGDN}")
Sleep(1000)
Send("{RIGHT}")
Send("{ENTER}")
Sleep(1000)
Send("{ENTER}")
Sleep(16000) ; shipping 
Send("{ESCAPE}") ; UPS export may show up 
Send("{ESCAPE}") ; ask to be printed
Sleep(500)
Send("{PGDN}")
Sleep(1500)
Send("{RIGHT}")
Send("{ENTER}")
Send("{DOWN}")
Sleep(4000)
$1 = $i + 1
WEnd    
EndFunc

This is what the DOS program I'm working with looks like,

Posted Image

Any help would be appreciated.

If you have any ideas to make the program better, please let me know

Cheers

Charles

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...