Jump to content

unexpectedpanda

Members
  • Posts

    15
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

unexpectedpanda's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Got the stop script button working by implementing a flag as suggested and moving all of the commands after the program execution out of the function, and into the main script. Thanks again Melba
  2. It is complex, I agree. Moreso since the removal apps need user interaction. Looks like we'll have to work around the issue, I'll give your suggestions a shot. Thanks for your help Melba
  3. Okay, I've come up with a benign compromise, I think If I can interrupt this with the stop script button: Func _RemoveProgramOne() ;Dummy function for forums example If WinExists("Program removal") Then GUIDelete($hRemoveProgramGUI) _ProgressStatus("Removing Program One", 1) Run("calc.exe") WinWait("Calculator") WinActivate("Calculator") ControlClick("Calculator","","[CLASS:Button; INSTANCE:9]") ControlClick("Calculator","","[CLASS:Button; INSTANCE:23]") ControlClick("Calculator","","[CLASS:Button; INSTANCE:10]") Sleep(2000) WinActivate("Calculator") Send("{Enter}") MsgBox(0,"","Hello!") While 1 Sleep(20000) WEnd EndFunc ;==>_RemoveProgramOne Then all will be solved If it's not possible, I shall have to find a workaround
  4. Thanks Melba -- if only it were so simple though. The full version of the AutoIt script interacts with the removal programs, waiting for certain window titles to appear, clicking buttons, sometimes even moving the mouse. I can post exact code if you like, I'm just conscious that I'm shutting down things like antivirus and I don't really want to be responsible for putting code out into public that people could use maliciously.
  5. An excellent point! I'd just like to terminate my AutoIt script in this instance. The removal programs are separate .exes (automated by the script) that I'm happy to allow to continue so things don't break, or for the user to manually cancel.
  6. Hi all, I've embarked on a huge clean up of my code project, trying to properly name variables, fix functions, remove bloat etc. The project is designed to return a bloatware and crapware filled laptop to as clean as possible, and to remove any processes that may interrupt a following script that benchmarks the machine. Throughout the project, there's a status bar displayed at the top left, with a big "stop script" button under it. Ideally, that button should run the function _QuitAutoIt() immediately regardless of what the situation is on screen. There is one particular bit though, where the stop script button simply doesn't work. I believe it's related to interrupting a function, but I can't seem to get this to work, and the functions that need to be interrupted can't really be put inside a handy loop to execute as per the examples. For now, I've had to fall back on a keyboard shortcut (CTRL+ALT+Q) that does succesfully terminate the program whenever I like. I've included some sample code. It's been excised from the rest of the codebase and some function placeholders have been put in so it's easier for other people to view. As such, there's likely some variables and functions hanging around that aren't used, but can be safely ignored. When the code is run, it first loads the progress bar, then a GUI asking which program to remove. At this point, the stop script button works. Click one of the program buttons though, and stop script button stops working. Take in mind than when you press a button, a function is executed that is a once off process -- it can't be looped. _GetDPI is just a support file, the rest of the _ files are where the action happens. The main script file is example.au3. I'd love some help here if possible. Thanks for your time, if you're kind enough to give it example.zip
  7. So this took much, much longer to figure out than I care to admit, but here's what fixed all the icons for me up to 200% DPI, with independent scaling of taskbar/ALT+TAB icons and the sysmenu icon. I'm sure you can do that DLL call in one go but I'm not yet experienced enough to figure out how to do so. ;************************************************** ;Window icon resizing ;************************************************** ;Version 1.1 | Last updated 29 August 2012 ; ; Special thanks to JFX, TranceXX, ProgAndy, guinness and Yashied, ; whose separate coding efforts enabled this ; ;-------------------------------------------------- ;*************************************************** ;Set high-res window icons Func _GUISetIcon($hGui, $sModule, $iName); this for loaded modules in this shape If $sModule = "" Then Local $a_hCall = DllCall("kernel32.dll", "hwnd", "GetModuleHandleW", "ptr", 0) Else Local $a_hCall = DllCall("kernel32.dll", "hwnd", "GetModuleHandleW", "wstr", $sModule) EndIf Local $hModule = $a_hCall[0] If $a1[1] >= 96 and $a1[1] < 120 Then $iconsize = 16 $tasksize = 32 EndIf If $a1[1] >= 120 and $a1[1] < 144 Then $iconsize = 20 $tasksize = 48 EndIf If $a1[1] >= 144 and $a1[1] < 192 Then $iconsize = 24 $tasksize = 48 EndIf If $a1[1] >= 192 Then $iconsize = 32 $tasksize = 256 EndIf $a_hCall = DllCall("user32.dll", "hwnd", "LoadImageW", _ "hwnd", $hModule, _ "int", $iName, _ "dword", 1, _; IMAGE_ICON "int", $iconsize, _ ;x width "int", $iconsize, _ ;y height "dword", 0); LR_DEFAULTCOLOR Local $hIcon = $a_hCall[0] DllCall("user32.dll", "hwnd", "SendMessageW", _ "hwnd", $hGui, _ "dword", 0x0080, _; WM_SETICON "dword", 0, _; 1 = ICON_BIG, 0 = ICON_SMALL "hwnd", $hIcon) $a_hCall = DllCall("user32.dll", "hwnd", "LoadImageW", _ "hwnd", $hModule, _ "int", $iName, _ "dword", 1, _; IMAGE_ICON "int", $tasksize, _ ;x width "int", $tasksize, _ ;y height "dword", 0); LR_DEFAULTCOLOR Local $hIcon = $a_hCall[0] DllCall("user32.dll", "hwnd", "SendMessageW", _ "hwnd", $hGui, _ "dword", 0x0080, _; WM_SETICON "dword", 1, _; 1 = ICON_BIG, 0 = ICON_SMALL "hwnd", $hIcon) EndFunc ;==>_GUISetIcon
  8. New complication: I set different sized icons for different levels of DPI scaling, which now properly scales the tray and window icons. Sadly, the ALT+TAB and tray icons (which are much larger images) are now scaling incorrectly, as they're using the smaller sizes I've set for the window icon. As an interesting aside, calling MsgBox scales the icon perfectly for the taskbar (although displays nothing on ALT+TAB). Don't know if it's possible to separate the window icon from ALT-TAB and Tray? I'm afraid the DLL calling stuff is a little beyond me at this stage! Func _GUISetIcon($hGui, $sModule, $iName); this for loaded modules in this shape If $sModule = "" Then Local $a_hCall = DllCall("kernel32.dll", "hwnd", "GetModuleHandleW", "ptr", 0) Else Local $a_hCall = DllCall("kernel32.dll", "hwnd", "GetModuleHandleW", "wstr", $sModule) EndIf Local $hModule = $a_hCall[0] If $a1[1] >= 96 and $a1[1] < 120 Then $iconsize = 16 If $a1[1] >= 120 and $a1[1] < 144 Then $iconsize = 20 If $a1[1] >= 144 and $a1[1] < 192 Then $iconsize = 24 If $a1[1] >= 192 Then $iconsize = 32 $a_hCall = DllCall("user32.dll", "hwnd", "LoadImageW", _ "hwnd", $hModule, _ "int", $iName, _ "dword", 1, _; IMAGE_ICON "int", $iconsize, _ "int", $iconsize, _ "dword", 0); LR_DEFAULTCOLOR Local $hIcon = $a_hCall[0] DllCall("user32.dll", "hwnd", "SendMessageW", _ "hwnd", $hGui, _ "dword", 0x0080, _; WM_SETICON "dword", 1, _; 1 = ICON_BIG, 0 = ICON_SMALL "hwnd", $hIcon) EndFunc ;==>_GUISetIcon
  9. Ah wonderful, it works, thank you so much! So now it's referencing the icon with the resource name "99" in the file itself -- fancy Adding this to the source: ;Special thanks to JFX for making the high res icon code work from TranceXX
  10. That seems to work well for the referenced shell32.dll, no dice for the included .ico though. Here's the code I tried below, still getting a blurry icon -- guessing I'm not referencing properly? #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Version=beta #AutoIt3Wrapper_Icon=cnet.ico #AutoIt3Wrapper_Outfile=test2.exe #AutoIt3Wrapper_Res_Description=test #AutoIt3Wrapper_Res_Fileversion=0.992.0.0 #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator #AutoIt3Wrapper_Res_Compatibility=Windows7 #AutoIt3Wrapper_Res_HiDpi=1 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** TraySetIcon(@ScriptDir & "\cnet.ico",1) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <_GetDPI.au3> Opt("GUIOnEventMode", 1) $a1 = _GetDPI() $iDPIRat = $a1[2] $FormMainGUI = GUICreate("test", 450 * $iDPIRat, 190 * $iDPIRat) _GUISetIcon($FormMainGUI, @ScriptDir & "\cnet.ico", 1); name and not ordinal value $Administratorlbl = GUICtrlCreateLabel("You MUST be signed into an administrative account before running installation",0,85 * $iDPIRat,450 * $iDPIRat,20 * $iDPIRat,$SS_CENTER) GuiCtrlSetColor($Administratorlbl,0x777777) GuiCtrlSetFont($Administratorlbl,7,400) $btnAutomated = GuiCtrlCreateButton("Prepare system and install benchmarks",25 * $iDPIRat,105 * $iDPIRat,400 * $iDPIRat,41 * $iDPIRat) $TipLabel = GUICtrlCreateLabel("Press CTRL + ALT + Q to quit the script at any time, CTRL + ALT + G to enter GOD MODE", 0,160 * $iDPIRat,450 * $iDPIRat,20 * $iDPIRat,$SS_CENTER) GuiCtrlSetColor($TipLabel,0x777777) GUICtrlSetFont($Tiplabel,7,400) GUISetState(@SW_SHOW,$FormMainGUI) GUISetOnEvent($GUI_EVENT_CLOSE,"CloseGui") Sleep(10000) ;************************************************** ;Kill the Program Func CloseGui() Exit EndFunc ;*************************************************** ;Set high-res window icons Func _GUISetIcon($hGui, $sModule, $iName); this for loaded modules in this shape Local $a_hCall = DllCall("kernel32.dll", "hwnd", "GetModuleHandleW", "wstr", $sModule) Local $hModule = $a_hCall[0] $a_hCall = DllCall("user32.dll", "hwnd", "LoadImageW", _ "hwnd", $hModule, _ "int", $iName, _ "dword", 1, _; IMAGE_ICON "int", 32, _ "int", 32, _ "dword", 0); LR_DEFAULTCOLOR Local $hIcon = $a_hCall[0] DllCall("user32.dll", "hwnd", "SendMessageW", _ "hwnd", $hGui, _ "dword", 0x0080, _; WM_SETICON "dword", 1, _; 1 = ICON_BIG, 0 = ICON_SMALL "hwnd", $hIcon) EndFunc ;==>_GUISetIcon
  11. Hi all, I've been doing some work on a MacBook Pro with Retina Display, and so have been toying with high DPI interfaces (~200% dpi) and ?do=embed' frameborder='0' data-embedContent> to make sure things are nice and sharp. The last barrier appears to be window icons used at the top left of the application. I've done a fair bit of searching about icons on the forums, but although there have been references here and there to blurry icons or telling AutoIt specifically what icon to use within the .ICO file, so far I haven't found a solution that's quite fit. As you can see, the desktop icon is great, so is the tray icon, but the window icon at the top left is scaled up and blurry. Native Windows apps don't seem to have this issue. Any hints of how to correct this would be very much welcome. I've uploaded some sample code here, as well as the .ico file that I'm using (374KB ZIP). It's just sample code to illustrate the point, it's not meant to be a functional GUI. You'll likely need to compile with the ?do=embed' frameborder='0' data-embedContent> to be able to see everything at properly sharp high DPI levels, rather than blurry DWM scaling ("Go" (F5) doesn't work for high DPI, you have to compile (F7)... I'm guessing I'd need access to the aut2exe code to modify that behaviour). Here's the code I'm currently using (also in the ZIP): #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Version=beta #AutoIt3Wrapper_Icon=cnet.ico #AutoIt3Wrapper_Outfile=test.exe #AutoIt3Wrapper_Res_Description=test #AutoIt3Wrapper_Res_Fileversion=0.992.0.0 #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator #AutoIt3Wrapper_Res_Compatibility=Windows7 #AutoIt3Wrapper_Res_HiDpi=1 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** TraySetIcon(@ScriptDir & "\cnet.ico",1) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <_GetDPI.au3> Opt("GUIOnEventMode", 1) $a1 = _GetDPI() $iDPIRat = $a1[2] $FormMainGUI = GUICreate("test", 450 * $iDPIRat, 190 * $iDPIRat) GuiSetIcon(@ScriptDir & "\cnet.ico",1,$FormMainGUI) $Administratorlbl = GUICtrlCreateLabel("You MUST be signed into an administrative account before running installation",0,85 * $iDPIRat,450 * $iDPIRat,20 * $iDPIRat,$SS_CENTER) GuiCtrlSetColor($Administratorlbl,0x777777) GuiCtrlSetFont($Administratorlbl,7,400) $btnAutomated = GuiCtrlCreateButton("Prepare system and install benchmarks",25 * $iDPIRat,105 * $iDPIRat,400 * $iDPIRat,41 * $iDPIRat) $TipLabel = GUICtrlCreateLabel("Press CTRL + ALT + Q to quit the script at any time, CTRL + ALT + G to enter GOD MODE", 0,160 * $iDPIRat,450 * $iDPIRat,20 * $iDPIRat,$SS_CENTER) GuiCtrlSetColor($TipLabel,0x777777) GUICtrlSetFont($Tiplabel,7,400) GUISetState(@SW_SHOW,$FormMainGUI) GUISetOnEvent($GUI_EVENT_CLOSE,"CloseGui") Sleep(10000) ;************************************************** ;Kill the Program Func CloseGui() Exit EndFunc Thanks, Unexpectedpanda
  12. I admit, this is a hack job, but it might help someone (or give the devs an easy leg up in terms of making this official). I've had a MacBook Pro with Retina Display on loan for about a week, and have noticed that AutoIt GUIs don't handle high DPI displays well, defaulting to DWM scaling (fuzzy, blurry upscale). See here for more information: http://blogs.msdn.com/b/patricka/archive/2010/04/15/why-does-a-high-dpi-setting-make-my-application-look-fuzzy-and-have-clipped-text.aspx To return things to sharpness, we need to modify the manifest file, but pretty much every res hacker I used, and even Microsoft's own mt.exe tool would destroy AutoIt binaries, whether compiled with UPX or not. As such, I've modified AutoIt3Wrapper.au3 to fit the task. Specifically, when the user adds #AutoIt3Wrapper_Res_HiDpi=1 to the to their AutoIt3Wrapper directives, this section gets written to the manifest: <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"> <dpiAware>true</dpiAware> </asmv3:windowsSettings> </asmv3:application> The header of the manifest has also been modified to read: <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> Compile and replace AutoIt3Wrapper.exe, and SciTE will now be capable of compiling DPI aware GUIs. Just running Go (F5) will show normal DWM scaling, you have to compile to see the results (click to see the full-sized image to appreciate how blurry things can get). Designing them so scaled up text doesn't run off edges, or higher resolution images are served is your own look out AutoIt3Wrapperhack.au3
  13. Brill! I will do exactly that
  14. Ah, so because it's in a function it's treated differently. Interesting! I look forward to playing around a bit more Thanks so much for your kindness Melba23 -- I'd also like to thank you for all your other responses on this forum, they've saved me and no doubt many others a few times now.
  15. Hi all, I'm sure the solution is obvious, but after my Helpfile-fu, Google-fu, Forum-fu and FAQ-fu failed me and hours of fiddling, I need a fresh pair of eyes to help. The first GUI in this script loads, and when you press on the first button loads another GUI in the function Autobench. But this second GUI doesn't respond to any button presses. Any pointers to getting the buttons to respond would be greatly appreciated. #include <GUIConstants.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) #RequireAdmin $MachineField = 0 $FormMainGUI = GUICreate("Benchmarks", 450, 150, (@Desktopwidth/2)-225, (@DesktopHeight/2)-250) $btnAutomated = GuiCtrlCreateButton("Deploy and run automated benchmarks",75,40,300,41) $btnExitGui = GUICtrlCreateButton("Exit", 186, 100, 75, 25, 0) GUISetState(@SW_SHOW,$FormMainGUI) GUISetOnEvent($GUI_EVENT_CLOSE,"CloseGui",$FormMainGUI) GUICtrlSetOnEvent($btnExitGui,"CloseGui") GUICtrlSetOnEvent($btnAutomated,"AutoBench") WinWaitClose("Benchmarks") ;************************************************** ;Functions Func AutoBench() GUIDelete($FormMainGUI) $MachineNameGUI = GUICreate("Machine name",450,150,(@DesktopWidth/2)-225, (@DesktopHeight/2)-150) $MachineFieldlbl = GUICtrlCreateLabel("Please enter the machine name (brand/model, e.g. Apple MacBook Pro 13",10,10) $MachineField = GUICtrlCreateInput("",10,30) $MachineSaveBtn = GUICtrlCreateButton("Save",10,55,100,20) GuiSetState(@SW_SHOW,$MachineNameGUI) GUISetOnEvent($GUI_EVENT_CLOSE,"CloseGui",$MachineNameGUI) GUICtrlSetOnEvent($MachineSaveBtn,"MachineSaveBtn") WinWaitClose("Machine name") EndFunc Func MachineSaveBtn() GUICtrlRead($MachineField) MsgBox(0,"",$MachineField) EndFunc Func CloseGui() Exit EndFunc Much thanks!
×
×
  • Create New...