Donnovan Posted June 11, 2011 Posted June 11, 2011 (edited) I leave my work and AutoIt continues running all night since i return on the next day and stop it by clicking on the Autoit icon in the system tray. My worry is if someone press any key of the keyboard or mouse button in my ausence, causing the script to fail. There is a way to block keyboard and/or mouse until someone (in most cases, me) click on the Autoit icon on the system tray and stop the script? Thanks a lot! Edited June 11, 2011 by Donnovan
guinness Posted June 11, 2011 Posted June 11, 2011 In the Help File search for enable/disable mouse and keyboard. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
wakillon Posted June 12, 2011 Posted June 12, 2011 Instead of Block Input , hide icon and create a Hotkey for exit script. #NoTrayIcon HotKeySet ( "{ESC}", "_Exit" ) ; your script Func _Exit ( ) Exit EndFunc AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
Donnovan Posted June 13, 2011 Author Posted June 13, 2011 (edited) Thanks for the answers! Things are changing. Firstly i was unable to use the computer when AutoIt was running, since any key pressed was able to make the script stop or write in the wrong windows or delete the wrong cell, etc... expandcollapse popupDim $contador1 = 0 Dim $sevNum = "" Dim $check = "" Dim $answer = 0 Dim $linha[13][3] Dim $opc[3] Dim $x = 0 Dim $y = 0 Dim $z = 0 Dim $rep = 0 Dim $end = "" Dim $delay = 0 $delay = 5 ; demora entre os toques de tecla (em milisegundos) $rep = 20000 ; número de SEV's à pegar $end = "1328630" ; ultima SEV da lista For $contador1 = 1 to $rep clipput("") Opt("SendKeyDelay", $delay) Opt("SendKeyDownDelay", 5) WinActivate("[CLASS:XLMAIN]") send("{F2}{SHIFTDOWN}{HOME}{SHIFTUP}^c{ESC}") $sevNum=Clipget() While $sevNum="" sleep(5) $sevNum = clipget() WEnd WinActivate("[CLASS:IEFrame]") clipput("") send("q") sleep(80) send("^c") While clipget()="" sleep(5) WEnd If StringInStr(clipget(),"TIPO DE CAMPO INCORRETO!")=0 Then Exit Endif send("{ENTER}") send($sevNum&"{ENTER}") $check="" $x=1 while $check<>"Aguardando" And $x<=70 Sleep(5) $check=stringleft(StatusbarGetText("[CLASS:IEFrame]"),10) $x=$x+1 WEnd while $check<>"Concluído" Sleep(5) $check=StatusbarGetText("[CLASS:IEFrame]") WEnd Sleep(30) send("^c") Sleep(30) If StringInStr(clipget(),"REGISTRO NÃO ENCONTRADO!")<>0 Then Send("{ENTER}") Endif clipput("Valor estimado (Projeto Solução)") send("^f^v") sleep(20) If ControlGetText("[CLASS:IEFrame]", "", "Static3") = "Nenhuma correspondência encontrada" Then send("{ALTDOWN}{CTRLDOWN}{TAB 3}{CTRLUP}{ALTUP}{TAB}") WinActivate("[CLASS:XLMAIN]") send("{DOWN}") Else For $x = 1 to 3 clipput("Opção de Nro.: "&$x) send("^f{SHIFTDOWN}{HOME}{SHIFTUP}{DEL}^v") sleep(20) $opc[$x-1]=ControlGetText("[CLASS:IEFrame]", "", "Static3") Next send("{ALTDOWN}{CTRLDOWN}{TAB 3}{CTRLUP}{ALTUP}{TAB 9}") Sleep(40) send("^c") sleep(20) $linha[0][0]=clipget() send("{TAB}^c") Sleep(20) $linha[1][0]=clipget() send("{TAB}^c") Sleep(20) $linha[2][0]=clipget() send("{TAB}^c") Sleep(20) $linha[3][0]=clipget() send("{TAB}^c") Sleep(20) $linha[4][0]=clipget() send("{TAB}^c") Sleep(20) $linha[5][0]=clipget() send("{TAB}^c") Sleep(20) $linha[6][0]=clipget() send("{TAB}^c") Sleep(20) $linha[7][0]=clipget() send("{TAB 39}^c") Sleep(20) if $linha[7][0]=clipget() Then send("{TAB}^c") sleep(20) EndIf $linha[8][0]=clipget() send("{TAB}^c") Sleep(20) $linha[9][0]=clipget() send("{TAB}^c") Sleep(20) $linha[10][0]=clipget() send("{TAB 5}{SHIFTDOWN}{PGDN}{SHIFTUP}^c") Sleep(20) $linha[11][0]=clipget() For $x = 1 to 2 If $opc[$x] <> "Nenhuma correspondência encontrada" Then send("{TAB}^c") sleep(20) if $linha[11][$x-1]=clipget() Then send("{TAB}^c") sleep(20) EndIf $linha[8][$x]=clipget() send("{TAB}^c") Sleep(20) $linha[9][$x]=clipget() send("{TAB}^c") Sleep(20) $linha[10][$x]=clipget() send("{TAB 5}{SHIFTDOWN}{PGDN}{SHIFTUP}^c") Sleep(20) $linha[11][$x]=clipget() EndIf Next clipput("") send("{TAB}{SHIFTDOWN}{PGDN}{SHIFTUP}^c") Sleep(20) $linha[12][2]=clipget() send("{ALTDOWN}{LEFT}{ALTUP}") sleep(50) send("^c") sleep(20) If StringInStr(clipget(),"REGISTRO NÃO ENCONTRADO!")<>0 Then Send("{ENTER}") Endif send("{SHIFTDOWN}{HOME}{SHIFTUP}{DEL}") sleep(20) WinActivate("[CLASS:XLMAIN]") send("{RIGHT}") Sleep(10) For $x = 0 to 7 clipput($linha[$x][0]) Sleep(10) send("{DEL}{F2}^v{ENTER}{UP}{RIGHT}") next $z=8 For $x = 0 to 2 If $opc[$x]<>"Nenhuma correspondência encontrada" Then For $y = 8 to 11 clipput($linha[$y][$x]) if $y=11 Then send("{DEL}{F2}^v{ENTER}{UP}{ALT}cel{ENTER}{RIGHT}") Else send("{DEL}{F2}^v{ENTER}{UP}{RIGHT}") EndIf $z=$z+1 Next EndIf next clipput($linha[12][2]) If $z <20 Then send("{RIGHT " & 21-$z-1 & "}{DEL}{F2}^v{ENTER}{UP}{ALT}cel{ENTER}") Else send("{DEL}{F2}^v{ENTER}{UP}{ALT}cel{ENTER}") EndIf Send("{HOME}") Sleep(35) Send("{DOWN}") EndIf Sleep(30) WinActivate("[CLASS:SciTEWindow]") if $sevNum=$end Then Exit EndIf Next But now, using _IE and and Object Excel Management, i believe i can run autoit with invisible windows and continue to do paralel work. So the problem will be solved since people can use the computer normally with no interference with AutoIt: Here the progress: expandcollapse popup#include <IE.au3> $rep = 100 $oExcel = ObjGet("","Excel.Application") $oIE = _IEAttach ("", "instance", 1) ;$oIE = _IECreate("http://ntspo912/ssa/Scripts/Mev_ConsSolFinal.asp") _IENavigate ($oIE,"http://ntspo912/ssa/Scripts/Mev_ConsSolFinal.asp") While 1 $oForm = _IEFormGetCollection ($oIE,0) $oInput = _IEFormElementGetCollection ($oForm,2) $oSubmit = _IEFormElementGetCollection ($oForm,3) $oInput.Value = $oExcel.Activecell.Value _IEAction ($oSubmit, "click") _IELoadWait ($oIE) If WinExists("[CLASS:#32770]") Then WinClose("[CLASS:#32770]", "") ElseIf _IEPropertyGet ($oIE, "locationurl") <> "http://ntspo912/ssa/Scripts/Mev_ConsSolFinal.asp" Then ExitLoop EndIf $oExcel.Activecell.Offset(1,0).Select WEnd For $x = 1 to $rep $oForm = _IEFormGetCollection ($oIE,0) MsgBox(0,"",@extended) $oElements = _IEFormElementGetCollection ($oForm) $y = 0 For $oElement in $oElements If $oElement.type <> "hidden" Then $oExcel.Activecell.Offset(0,1).Select $oExcel.Activecell.Value = $oElement.value $y = $y + 1 EndIf Next Exit $oExcel.Activecell.Offset(1,-$y).Select While 1 $oForm = _IEFormGetCollection ($oIE,1) $oInput = _IEFormElementGetCollection ($oForm,2) $oSubmit = _IEFormElementGetCollection ($oForm,3) ; $oInput = _IEFormElementGetObjByName ($oForm, "inputsev") ; $oSubmit = _IEFormElementGetObjByName ($oForm, "submitsev") $oInput.Value = $oExcel.Activecell.Value _IEAction ($oSubmit, "click") _IELoadWait ($oIE) If WinExists("[CLASS:#32770]") Then WinClose("[CLASS:#32770]", "") ElseIf _IEPropertyGet ($oIE, "locationurl") <> "http://ntspo912/ssa/Scripts/Mev_ConsSolFinal.asp" Then ExitLoop EndIf $oExcel.Activecell.Offset(1,0).Select WEnd Next This second version do the same thing but is way more fast, and i can hide Esxel and IE windows. Thanks! Edited June 13, 2011 by Donnovan
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