Jump to content

pausing script - to accept user input - doesnt continue as it should


Recommended Posts

ive got a basic hot key script (the boilerplate code for this code was found on the internet - with moderators additional code added to deal with the well-known 'virtual stuck key' issue)

the intention here is to help me fill out forms at a salesforce.com cms website.

the only 'user function' ive actually added is called 'Close' - invoked with '(shift)(control)c'

as presented, the script works PERFECTLY. note that at present the presented code contains a commented out line ' ; pause here to allow user to enter data into gui"

the moment i add either of two different means to allow me to type user data and pause the script - the script works fine up to, and including the point where i enter data. once control goes back to the script, the balance of the commands dont work as they should !!! i basically have the script send (alt)D - which sends the cursor into the URL address field of the browser (serving as a reference position within the browser), then merely sending a set number of tabs to move to the 'Save & Close' button, before sending {Enter} to activate that selected button.

with no pausing of any kind - the script navigates perfectly in the web form and saves and closes the edited form.

the moment i pause in th emiddle of the 'Close' function, using either of these methods;

a. Sleep(30000) ; THIS WOULD BE THE LAMEST WAY TO SOLVE THIS PROBLEM

b. Send("{PAUSE}") ; THIS WOULD BE THE IDEAL WAY TO SOLVE THIS PROBLEM, MERELY TOGGLING SCRIPT EXECUTION STATE WITH EACH {PAUSE} KEY INVOCATION

when the script returns from the sleep/pause - for reasons unknown, it then 'looses its bearings' and cant navigate the page as it normally should.

perhaps this is yet another 'well-known-issue' (involving pausing for user input) that i simply havent been able to find discussed in the faq?

perhaps someone can suggest a code snippet that theyve found works with autoit to pause a script to allow human input, then allows the script to continue.

#include <Misc.au3>                                          ; this is REQUIRED if you want this script to work properly

Global $hDLL = DllOpen("user32.dll")                         ; this is REQUIRED if you want this script to work properly
Global $Paused

HotKeySet("{PAUSE}", "TogglePause")      ; toggle the script executation state by 'pausing'

HotKeySet("^+c",     "Close")            ; control-shift-c Close           - will depress 'Edit' button, make changes, PAUSE FOR USER INPUT, then return to main Support screen

HotKeySet("^+y",     "ShowMessage")      ; control-shift-y
HotKeySet("^+z",     "Terminate")        ; control-shift-z

;;;; main loop is required ;;;;

While 1
    Sleep(100)
WEnd

;;;;

Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc   ;==>TogglePause

Func Terminate()
    DllClose($hDLL)                                          ; this is REQUIRED if you want this script to work properly
    Exit 0
EndFunc   ;==>Terminate

Func ShowMessage()
    MsgBox(4096, "", "This is a message.")
EndFunc   ;==>ShowMessage



Func Close()

    While _IsPressed("10", $hDLL) Or _IsPressed("11", $hDLL) ; this is REQUIRED if you want this script to work properly
        Sleep(10)                                            ; this is REQUIRED if you want this script to work properly
    WEnd                                                     ; this is REQUIRED if you want this script to work properly

    ; alt-D to move into the 'url address field' (as reference for cursor positioning), then tab 50 x's (to place cursor on 'Edit' button), then sent {Enter} to place page in edit mode
    Send("!D")
    Send("{TAB 50}")
    Send("{ENTER}")
    Sleep(5000)

    ; tab to 'description' field (which highlights everything in field), send LEFT key (to de-select the highlighted text), then insert 'year-month-day hour:minute ga, LM(newline)'
    Send("{TAB 9}")
    Send("{LEFT}")
    Send(@YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & " ga ")

    ; pause here to allow user to enter data into gui (and possibly hit 'tab' or '(shift)tab' keys)

    ; alt-D to move into the 'url address field' (as reference for cursor positioning), then tab 66 x's [or shift tab 10 x's] (to place cursor on 'Save & Close' button), then send {Enter} to 'Save' the edited page
    Send("!D")
    Send("{TAB 66}")
    Send("{ENTER}")
    Sleep(5000)

EndFunc   ;==>Close
Link to comment
Share on other sites

Just to inform, F6 gives you imediate control over the url bar, it's an alternative to what you use now.

I've never needed to pause a script, but i would try:

Do - Sleep - Until = you press a certain key, to tell the script you're done editing.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

I very well might need to learn how to use the ie object model (something im obviously not otherwise dying to do - as i know this will take some time) to solve this problem.

Either way, theres some trust needed that once the script continues from a 'pausing for user input' mode - to executing again - that the script should do what it is supposed to do.

Without this trust - my confidence here is waning...

Link to comment
Share on other sites

Backspace or ALT-Left arrow

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

theres some trust needed that once the script continues from a 'pausing for user input' mode - to executing again - that the script should do what it is supposed to do.

If the script is well done, it will perform well...Until now, all the times a script of mine was not working well, it was my fault.

Is there an equivalent "ie.au3" for firefox? I hate IE.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

No other browser allows control from external scripting as well as IE does. FF has a plugin so you can use the FF UDF, but it's minimal from what I've seen. Chrome/Opera/Safari etc. don't have anything similar. Using the IE.au3 UDF uses Internet Explorer, but you can do it all in the background and never see the browser window, so there's no reason to not use it, considering it's probably the only Windows browser that will let you do even half of what IE allows.

Use the tools available, and don't worry so much about what's going on behind the curtain. IE works fine on most sites, and in some cases it's the only thing that can be used to do it.

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

Thank you for clarification. :)

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

from what ive read last evening - just to add to the conversation... 'selenium web driver' is a web browing testing framework that works with several major browsers across several os's. how it works is by talking to each browser through its published automation api - all of which may be different. so that you script once in 'selenium' and selenium transfers to the appropriate native browser (to be tested) automation api. selenium web driver has bindings to several major languages, java, php, perl, c#, unfortunately no bindings to 'autoit' at this time.

yesterday, i tried searching for 'autoit internet explorer' scripts or tutorials, and many of the examples dont actually run, bombing with various syntax errors.

can anyone suggest any urls where the majority of the autoit internet explorer sample/tutorial scripts actually work? this would be helpful as im a total newbie with ie.au3

thanks in advance...

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