r4b1dm0nk3y Posted March 9, 2012 Share Posted March 9, 2012 Hello, In my script I need to check which keypress option is available. If keypress option ALT+ol available then do 'x' or if keypress option ALT+on available then do 'y'. Make sense? Basically I'm running a recorded keypress script. If ALT+on is not a choice in the running program then I need the script to do a different routine or it will pause. Is this possible? Link to comment Share on other sites More sharing options...
Blue_Drache Posted March 9, 2012 Share Posted March 9, 2012 And what game are you using it on? Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
r4b1dm0nk3y Posted March 10, 2012 Author Share Posted March 10, 2012 It's not for a game. I'm using the script as a part of our uninstall process for McAfee AV at work. I need to unlock the local console then disable the a setting using the keypresses. ALT+on equals 'Tools>Unlock User Interface.' ALT+ol equals 'Tools>Lock User Interface.' I need the script to detect if the VirusScan Console it locked or unlocked, then do other key presses to disable finish the process. When the user interface is locked the option lock user interface is grayed out and vice versa. When my current script runs on a machine that is unlocked it hangs because ALT+on (the command is really hold ALT then press 'o' then press 'n'. The recorder sees it as ALT+on) Link to comment Share on other sites More sharing options...
Blue_Drache Posted March 10, 2012 Share Posted March 10, 2012 (edited) Oh. Well, is using Send() the ONLY way to do it? Could you use some sort of ControlSend() instead? Also, try using a tiny sleep between commands if Send() is the only way. Example: Send("!o") Sleep(100) Send("!n") Edit: If I seemed rude with my question, it's a combination of various factors that made me ask it. Your name, specifically, the way it's spelled, for one. Second, most flash games resist automation, forcing a user to resort to brute force key-mashing. Third ... you had 2 posts at the time. Edited March 10, 2012 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
r4b1dm0nk3y Posted March 11, 2012 Author Share Posted March 11, 2012 (edited) No hard feelings. I should have put more detail in my original post. Anyway, after doing a bit or research it looks like there are maybe a few possibilities using Control() functions, specifically I'm going to try ControlCommand(). Below is my script, but its not working. I get an error '"If" statements must have a "Then" keyword.' I'm not sure wher my syntax problem is. expandcollapse popup; --- Change log --- Version 2 --- ; v1 - Detect OS archirecture then execute function. Setup keypresses to unlock interface ; v2 - Setup script to deltect if console is locked or unlock, then choose action to complete process. ; ---- Detect System OS Architecture ---- ; This section check if the OS is running x86 or x64 bit Windows. If the machine detect x86 or x64 OS it will execute ; commands for that Windows version. x86 will execute programs from C:Program Files and x64 will execute ; programs from C:Program Files (x86). Switch @OSArch Case "x86" ; Do stuff for x86 _x86() Case "x64" ; Do stuff for x64 _x64() Case Else MsgBox(16, "Error", "Unhandled case: CPU architecture not recognized." & @CRLF & "Please notify your system administrator!") Exit EndSwitch Func _x86() ; ---- Disable McAfee Access Protection ---- ; This section will run McAfee VirusScan Console to disable Access Protection via program ; execution, then using keyboard (ALT + <key>) #region ---Au3Recorder generated code Start --- Opt("WinWaitDelay",100) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) Run('C:Program FilesMcAfeeVirusScan Enterprisemcconsol.exe') _WinWaitActivate("VirusScan Console","") If ControlCommand ( "VirusScan Console", "Lock User Interface", "{ALTDOWN}ol{ALTUP}" , "IsVisible", "" ) ; Checks if console is unlocked Then Send("{F4}{ALTDOWN}{F4}{ALTUP}") ; Stops selected option, then exits the console ElseIf ControlCommand ( "VirusScan Console", "Unlock User Interface", "{ALTDOWN}on{ALTUP}" , "IsVisible", "" ) ; Checks is console is locked Then Send("{ALTDOWN}on{ALTUP}") ; Selects the 'Unlock User Interface option _WinWaitActivate("Login","The user interface i") Send("<password_here>") ; Enters console password to unlock interface _WinWaitActivate("VirusScan Console","") Send("{F4}{ALTDOWN}{F4}{ALTUP}") ; Stops selected option, then exits the console Else MsgBox(0, "Error!", "The script has encountered an error. Please check the console configuration and try again!") Then Send("{ALTDOWN}{F4}{ALTUP}") ; Exits the console EndIf #region --- Internal functions Au3Recorder Start --- #endregion --- Internal functions Au3Recorder End --- #endregion --- Au3Recorder generated code End --- EndFunc ;==>_x86 Func _x64() ; ---- Disable McAfee Access Protection ---- ; This section will run McAfee VirusScan Console to disable Access Protection via program ; execution, then using keyboard (ALT + <key>) #region ---Au3Recorder generated code Start --- Opt("WinWaitDelay",100) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) Run('C:Program Files (x86)McAfeeVirusScan Enterprisemcconsol.exe') _WinWaitActivate("VirusScan Console","") If ControlCommand ( "VirusScan Console", "Lock User Interface", "{ALTDOWN}ol{ALTUP}" , "IsVisible", "" ) ; Checks if console is unlocked Then Send("{F4}{ALTDOWN}{F4}{ALTUP}") ; Stops selected option, then exits the console ElseIf ControlCommand ( "VirusScan Console", "Unlock User Interface", "{ALTDOWN}on{ALTUP}" , "IsVisible", "" ) ; Checks is console is locked Then Send("{ALTDOWN}on{ALTUP}") ; Selects the 'Unlock User Interface option _WinWaitActivate("Login","The user interface i") Send("<password_here>") ; Enters console password to unlock interface _WinWaitActivate("VirusScan Console","") Send("{F4}{ALTDOWN}{F4}{ALTUP}") ; Stops selected option, then exits the console Else MsgBox(0, "Error!", "The script has encountered an error. Please check the console configuration and try again!") Then Send("{ALTDOWN}{F4}{ALTUP}") ; Exits the console EndIf #region --- Internal functions Au3Recorder Start --- #endregion --- Internal functions Au3Recorder End --- #endregion --- Au3Recorder generated code End --- EndFunc ;==>_x64 Func _WinWaitActivate($title,$text,$timeout=0) WinWait($title,$text,$timeout) If Not WinActive($title,$text) Then WinActivate($title,$text) WinWaitActive($title,$text,$timeout) EndFunc Also, I'm not sure what 'controlID' in Control() should be or how exactly they work. I read the examples but it just not clicking. Edited March 11, 2012 by r4b1dm0nk3y Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted March 12, 2012 Moderators Share Posted March 12, 2012 Hi, r4b1dm0nk3y. Have you checked for silent uninstall options? Check the registry under HKLMSOFTWAREMicrosoftWindowsCurrentVersionUninstall, and look through the folders for your product. McAfee bundles most of its products into an MSI nowadays, which should allow you to silently remove it. For example, the silent uninstall string for version 8.7 would be something like this.ShellExecute("msiexec.exe", '/x "{147BCE03-C0F1-4C9F-8157-6A89B6D2D973}" /qn') "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
r4b1dm0nk3y Posted March 12, 2012 Author Share Posted March 12, 2012 @JLogan3o13, The actual uninstall is being handled by the new AV and it works well. I just need to unlock the console so the uninstall process can kickoff. The console needs to be unlocked so I can disable McAfee Access Protection. We have it configured to prevent any modification to McAfee files, processes and regkeys. Link to comment Share on other sites More sharing options...
r4b1dm0nk3y Posted March 12, 2012 Author Share Posted March 12, 2012 I figured out my syntax problems. Now I just need to properly detect the available key presses. Link to comment Share on other sites More sharing options...
Blue_Drache Posted March 12, 2012 Share Posted March 12, 2012 ControlGetText()? Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
r4b1dm0nk3y Posted March 12, 2012 Author Share Posted March 12, 2012 I'm trying to use the AutoIT Window Info Tool and to gather more information about the controls but the particular toolbar I need info on is in an inactive state when using these apps. This is because the VirusScan window is not active. When I click out if the VirsScan window the toolbar menu goes inactive with the window. Is there any way around this or another way to capture this info? Is it possible to read info on inactive toolbars? Link to comment Share on other sites More sharing options...
r4b1dm0nk3y Posted March 12, 2012 Author Share Posted March 12, 2012 @Blue_Drache I don't think ControlGetText() will work as it cannot tell the status of the option, enabled or disabled. I think the best command for this is ControlCommand() but I can;t get it to work properly I figured out the menu options I need to use as commands, I think. "T&ools", "&Lock User Interface" and "U&nlock User Interface". The difficulty with what I need to do is partly due to the fact that I need to check if an option is enabled in the sub-menu. Is there a way I can do this using "WinMenuSelectItem()" to open the menu then ControlCommand() or some Control() variant to check the sub-menu options? Or should I beable to read a sub-menu using a Control() variant? Link to comment Share on other sites More sharing options...
Blue_Drache Posted March 12, 2012 Share Posted March 12, 2012 WinMenuSelectItem() may not work correctly for reasons stated in the help file. That's also why I suggested ControlGetText() to see if it's there. Maybe since it's not exactly a standard control... it may not work. I'm sort of at a loss here, since I don't like/use McAfee Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
r4b1dm0nk3y Posted March 13, 2012 Author Share Posted March 13, 2012 @Blue_Drache, the issue here is not McAfee. This issue is how I can (or not) properly code the script to do what I need it to. The fault does not lie with the application, rather my inexperience with AutoIT. There is a way to make the script do what I need it to, I just don't have the knowledge to make it happen. This is where I look to the community for guidance. I'm not gonna simply write this off as issue with my application. The principles which I am seeking can be use in any application if applied properly.I've been looking up and down the forums looking for ideas and other posts similar to mine, and I've learned a lot in the process, but I need help figuring the best method to attack this. There seems to be a few way this may work using ControlGetText(), ControlCommand() or something similar, but I need help working it out. I cannot accept failure. Link to comment Share on other sites More sharing options...
DW1 Posted March 13, 2012 Share Posted March 13, 2012 post some screens of your win info tool. Is the question "How do I detect if a menuitem is enabled" or "How do I detect if a menu item is checked"? AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 13, 2012 Moderators Share Posted March 13, 2012 r4b1dm0nk3y,Attach your image to the post itself - you can do this when you press the "More Reply Options" button. Trying to add it to "Downloads" area is not the way to do it. 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...
r4b1dm0nk3y Posted March 13, 2012 Author Share Posted March 13, 2012 @Melba23, Thanks for the pointer.@danwilli, The question is how to detect if one of two sub-menu items is enabled. I have attache two screen shots, one with the info tool with mcafee console in view and one of the sub menu. I need to check if "Tools>Unlock User Interface" or "Tools>Lock User Interface" option is enabled. Link to comment Share on other sites More sharing options...
Mechaflash Posted March 13, 2012 Share Posted March 13, 2012 maybe try a ControlFocus(). Test it on an enabled control and a disabled one to make sure it works with the window. If a control is disabled, this should return 0 Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
r4b1dm0nk3y Posted March 14, 2012 Author Share Posted March 14, 2012 (edited) Does this look correct? I think I'm doing something wrong. When the script runs I always get the message box so perhaps I've made an error? Func _x64() ; ---- Disable McAfee Access Protection ---- ; This section will run McAfee VirusScan Console to disable Access Protection via program ; execution, then using keyboard (ALT + <key>) #region ---Au3Recorder generated code Start --- Opt("WinWaitDelay",100) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) Run('C:\Program Files (x86)\McAfee\VirusScan Enterprise\mcconsol.exe') _WinWaitActivate("VirusScan Console","") If ControlFocus ( "", "", "&Lock User Interface") Then ; Checks if console is unlocked Send("{F4}{ALTDOWN}{F4}{ALTUP}") ; Stops selected option, then exits the console ElseIf ControlFocus( "", "", "U&nlock User Interface") Then ; Checks is console is locked Send("{ALTDOWN}on{ALTUP}") ; Selects the 'Unlock User Interface option _WinWaitActivate("Login","The user interface i") Send("<password_here>") ; Enters console password to unlock interface _WinWaitActivate("VirusScan Console","") Send("{F4}{ALTDOWN}{F4}{ALTUP}") ; Stops selected option, then exits the console Else MsgBox(0, "Error!", "The script has encountered an error. Please check the console configuration and try again!") ; Creates a message box with error message Send("{ALTDOWN}{F4}{ALTUP}") ; Exits the console EndIf #region --- Internal functions Au3Recorder Start --- #endregion --- Internal functions Au3Recorder End --- #endregion --- Au3Recorder generated code End --- EndFunc ;==>_x64 Func _WinWaitActivate($title,$text,$timeout=0) WinWait($title,$text,$timeout) If Not WinActive($title,$text) Then WinActivate($title,$text) WinWaitActive($title,$text,$timeout) EndFunc Do I need to open the "T&ools" menu first before looking for "&Lock User Interface" or "U&nlock User Interface"? Edited March 14, 2012 by r4b1dm0nk3y Link to comment Share on other sites More sharing options...
Mechaflash Posted March 14, 2012 Share Posted March 14, 2012 (edited) You're attempting to automate a login for an application. This practice is against the terms of this forum.See hereBy how it sounds, you're in an enterprise environment, and what you're doing may not be wrong or bad, however this forum just doesn't allow discussions of login automation for certain reasons. I'm sorry Edit: If one of the moderators deem this specific thread okay, then it wouldn't be a problem. Not sure which way they'll go on it. Edited March 14, 2012 by mechaflash213 Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
Developers Jos Posted March 14, 2012 Developers Share Posted March 14, 2012 (edited) You're attempting to automate a login for an application. This practice is against the terms of this forum.Edit: If one of the moderators deem this specific thread okay, then it wouldn't be a problem. Not sure which way they'll go on it.Don't think our rules state this.It states:SPAM tools including instant messenger or forum auto-posters. This includes forum or site auto-login methods Edited March 14, 2012 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. 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