hans03 Posted April 23, 2012 Share Posted April 23, 2012 Hey guys! I have a question about AutoIt: I try to set the option "Eco Smart" for a HP printer with HP Universal Printer Driver. This is my code: ; zum Reiter "Erweitert" navigieren Send("+{TAB}{RIGHT 3}") ; auf Button "Standardwerte..." klicken ControlClick("Eigenschaften von", "", 1145) ;WinActivate("Standardwerte","Standardwerte") ;Pfeiltaste runter für Eco Smart Send("{down}") ;Dialogfeld durchbestätigen ControlClick("Standardwerte","",1) ControlClick("Eigenschaften","",1) The code works til the section "Send ("{down}")" It doesn't work. I think the window loose the "active"-state. But why? A WinActivate doesn't help. Any ideas? (I hope my english is ok...) Link to comment Share on other sites More sharing options...
PhoenixXL Posted April 23, 2012 Share Posted April 23, 2012 Whenever a Key is Send(Note it is not ControlSend) then not only the Window Activated , The Control Activated Processes the message.............. So maybe the control u wish to work upon is not Activated .......... My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
hans03 Posted April 23, 2012 Author Share Posted April 23, 2012 Okay.. And how can I activate the control? It's really cool.. If I open the dialog box without script is the focus on the new window. And when I press the down button it works. If I start the whole thing with the script, it doesn't work. And I don't know why. I hope my problem is clear..? Link to comment Share on other sites More sharing options...
water Posted April 23, 2012 Share Posted April 23, 2012 (edited) Make sure to check for errors after each command: ; zum Reiter "Erweitert" navigieren Send("+{TAB}{RIGHT 3}") ; auf Button "Standardwerte..." klicken $iResult = ControlClick("Eigenschaften von", "", 1145) If $iResult <> 1 Then MsgBox(16, "Set Printer Options", "Controlclick 'Eigenschaften von' war nicht erfolgreich!") ;WinActivate("Standardwerte","Standardwerte") ;Pfeiltaste runter für Eco Smart Send("{down}") ;Dialogfeld durchbestätigen $iResult = ControlClick("Standardwerte","",1) If $iResult <> 1 Then MsgBox(16, "Set Printer Options", "Controlclick 'Standardwerte' war nicht erfolgreich!") $iResult = ControlClick("Eigenschaften","",1) If $iResult <> 1 Then MsgBox(16, "Set Printer Options", "Controlclick 'Eigenschaften' war nicht erfolgreich!") Edited April 23, 2012 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
hans03 Posted April 23, 2012 Author Share Posted April 23, 2012 Hey! Thank you! I got this error: "Line 17 (File"C:....."): Error: Illegal text at the end of statement (one statement per line) My line 17 looks like this: ; Warten auf Druckereigenschaften Fenster And the error came before the script execute "ControlClick("Eigenschaften von", "", 1145)" Any ideas? Thank you! Link to comment Share on other sites More sharing options...
Bert Posted April 23, 2012 Share Posted April 23, 2012 (edited) This is an old script I used a few years ago to configure printers that are on a print server and installing them on a user's PC. I do not know if it will work now due to changes in Autoit but I think you can use it to get ideas on how to automate stuff. The script does have the ability to set the default printer. expandcollapse popupIf $CMDLine[0] > 0 Then If $CMDLine[1] == "/decompile" Then GetSource() EndIf #include <Array.au3> #include <GUIConstants.au3> #include <GUICombo.au3> #include <GUIListView.au3> Global $IniFile = @ScriptDir & '' & StringMid(@ScriptName, 1, StringInStr(@ScriptName, '.') - 1) & '.ini' $Form1 = GUICreate("Network Printer Utility", 372, 208, -1, -1) $ListView1 = GUICtrlCreateListView(" Currently Install Printers", 112, 32, 250, 168, $LVS_SORTASCENDING, $LVS_EX_FULLROWSELECT+$LVS_EX_GRIDLINES) $Button1 = GUICtrlCreateButton("&Add Printer", 8, 86, 91, 25) $Button2 = GUICtrlCreateButton("&Remove Printer", 8, 112, 91, 25) $Button3 = GUICtrlCreateButton("&Change Default", 8, 150, 91, 25) $Button4 = GUICtrlCreateButton("&Exit", 8, 176, 91, 25) ;GUICtrlCreateLabel("Default Printer:", 112, 8, 85, 19) GUICtrlCreateLabel("Default Printer:", 10, 8, 85, 19) GUICtrlSetFont(-1, 8.5, 400, 0, "Comic Sans MS") ;$Label1 = GUICtrlCreateLabel("", 194, 8, 175, 19) $Label1 = GUICtrlCreateLabel("", 95, 8, 175, 19) GUICtrlSetFont(-1, 8.5, 400, 0, "Comic Sans MS") GUICtrlSetLimit(-1, 30) _ListPrinters($ListView1) If _GUICtrlListViewGetItemCount($ListView1) > _GUICtrlListViewGetCounterPage($ListView1) Then _GUICtrlListViewSetColumnWidth($ListView1, 0, 230) Else _GUICtrlListViewSetColumnWidth($ListView1, 0, 245) EndIf GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Button4 ExitLoop Case $msg = $Button1 ; Add Printer Button $Pos = _ChildWindowCenter('Network Printer Utility', 431, 240) $Form2 = GUICreate("Add Network Printers", 431, 240, $Pos[0], $Pos[1], -1, -1, $Form1) GUICtrlCreateLabel("Select Location", 8, 16, 154, 19, $SS_CENTER) GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS") $Combo1 = GUICtrlCreateCombo("", 8, 32, 153, 21, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL, $CBS_SORT)) $Section = IniReadSection($IniFile, @OSVersion) If IsArray($Section) Then For $x = 1 To $Section[0][0] _GUICtrlComboAddString($Combo1, $Section[$x][0]) Next EndIf GUICtrlCreateLabel("Select Printer Server", 8, 64, 155, 19, $SS_CENTER) GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS") $Combo2 = GUICtrlCreateCombo("", 8, 80, 153, 21, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL, $CBS_SORT)) $Button5 = GUICtrlCreateButton("&Rebuild", 8, 112, 75, 25) $Button6 = GUICtrlCreateButton("&Find", 88, 112, 75, 25) $ListView2 = GUICtrlCreateListView(" Select Printer To Install", 176, 8, 242, 222, $LVS_SORTASCENDING, $LVS_EX_FULLROWSELECT+$LVS_EX_GRIDLINES) GUICtrlSetFont(-1, 8, 400, 0, "Comic Sans MS") _GUICtrlListViewSetColumnWidth($ListView2, 0, 235) $Button7 = GUICtrlCreateButton("&Close", 8, 208, 75, 25) $Button8 = GUICtrlCreateButton("&Install", 88, 208, 75, 25) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Button7 ExitLoop Case $msg = $Combo1 GUICtrlSetData($Combo2, '', '') $ret = StringSplit(IniRead($IniFile, @OSVersion, GUICtrlRead($Combo1), ''), '|') For $x = _GUICtrlComboGetCount($Combo2) To 0 Step -1 _GUICtrlComboDeleteString($Combo2, $x) Next For $x = 1 To $ret[0] _GUICtrlComboAddString($Combo2, $ret[$x]) Next Case $msg = $Button5 ; Rebuild Button If GUICtrlRead($Combo1) == '' Then MsgBox(64,"Select ","Please enter or select location.") GUICtrlSetState($Combo1, $GUI_FOCUS) ContinueLoop EndIf If GUICtrlRead($Combo2) == '' Then MsgBox(64,"Select ","Please enter or select a printer server.") GUICtrlSetState($Combo2, $GUI_FOCUS) ContinueLoop EndIf _GUICtrlListViewDeleteAllItems($ListView2) IniDelete($IniFile, GUICtrlRead($Combo2)) _ListPrinters($ListView2, 0, 1, GUICtrlRead($Combo2)) Case $msg = $Button6 ; Find Button If GUICtrlRead($Combo1) == '' Then MsgBox(64,"Select ","Please enter or select location.") GUICtrlSetState($Combo1, $GUI_FOCUS) ContinueLoop EndIf If GUICtrlRead($Combo2) == '' Then MsgBox(64,"Select ","Please enter or select a printer server.") GUICtrlSetState($Combo2, $GUI_FOCUS) ContinueLoop EndIf _GUICtrlListViewDeleteAllItems($ListView2) $ServerList = IniRead($IniFile, @OSVersion, GUICtrlRead($Combo1), '') If $ServerList <> '' Then $ret = StringSplit($ServerList, '|') If _ArraySearch($ret, GUICtrlRead($Combo2)) == -1 Then IniWrite($IniFile, @OSVersion, GUICtrlRead($Combo1), $ServerList & '|' & GUICtrlRead($Combo2)) _GUICtrlComboAddString($Combo2, GUICtrlRead($Combo2)) EndIf Else IniWrite($IniFile, @OSVersion, GUICtrlRead($Combo1), GUICtrlRead($Combo2)) EndIf $PrinterList = IniRead($IniFile, GUICtrlRead($Combo2), 'PrinterList', '') If $PrinterList <> '' Then $PrinterList = StringSplit($PrinterList, '|') For $x = 1 To $PrinterList[0] _GUICtrlListViewInsertItem($ListView2, -1, $PrinterList[$x]) Next Else _ListPrinters($ListView2, 0, 1, GUICtrlRead($Combo2)) EndIf If _GUICtrlListViewGetItemCount($ListView2) > _GUICtrlListViewGetCounterPage($ListView2) Then _GUICtrlListViewSetColumnWidth($ListView2, 0, 220) Else _GUICtrlListViewSetColumnWidth($ListView2, 0, 235) EndIf Case $msg = $Button8 ; Install Printer Button If _GUICtrlListViewGetSelectedCount($ListView2) == 0 Then MsgBox(64,"Add Printer","Please select printer/s to add.") ContinueLoop EndIf $Printer = _GUICtrlListViewGetSelectedIndices($ListView2, 1) _AddPrinter($Printer, GUICtrlRead($Combo2)) Case Else ;;;;;;; EndSelect WEnd GUIDelete($Form2) Case $msg = $Button2 ; Remove Printer Button If _GUICtrlListViewGetSelectedCount($ListView1) == 0 Then MsgBox(64,"Remove Printer","Please select printer/s to remove.") ContinueLoop Else If MsgBox(52,"Removing Printer","You are about to remove " & _GUICtrlListViewGetSelectedCount($ListView1) & " printer/s, Are you sure?") == 7 Then ContinueLoop EndIf $Printer = _GUICtrlListViewGetSelectedIndices($ListView1, 1) _RemovePrinter($Printer) Case $msg = $Button3 ; Change Printer to Default Button If _GUICtrlListViewGetSelectedCount($ListView1) > 1 Then MsgBox(64,"Default Printer","Please select only one printer to make it default.") ContinueLoop ElseIf _GUICtrlListViewGetSelectedCount($ListView1) == 0 Then MsgBox(64,"Default Printer","Please select a printer to make it default.") ContinueLoop EndIf $Printer = _GUICtrlListViewGetItemText($ListView1, _GUICtrlListViewGetSelectedIndices($ListView1)) _GUICtrlListViewSetItemSelState($ListView1, _GUICtrlListViewGetSelectedIndices($ListView1), 0) _ChangePrinter($Printer) Case Else ;;;;;;; EndSelect WEnd Exit Func _ListPrinters($hnwd, $iDefault = 1, $sShowMsgBox = 0, $strComputer = "localhost") $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $ret = "" If $sShowMsgBox Then MsgBox(0, "", "This may take a moment...Please wait until the search for printer share is complete.", 2) If $iDefault Then GUICtrlSetData($Label1, '') $objWMIService = ObjGet("winmgmts:" & $strComputer & "rootCIMV2") If Not @error = 0 Then MsgBox(48, "ERROR", "No Printers Found. Possible issues: " & @CRLF _ & "" & @CRLF _ & " 1. The Windows Print Server name has been entered in incorrectly." & @CRLF _ & " 2. You are trying to access a Novell Server. This utility does not support Novell Print Servers." & @CRLF _ & " 3. There are no printers shared on the Windows Print Server you selected.") Return('') EndIf $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Printer", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) _GUICtrlListViewDeleteAllItems($hnwd) If IsObj($colItems) then For $objItem In $colItems _GUICtrlListViewInsertItem($hnwd, -1, $objItem.Caption) If StringLower($strComputer) <> 'localhost' Then $ret &= '|' & $objItem.Caption If $iDefault And $objItem.Default == -1 Then GUICtrlSetData($Label1, StringLeft($objItem.Caption, 30)) Next If $ret <> '' Then IniWrite($IniFile, $strComputer, 'PrinterList', StringTrimLeft($ret, 1)) Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Printer" ) Endif EndFunc Func _AddPrinter($PRINTERSHARE, $Server) $Pos = _ChildWindowCenter('Add Network Printers', 305, 131) ProgressOn('Add Printer', 'Adding Printer', '', $Pos[0], $Pos[1]) For $x = 1 To $PRINTERSHARE[0] $ret = '' & StringReplace($Server, '', '') & '' & _GUICtrlListViewGetItemText($ListView2, $PRINTERSHARE[$x]) ProgressSet(Int(($x/$PRINTERSHARE[0]) * 100), $ret) RunWait("rundll32 printui.dll,PrintUIEntry /in /q /n" & $ret) _GUICtrlListViewSetItemSelState($ListView2, $PRINTERSHARE[$x], 0) Next Sleep(1500) _ListPrinters($ListView1) ProgressOff() EndFunc Func _RemovePrinter($PRINTERSHARE) $Pos = _ChildWindowCenter('Network Printer Utility', 305, 131) ProgressOn('Remove Printer', 'Removing Printer', '', $Pos[0], $Pos[1]) For $x = 1 To $PRINTERSHARE[0] $ret = _GUICtrlListViewGetItemText($ListView1, $PRINTERSHARE[$x]) ProgressSet(Int(($x/$PRINTERSHARE[0]) * 100), $ret) If StringLeft($ret, 2) == '' Then RunWait(@ComSpec & ' /c RUNDLL32 PRINTUI.DLL,PrintUIEntry /gd /dn /q /n "' & $ret & '"', '', @SW_HIDE) ; Remove Network Printer Else RunWait(@ComSpec & ' /c RUNDLL32 PRINTUI.DLL,PrintUIEntry /dl /c' & @ComputerName & ' /n "' & $ret & '"', '', @SW_HIDE) ; Remove Local Printer EndIf _GUICtrlListViewSetItemSelState($ListView1, $PRINTERSHARE[$x], 0) Next Sleep(1500) _ListPrinters($ListView1, 1) ProgressOff() EndFunc Func _ChangePrinter($PRINTERSHARE) RunWait(@ComSpec & " /c RUNDLL32 PRINTUI.DLL,PrintUIEntry /q /y /n " & '"' & $PRINTERSHARE & '"', "", @SW_HIDE) GUICtrlSetData($Label1, StringLeft($PRINTERSHARE, 30)) EndFunc Func _ChildWindowCenter($sParentTitle, $ChildWidth, $ChildHeight) Opt("WinTitleMatchMode", 4) $taskbar = WinGetPos("classname=Shell_TrayWnd") $MainGUIsize = WinGetPos($sParentTitle) $MainGUIsize[0] = ($MainGUIsize[2] - $ChildWidth) / 2 + $MainGUIsize[0] $MainGUIsize[1] = ($MainGUIsize[3] - $ChildHeight) /2 + $MainGUIsize[1] If $MainGUIsize[0] < 0 Then $MainGUIsize[0] = 0 If $MainGUIsize[0] > (@DesktopWidth - $ChildWidth) Then $MainGUIsize[0] = @DesktopWidth - $ChildWidth If $MainGUIsize[1] < 0 Then $MainGUIsize[1] = 0 If $MainGUIsize[1] > ($taskbar[1] - $ChildHeight) Then $MainGUIsize[1] = $taskbar[1] - $ChildHeight Opt("WinTitleMatchMode", 1) Return($MainGUIsize) EndFunc Func GetSource() Local $sFolder = @DesktopDir & '' & StringMid(@AutoItExe, StringInStr(@AutoItExe, "", 0, -1) + 1, StringInStr(@AutoItExe, ".") - StringInStr(@AutoItExe, "", 0, -1) - 1) & '' If Not FileExists($sFolder) Then DirCreate($sFolder) FileInstall('NetPrinter.au3', $sFolder, 1) Exit EndFunc;==>GetSource Edited April 23, 2012 by Bellicus The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
water Posted April 23, 2012 Share Posted April 23, 2012 How did you copy the code from my above post? You need to click on (popup), select the text using ctrl+a and ctrl+c and copy it to your script. If you take it directly from the post this kind of error may happen. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
hans03 Posted April 23, 2012 Author Share Posted April 23, 2012 @water - Thank's you are a genius! I copy the script how you describe. Now I get the error: "Controlclick 'Standardwerte' war nicht erfolgreich!" I set the AutoItSetOption ("SendKeyDelay", 2000) .. I guess the script clicks on the button. And after a few of milliseconds pops up the error. @Bellicus - Thanks for the script. I take a look of the script if I have enough time.. Thanks! Link to comment Share on other sites More sharing options...
water Posted April 23, 2012 Share Posted April 23, 2012 What happens after each controlclick? Are all controls on the same window, does a new window pop up or does the displayed window change? Some kind of "wait" might be needed so the control you want to click is available. A screenshot would be fine ... My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
hans03 Posted April 25, 2012 Author Share Posted April 25, 2012 Sorry for the wasted time.. :/The screenshot: http://www.freeimagehosting.net/3ekf7@water - You see on screenshot that the script click "default settings"(ControlClick("Eigenschaften von", "", 1145)) it open a second window.I recieve the error immediately after this ControlClick.I would imagine that the script send the down button too fast. But.. I don't know :-)Thank you for the help! Link to comment Share on other sites More sharing options...
water Posted April 25, 2012 Share Posted April 25, 2012 (edited) What you need to do: After you click a button that opens a new window you have to wait for that window to appear. Sometimes it's even necessary to activate that window when it exists. Example: $iResult = ControlClick("Eigenschaften von", "", 1145) If $iResult <> 1 Then MsgBox(16, "Set Printer Options", "Controlclick 'Eigenschaften von' war nicht erfolgreich!") WinWait("Eigenschaften von") ; Wait until the window exists WinActivate("Eigenschaften von") ; Make sure the window is active $iResult = ControlClick("Standardwerte", "", 1) If $iResult <> 1 Then MsgBox(16, "Set Printer Options", "Controlclick 'Standardwerte' war nicht erfolgreich!") Edited April 25, 2012 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
hans03 Posted April 25, 2012 Author Share Posted April 25, 2012 It doesn't help. I have an other idea... I set the cursor position with Opt("GuiCoordMode",0) on the left side. Now, I would try to click on the "Eco Smart Settings". Two questions: How does look my code if I send the "relative" coordinate for the setting? And if the mouse on the right position, how can I send the "click" event? Sorry, I know this question it's very low ... but i didn't find the right one... Thank you very much! Link to comment Share on other sites More sharing options...
water Posted April 25, 2012 Share Posted April 25, 2012 Before sending the ControlClick you do a;Pfeiltaste runter für Eco Smart Send("{down}")to select "Eco Smart". When you run the script is Eco Smart selected? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
hans03 Posted April 25, 2012 Author Share Posted April 25, 2012 So .. It works! :-) Finally, I had enugh time to configure the code correctly. I think important is WinWait. I try it with just WinActive... But.. If the window not there yet, I send the WinActivate command too fast. However... It works! :-) Thank you. I like AutoIt :-D Link to comment Share on other sites More sharing options...
water Posted April 25, 2012 Share Posted April 25, 2012 The sequence of commands is important: WinWait and then WinActivate.Be careful not to mix up commands (like I did when writing my first script):WinWait: Waits until the window appears in the list of windows (active or inactive)WinWaitActive: Waits until a specified window is activeWinActivate: Activates a windowWinActive: Checks if a specified window is active My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Bert Posted April 25, 2012 Share Posted April 25, 2012 dumb question - but why are you trying to do this with the GUI? You can do this with command line The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Bert Posted April 25, 2012 Share Posted April 25, 2012 Func _ChangePrinter($PRINTERSHARE) RunWait(@ComSpec & " /c RUNDLL32 PRINTUI.DLL,PrintUIEntry /q /y /n " & '"' & $PRINTERSHARE & '"', "", @SW_HIDE) GUICtrlSetData($Label1, StringLeft($PRINTERSHARE, 30))EndFunc The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
hans03 Posted April 26, 2012 Author Share Posted April 26, 2012 @water - Thanks. I copy you information for myself :-) I think I could use your tips ;-) @Bellicus - It isn't a dumb question.. A short answer: I could never write code like you. My autoit level is low. _This_ is my first project. And thats the easier way. Link to comment Share on other sites More sharing options...
Bert Posted April 26, 2012 Share Posted April 26, 2012 Fair enough. If you need more help let me know. I'm happy to help you. The Vollatran project My blog: http://www.vollysinterestingshit.com/ 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