nandy12 Posted January 29, 2013 Share Posted January 29, 2013 hi, I am using a simple script to clean up chars in another app. The functions used are winactivate, send, controlcommand -none of which should be waiting but yet I have an OCCASIONAL hang where the script just does not complete execution and the target app too wont respond to any events. Just to be clear, its not that the script hangs every time its invoked but it locks up once in a while. Here is the script: ;clear text if any if WinActivate("MP")==0 Then exit 1 EndIf ;get to the panel Send("!o") Send("a") Sleep(1500) ;v26Jan13. clear and activate Capture app Send("{BS}{BS}{BS}{BS}{BS}{BS}{BS}{BS}{BS}{BS}{BS}") Sleep(1000) WinActivate("Capture") exit 0 -------------- I really need to resolve this ASAP so any pointers appreciated. I run on win XP SP2 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 29, 2013 Moderators Share Posted January 29, 2013 nandy12,What app are you trying to automate - there might well be a better way than using the often unreliable Send. As it seems that you could be trying to empty an input, ControlSetText might be a more useful option. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
nandy12 Posted January 30, 2013 Author Share Posted January 30, 2013 (edited) hi m23, I'm trying to automate the MobilePartner app (Huawei modem GUI). Unfortunately target control is a custom control-something like an editable combo box and I was not sure if controlsetText will work correctly. The finder tool just lists the window handle and the registered window class.{edit: the finder tool does not select the editable portion of the control and only shows class,instance for the listbox portion. I tried using this info with ControlSetText but it does not work] The only explaination I have is that send is getting stuck if the target is busy and not responding to messages-but I am not even sure the target app gets to such a state! More than anything I dont want it to be stuck, failing gracefully would be good enough so maybe sendwithTimeout would be ok too. I want to be sure its only send and that none of the other functions have possibilities of endless waits before I make any changes. tks, nan Edited January 30, 2013 by nandy12 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 30, 2013 Moderators Share Posted January 30, 2013 nandy12,From what you say it sounds as if that is indeed a custom GUI and so not accessible via the Control* functions. However, you can test whether the app has been activated by using WinWaitActive - this includes a timeout so that if your app does not respond you can run some code in your script to indicate that a problem has occurred.What happens to the app GUI when you Send the ("!o") and ("a") codes? Is there a visual change such a menu opening? If so then you might be able to check that this has happened using PixelCheckSum on part of the GUI area affected. If the expected change does not occur then again you can run different code.Does that offer enough to be going on with? Please ask if you are unsure about how to work with any of the commands I mentioned. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
nandy12 Posted January 31, 2013 Author Share Posted January 31, 2013 m23, The Send(!o),send(a) are meant to bring up a specific panel via menu commands. The problem is that if the app is stuck then the first send could end up blocking. PixelgetCheckSum could help me figure if the right panel is already up but it wont tell me if the app is stuck. (pls correct me if thats wrong). Isn't there a send with timeout -maybe sendmessagetimeout win32 fn or equivalent? Ideally I would just want to attempt a send with a timeout. i did seem to see some such code on stackoverflow but can't locate it. Plus I dont want to try my own code without understanding hidden quirks. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 31, 2013 Moderators Share Posted January 31, 2013 nandy12,As the problem seems to be the other app not responding to your script, you might like to try checking that it is responsive using something along these lines before each Send. Then you can abort if the app is not in the mood to play after a certain time (TimerInit/Diff will help here) - assuming that you get a suitable response from the query. M23 nandy12 1 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
nandy12 Posted February 1, 2013 Author Share Posted February 1, 2013 M23, Thanks a lot for your assistance. i will use IsHungAppWindow that you pointed to and get around the problem. Many thank once again! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now