wisem2540 Posted August 3, 2017 Share Posted August 3, 2017 (edited) Hi all, Is it possible to disable a button or control in an app I did not create? For example, just a random EXIT button in a windows app like office, or adobe? I just want to prevent a user from clicking it Edited August 3, 2017 by wisem2540 Link to comment Share on other sites More sharing options...
spudw2k Posted August 4, 2017 Share Posted August 4, 2017 In theory, yes...but it also depends on the application and the control. To illustrate, here's a crude example that disables the = button on the windows calculator: If Not ProcessExists("calc.exe") Then Run(@SystemDir & "\calc.exe") ProcessWait("calc.exe") $hWnd = WinGetHandle("Calculator") If Not IsHWnd($hWnd) Then Exit ControlDisable($hWnd, "", "Button28") guner7 1 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Simpel Posted August 4, 2017 Share Posted August 4, 2017 Hi. My "="-Button is "Button30". And code above is only working on english speaking systems because of "calculator". But it works. But if I try ControlHide($hWnd, "", "Button30") instead of ControlDisable() it's not working (but returns 1 - meaning success). So your right - in theory. Regards, Conrad SciTE4AutoIt = 3.7.3.0 AutoIt = 3.3.14.2 AutoItX64 = 0 OS = Win_10 Build = 19044 OSArch = X64 Language = 0407/german H:\...\AutoIt3\SciTE H:\...\AutoIt3 H:\...\AutoIt3\Include (H:\ = Network Drive) Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. Link to comment Share on other sites More sharing options...
MattHiggs Posted August 5, 2017 Share Posted August 5, 2017 And I am curious On 8/3/2017 at 11:57 AM, wisem2540 said: Hi all, Is it possible to disable a button or control in an app I did not create? For example, just a random EXIT button in a windows app like office, or adobe? I just want to prevent a user from clicking it I am actually curious about this too. On 8/3/2017 at 8:31 PM, spudw2k said: In theory, yes...but it also depends on the application and the control. To illustrate, here's a crude example that disables the = button on the windows calculator: If Not ProcessExists("calc.exe") Then Run(@SystemDir & "\calc.exe") ProcessWait("calc.exe") $hWnd = WinGetHandle("Calculator") If Not IsHWnd($hWnd) Then Exit ControlDisable($hWnd, "", "Button28") @spudw2k, do you think you could go into a bit more detail as what kinds of control items autoit is able to manipulate (change the state of) like you did with the calculator example and which controls autoit is unable to modify. Link to comment Share on other sites More sharing options...
spudw2k Posted August 7, 2017 Share Posted August 7, 2017 Natively, AutoIt can interact with most "Standard Microsoft Controls". This note in on the Controls help file page. "Note: AutoIt only works with standard Microsoft controls. Some applications write their own custom controls which may look like a standard MS control but may resist automation. Experiment!" There are libraries to interact and UDFs to interact with non-standard controls (.Net for example), but I have little to no experience automating/interacting-with those. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
TheDcoder Posted August 7, 2017 Share Posted August 7, 2017 On 5/8/2017 at 0:09 AM, Simpel said: But if I try ControlHide($hWnd, "", "Button30") instead of ControlDisable() it's not working (but returns 1 - meaning success). So your right - in theory. It works for me: And here is my code: If Not ProcessExists("calc.exe") Then Run(@SystemDir & "\calc.exe") ProcessWait("calc.exe") $hWnd = WinGetHandle("Calculator") If Not IsHWnd($hWnd) Then Exit ControlHide($hWnd, "", "Button28") EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Simpel Posted August 7, 2017 Share Posted August 7, 2017 Funny. It's not working for me. I definitely have to use "Button30" to disable "=" (Win 7). But anyway ControlHide() isn't working. Maybe you need admin privilege? I'm a standard user. Regards, Conrad SciTE4AutoIt = 3.7.3.0 AutoIt = 3.3.14.2 AutoItX64 = 0 OS = Win_10 Build = 19044 OSArch = X64 Language = 0407/german H:\...\AutoIt3\SciTE H:\...\AutoIt3 H:\...\AutoIt3\Include (H:\ = Network Drive) Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. Link to comment Share on other sites More sharing options...
TheDcoder Posted August 7, 2017 Share Posted August 7, 2017 Maybe it depends on the version of Windows, what version are you using? and what edition? 18 minutes ago, Simpel said: Maybe you need admin privilege? I'm a standard user. I ran the script as a standard user too. EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Simpel Posted August 7, 2017 Share Posted August 7, 2017 That is console saying: ConsoleWrite("Arch: " & @OSArch & @CRLF & "Build: " & @OSBuild & @CRLF & "ServicePack: " & @OSServicePack & @CRLF & "Type: " & @OSType & @CRLF & "Version: " & @OSVersion & @CRLF ) Arch: X64 Build: 7601 ServicePack: Service Pack 1 Type: WIN32_NT Version: WIN_7 Conrad SciTE4AutoIt = 3.7.3.0 AutoIt = 3.3.14.2 AutoItX64 = 0 OS = Win_10 Build = 19044 OSArch = X64 Language = 0407/german H:\...\AutoIt3\SciTE H:\...\AutoIt3 H:\...\AutoIt3\Include (H:\ = Network Drive) Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. Link to comment Share on other sites More sharing options...
TheDcoder Posted August 7, 2017 Share Posted August 7, 2017 I am using Windows 8... something must have been changed in the way the APIs work between Win 7 and Win 8 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Neutro Posted August 7, 2017 Share Posted August 7, 2017 (edited) It's working for me also on Win10. Win7, 8 and 10 have the same OS core so it should work for you as well. Edited August 7, 2017 by Neutro Identify active network connections and change DNS server - Easily export Windows network settings Clean temporary files from Windows users profiles directories - List Active Directory Groups members Export content of an Outlook mailbox to a PST file - File patch manager - IRC chat connect example Thanks again for your help Water! 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