copyleft Posted August 2, 2021 Posted August 2, 2021 Trying to create a script to toggle my desktop text size. 7But I'm getting an error on the first "If Not" declaration. #RequireAdmin #include <MsgBoxConstants.au3> If Not _RegExistKey('HKCU\Control Panel\Desktop', 'LogPixels') Then MsgBox($MB_SYSTEMMODAL, "DPI", "Click to increase text size") RegWrite('HKCU\Control Panel\Desktop', 'LogPixels','REG_DWORD',Number('113')) Else MsgBox($MB_SYSTEMMODAL, "DPI", "Click to restore default text size") RegDelete('HKCU\Control Panel\Desktop', 'LogPixels') EndIf Func _RegExists($sKeyname, $sValueName = "") Local $iRet RegRead($sKeyName, $sValueName) Return ( $svalueName = "" ? @error <= 0 : @error = 0 ) EndFunc
Nine Posted August 2, 2021 Posted August 2, 2021 The name of the function do not correspond to the function you are calling.... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Subz Posted August 2, 2021 Posted August 2, 2021 Also a blank value doesn't necessarily mean its an error, you would just use the @error to determine if it exists or not, example: Func _RegValueExists($_sRegPath, $_sRegKey) RegRead($_sRegPath, $_sRegKey) Return @error ? @error : 0 EndFunc
Nine Posted August 2, 2021 Posted August 2, 2021 (edited) @Subz Agree. But there is no need to use ternary. Return @error is just fine, no ? Edited August 2, 2021 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
copyleft Posted August 2, 2021 Author Posted August 2, 2021 OK. I guess I'm on my way to getting flamed here. But fixed spelling of fuction. Still get error. #RequireAdmin #include <MsgBoxConstants.au3> If Not _RegValueExist ('HKCU\Control Panel\Desktop', 'LogPixels') Then MsgBox($MB_SYSTEMMODAL, "DPI", "Click to increase text size") RegWrite('HKCU\Control Panel\Desktop', 'LogPixels','REG_DWORD',Number('113')) Else MsgBox($MB_SYSTEMMODAL, "DPI", "Click to restore default text size") RegDelete('HKCU\Control Panel\Desktop', 'LogPixels') EndIf Func _RegValueExists($_sRegPath, $_sRegKey) RegRead($_sRegPath, $_sRegKey) Return @error ? @error : 0 EndFunc ; end Exit
Nine Posted August 2, 2021 Posted August 2, 2021 (edited) @copyleft Have you got your eyes examined recently ? You sure spelling is right ??? Edited August 2, 2021 by Nine Danp2 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
copyleft Posted August 2, 2021 Author Posted August 2, 2021 Wow. Too much coffee. Thanks. Solution found!👍
Nine Posted August 2, 2021 Posted August 2, 2021 3 hours ago, copyleft said: Too much coffee. Or not enough “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
JockoDundee Posted August 3, 2021 Posted August 3, 2021 12 hours ago, copyleft said: Solution found! Still you need to change the ternary statement from: Return @error ? @error : 0 to just Return @error as pointed out by @Nine. Not because it doesn’t work, but because it does work. And therefore you might use it all the time, out of habit. Next thing you know, you become a highly regarded AutoIt influencer. Pretty soon everybody’s using the subz error return method just to mess with the noobs. On second thought, just leave it Musashi 1 Code hard, but don’t hard code...
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