Whysilvers Posted January 3, 2014 Posted January 3, 2014 Hi everyone, I am super new with autoit. Basically, i just learned it today. And I have done some experiments. Right now, i am looking for the solution to work with multiple windows by using one script only. For example, My software name is "MSO" Functions: Execute F2 and ALT+2 and my script is HotKeySet("{ESC}", "MyExit") Func MyExit() Exit EndFunc While 1 ControlSend ( "MSO", "", "", "{f2}") Sleep(800) ControlSend ( "MSO, "", "", "!2") sleep (500) WEnd My current problem is, it works in one window only. and that window must be presented on the screen (must not be hidden, but can be inactive). So how to solve the problem?? I would appreciate if all of you can help me to solve the problem. Rgds, yo
Whysilvers Posted January 3, 2014 Author Posted January 3, 2014 What i mean is that I wanted to run 2 MSO windows, and use only one script. Is it possible?
Moderators Melba23 Posted January 3, 2014 Moderators Posted January 3, 2014 Whysilvers,Use the handles of the 2 windows to differentiate them - then you can use the same script to address them both. 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
Whysilvers Posted January 3, 2014 Author Posted January 3, 2014 Whysilvers, Use the handles of the 2 windows to differentiate them - then you can use the same script to address them both. M23 Thanks for reply. How to get handles? As i used AutoItv3 window info to search the info, in the "handle" column doesn't have any detail. and the all the windows that i opened have same name, MSO. would you mind guide me a little bit? Thanks
Moderators Melba23 Posted January 3, 2014 Moderators Posted January 3, 2014 Whysilvers,Use WinList to get the handles of the 2 windows named "MSO" - then you can use these handles in place of the "title" parameter when using other functions. 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
Whysilvers Posted January 5, 2014 Author Posted January 5, 2014 Whysilvers, Use the handles of the 2 windows to differentiate them - then you can use the same script to address them both. M23 Dear Melba, Thanks for your help. You really guided me a lot. and now the things go further a bit. Right now I managed to get the window handle. and need to do some improvement. Basically, i can get handle into the script. but how to ask the script run all the existing "MSO" windows? Here is my script HotKeySet("{ESC}", "MyExit") Local $aWinList = WinList ("[REGEXPTITLE:(?i)(.*MSO)]") Func MyExit() Exit EndFunc While 1 If ControlSend ( "$aWinList[1[1", "", "", "{f2}") Then Sleep(100) EndIf If ControlSend ( "$aWinList[1[1", "", "", "!+2") Then sleep (300) EndIf WEnd As you can see, now i am only able to run 1st window only. One more thing, i discovered that when i run the script, it affect my normal function as well. the F2 function keep disturbing my active windows. Hope you can guide me to improve my script. Thanks
Bert Posted January 5, 2014 Posted January 5, 2014 what does MSO stand for? I did a google search and I found everything from Martha Steward to this: http://forums.bistudio.com/showthread.php?114001-Multi-Session-Operations-v3-3-is-released! The Vollatran project My blog: http://www.vollysinterestingshit.com/
Whysilvers Posted January 5, 2014 Author Posted January 5, 2014 sorry. i just use MSO as an example. i'm trying to write a automator to assist me on changing typing language for my company software.
Bert Posted January 5, 2014 Posted January 5, 2014 Are you changing the language when you run the installer or after the application has been installed on the PC? If it is after the software has been installed have you looked to see where the software keeps it settings? Is it an INI file? Registry? If it is kept in either one of those places then it is easy to make the change you need. For modifying the INI file, look at INIRead, INIWrite in the AutoIt help file. For the registry look at RegRead and RegWrite in the AutoIt help file. The Vollatran project My blog: http://www.vollysinterestingshit.com/
Whysilvers Posted January 7, 2014 Author Posted January 7, 2014 Basically, i solved the Handles issue. However, even I have the Handles, why the controlsend fuction doesn't work? I need to exit the script, manually key in handle into Controlsend "xxxxxx". Then it will work. How to make the script automatically get the handle, put into controlsend's title, and work immediately? thanks
Moderators Melba23 Posted January 7, 2014 Moderators Posted January 7, 2014 Whysilvers,Post the code you have tried - perhaps we can see why it is not working. M23P.S. When you post code please use Code tags - see here how to do it. 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
Whysilvers Posted January 8, 2014 Author Posted January 8, 2014 Here is my code which i need to key in handle later on expandcollapse popupHotKeySet("{ESC}", "MyExit") HotKeySet ("!a", "getWinList") HotkeySet ("!c", "Start") Local $aWinList Global $nowin Func MyExit() Exit EndFunc Func getWinList() $aWinList = Winlist ("[REGEXPTITLE:MSO]") $nowin = $aWinList[1][1] MsgBox(0, "Handle", "The handle has been set to " & $nowin) EndFunc Func Start() MsgBox(64,"INFO", "start function") While 1 ControlSend ( "$nowin", "", "q") Sleep(700) ControlSend ( "$nowin", "", "", "\") EndIf sleep (200) WEnd EndFunc While 1 sleep(150) WEnd and also, how to let this script to send "controlsend" to 2 windows? as i 've tried ControlSend ( "0x00002222 AND 0x0003333", "", "q") Sleep(700) ControlSend ( "0x00002222 AND 0x0003333", "", "", "\") also cannot work. and i tried to separate windows 1 and windows 2 into 2 functions, by setting 2 Hotkeyset. when i activate both, the latest one will work, and the previous one won't work. thanks in advance
Moderators Melba23 Posted January 8, 2014 Moderators Posted January 8, 2014 WhySilvers,You need to learn about arrays! I suggest starting with the Arrays tutorial in the Wiki. Open 2 Notepad windows and run this - it shows how you deal with multiple windowsexpandcollapse popup#include <Array.au3> ; Just for display of the window array HotKeySet("{ESC}", "MyExit") HotKeySet("!a", "getWinList") HotKeySet("!c", "Start") Global $aWinList While 1 Sleep(10) WEnd Func MyExit() Exit EndFunc ;==>MyExit Func getWinList() ; Match windows with MSO as a substring in the title $iOldMode = Opt("WinTitleMatchMode", 2) ; Get an array of the matching windows $aWinList = WinList("Notepad") ; Reset the mode Opt("WinTitleMatchMode", $iOldMode) ; Just to show you what we get _ArrayDisplay($aWinList, "", Default, 8) EndFunc ;==>getWinList Func Start() MsgBox(64, "INFO", "start function") ; Loop through the array of matching windows For $i = 1 To $aWinList[0][0] ; Extract the handle from the array $hWnd = HWnd($aWinList[$i][1]) ; Now run a minimize/restore cycle on each Notepad window to show that it works for each WinSetState($hWnd, "", @SW_MINIMIZE) Sleep(1000) WinSetState($hWnd, "", @SW_RESTORE) Sleep(1000) Next EndFunc ;==>StartPlease ask if you have any questions. 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
Whysilvers Posted January 11, 2014 Author Posted January 11, 2014 WhySilvers, You need to learn about arrays! I suggest starting with the Arrays tutorial in the Wiki. Open 2 Notepad windows and run this - it shows how you deal with multiple windows expandcollapse popup#include <Array.au3> ; Just for display of the window array HotKeySet("{ESC}", "MyExit") HotKeySet("!a", "getWinList") HotKeySet("!c", "Start") Global $aWinList While 1 Sleep(10) WEnd Func MyExit() Exit EndFunc ;==>MyExit Func getWinList() ; Match windows with MSO as a substring in the title $iOldMode = Opt("WinTitleMatchMode", 2) ; Get an array of the matching windows $aWinList = WinList("Notepad") ; Reset the mode Opt("WinTitleMatchMode", $iOldMode) ; Just to show you what we get _ArrayDisplay($aWinList, "", Default, 8) EndFunc ;==>getWinList Func Start() MsgBox(64, "INFO", "start function") ; Loop through the array of matching windows For $i = 1 To $aWinList[0][0] ; Extract the handle from the array $hWnd = HWnd($aWinList[$i][1]) ; Now run a minimize/restore cycle on each Notepad window to show that it works for each WinSetState($hWnd, "", @SW_MINIMIZE) Sleep(1000) WinSetState($hWnd, "", @SW_RESTORE) Sleep(1000) Next EndFunc ;==>Start Please ask if you have any questions. M23 Wow!!! IT worKs flawlessly. thanks a lot for your help. You really solve my frustration. Million thanks again!
Moderators Melba23 Posted January 11, 2014 Moderators Posted January 11, 2014 Whysilvers,Glad I could help. 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
Whysilvers Posted January 14, 2014 Author Posted January 14, 2014 I want to do some improvement on my script. Basically, i want everything run normally. and i want after certain period, the script will press F5 to refresh. But when i tried to use sleep (xxx), it paused the whole script and the script won't run for xxx mil second. is there any better way i can use to replace sleep () ? thanks
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