Jump to content

Stilez

Members
  • Posts

    17
  • Joined

  • Last visited

Stilez's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Traytip works, but I want to find out how to make it work with a tooltip style.
  2. Thanks Unfortunately that didn't work quite as I'd hoped. The (TrayTool|Tool)tip itself is the problem. It looks like Tray Tooltip doesn't work like Traytip - rewriting it doesn't update the displayed text or reset the timeout. It still displays the same value as when first shown and vanishes after a few seconds. So TraySetToolTip() is out unless there's better control available via DLL calls. Tooltip() looks more promising, but I'm having a different problem with it - it's somehow preventing detection of the "move off" state. (Also the traytooltip is still displayed and I can't work out how to stop it, and the tooltip no longer positions next to its tray icon). You can see the problem for yourself by running the code below, with $USE_TOOLTIP set to 0 or 1. Setting $USE_TOOLTIP = 0 posts the current "hover" status to the console as your code did. Setting $USE_TOOLTIP = 1 posts the status to console and also writes (or updates) a tooltip using a random number instead of "updated data". With $USE_TOOLTIP = 0 everything's fine. But when $USE_TOOLTIP = 1, the act of setting the tooltip somehow seems to cause the "mouse move away" detection to fail, so it never changes $over_icon back to 0 and therefore never turns off the tooltip. Any ideas why? #include <Constants.au3> Global $_MousePosOld[2] $over_icon = False $USE_TOOLTIP = 1 While 1 $_MousePos = MouseGetPos ( ) If $_MousePos[0] <> $_MousePosOld[0] Or $_MousePos[1] <> $_MousePosOld[1] Then $_Msg = TrayGetMsg ( ) Switch $_Msg Case $TRAY_EVENT_MOUSEOVER $over_icon = True Case Else $over_icon = False EndSwitch $_MousePosOld[0] = $_MousePos[0] $_MousePosOld[1] = $_MousePos[1] EndIf If $USE_TOOLTIP Then If $over_icon then ToolTip("some info" & @CRLF & random(1,1000,1),5000,5000,"TITLE",0,4) Else Tooltip("") EndIf EndIf ConsoleWrite("$over_tray = " & $over_icon & @CRLF) Sleep ( 10 ) WEnd
  3. I did, but I figured as an event, it fires once on the mouse moving over. There's no sign of a corresponding $TRAY_EVENT_MOUSEOFF to detect the end of mousing over.
  4. I want to do an action every couple of seconds as long as the mouse is hovering over the tray icon. I'm not sure how to do that, because the standard tray event (as I understand it) only detects the mouse moving over the icon. It doesn't fire continually or set a checkable flag for as long as the mouse is there. The actual aim of the code is for a tray tool that displays status information - the idea is to update/rewrite the tray tooltip every few seconds while the icon is hovered, so that if the mouse is left over the icon for a long-ish time, the tooltip data gets updated every few seconds and the tooltip doesn't vanish until the mouse actually stops hovering. Any help welcomed!
  5. To embed it as code, rather than (eg) FileInstall() or binary, yes. And to have a way to convert an RTF file or string to pure ascii text that handles CR/LF correctly.
  6. I'm using and it seems to work well, including in a virtual machine.
  7. I wrote this code, which seems to work well, including in virtual machines. VM detection matters because In a VM you probably need to specify a maximum valid resolution (as it can only check adapter values) and the refresh rate won't really be variable as it has to match the @DESKTOP rate. In a non-VM you can usually use the maximum returned resolution (as the monitor is usually genuine hardware), but the refresh rate is best limited out of caution to ~ 85 - 100 Hz when automated.The code looks for the largest 32 bit per pixel resolution since most people probably use 32 bit display settings and it's unusual to find an adapter that can't do 32 bits on max resolution if needed. It also ignores all resolutions below that which you're already using, and below 800 wide or high, and returns zero if you're already using max resolution. If you always want the max value returned, edit the lines "$min_width =" and "$min_height =" to zero or 800 x 600 or something. There will usually be one monitor resolution that's maximum for both width and height. The parameters include a maximum width only - for simplicity if you define a max width, it automatically returns the maximum height supported by that width (if more than the minimum or current screen size). Code related to detecting valid resolutions is by Rasim (). Code related to VM detection also included ("_CheckVM"), which I've posted elsewhere () and uses code by Fennek (link). Dim $a[3] #include <Math.au3> #include <Array.au3> ; different parameters in a VM If _CheckVM() = "" Then MsgBox(0,"","Did not detect VM." & @CRLF & @CRLF &"Checking for a larger resolution than your current one. Limits:" & @CRLF & @CRLF & "Refresh rate - up to 90 Hz") _GetMaxNativeResolution($a) Else MsgBox(0,"","Detected VM." & @CRLF & @CRLF &"Checking for a larger resolution than your current one. Limits:" & @CRLF & @CRLF & "Width - ignoring anything over 1600" & @CRLF & "Refresh rate - same as your current refresh rate (" & @DesktopRefresh & "Hz)") _GetMaxNativeResolution($a, 1600, -1) EndIf ; results -> user If @error Then MsgBox(0,"", "Cannot identify a larger ""maximum"" resolution - no valid larger 32bpp resolutions found.") Else MsgBox(0,"", "Found one or more valid larger resolutions within the limits" & @CRLF & @CRLF &"Largest ""guaranteed"" resolution was " & $a[0] & " x " & $a[1] & " @ " & $a[2] & "Hz (32 bits per pixel)") EndIf ; ------------------------------------ End main ; ------------------------------------ Start max resolution funcs ; Attempt to identify the maximum resolution for the main display. Complicated by ; 1) Virtual machines can report very large "valid resolutions" the user may not want ; or refresh rates that are meaningless for a "screen" that's really just a window ; 2) high refresh rates can damage hardware ; ; $out[3] will be set to an array [width, height, resolution] for the highest valid 32 bit per pixel resolution found ; or 0 if no valid higher resolution could be found (eg already operating at max resolution) ; ;$max_width (optional) limits the resolutions which can be returned (eg in a VM one might set $max_width = 1440). ; Default 0 = don't limit ; On a non-VM usually use the default 0 or a limit you know to be valid. ; ; $max_refresh (optional) sets a limit on refresh rate if >0, or forces current refresh rate matching if <0. ; Default = 90 Hz. ; On a VM use $max_refresh = -1 to match the existing screen refresh rate. Func _GetMaxNativeResolution(ByRef $out, $max_width = 0, $max_refresh = 90) Dim $DEVMODE, $DllRet, $enum = 0, $valid_res[1][4] Local Const $EDS_RAWMODE = 0x2 $min_width = _Max(@DesktopWidth + 1, 800) $min_height = _Max(@DesktopHeight + 1, 800) If $max_width = 0 Then $max_width = 99999 $res_count = 0 ; Get valid resolutions. Code for detecting list of reported valid resolutions is by Rasim ; www.autoitscript.com/forum/topic/70679-optain-supported-resolutions-via-enumdisplaysettingsex-call $DEVMODE = DllStructCreate("char dmDeviceName[32];ushort dmSpecVersion;ushort dmDriverVersion;short dmSize;" & _ "ushort dmDriverExtra;dword dmFields;short dmOrientation;short dmPaperSize;short dmPaperLength;" & _ "short dmPaperWidth;short dmScale;short dmCopies;short dmDefaultSource;short dmPrintQuality;" & _ "short dmColor;short dmDuplex;short dmYResolution;short dmTTOption;short dmCollate;" & _ "byte dmFormName[32];dword dmBitsPerPel;int dmPelsWidth;dword dmPelsHeight;" & _ "dword dmDisplayFlags;dword dmDisplayFrequency") DllStructSetData($DEVMODE, "dmSize", DllStructGetSize($DEVMODE)) Do $DllRet = DllCall("user32.dll", "int", "EnumDisplaySettingsEx", "ptr", 0, "dword", $enum, _ "ptr", DllStructGetPtr($DEVMODE), "dword", 0) $DllRet = $DllRet[0] $enum += 1 $w = DllStructGetData($DEVMODE, "dmPelsWidth") ; width $h = DllStructGetData($DEVMODE, "dmPelsHeight") ; height $r = DllStructGetData($DEVMODE, "dmDisplayFrequency") ; refresh rate $bpp = DllStructGetData($DEVMODE, "dmBitsPerPel") ; bits per pixel If $bpp <> 32 Or $w < $min_width Or $w > $max_width Or $h < $min_height Then ContinueLoop If ($max_refresh < 0 And $r <> @DesktopRefresh) Or ($max_refresh > 0 And $r > $max_refresh) Then ContinueLoop ReDim $valid_res[$res_count + 1][4] $valid_res[$res_count][0] = $w $valid_res[$res_count][1] = $h $valid_res[$res_count][2] = $r ;$valid_res[$res_count][3] = $bpp ; bits per pixel - not interested ; and create a sort key - ensure fixed width fields for sorting $valid_res[$res_count][3] = StringFormat("%06d",$w) & "-" & StringFormat("%06d",$h) & "-" & StringFormat("%03d",$r) $res_count += 1 Until $DllRet = 0 $DEVMODE = 0 If $res_count = 0 Then $out = 0 SetError(1) return 1 Else ; Sort, then return the largest item (last entry) as a 1-dimension array. _ArraySort($valid_res,0,0,0,3) Dim $out[3] = [ $valid_res[$res_count - 1][0], $valid_res[$res_count - 1][1], $valid_res[$res_count - 1][2] ] SetError(0) return 0 EndIf EndFunc ;==>_GetMaxNativeResolution ; ------------------------------------ End max resolution funcs ; ------------------------------------ Start VM detection funcs (not strictly part of this script) ; Checks if we're in a VM. Returns "" if we aren't, or a string containing the diagnostic explanation if we are. ; Uses code by fennek, extra logic by Stilez ; www.secret-zone.net/showthread.php?3143-Detect-Vmware-VirtualBox-VirtualP-Autoit ; and ; www.autoitscript.com/forum/topic/131607-detect-running-in-virtual-machine ; Method: Checks for VM services/processes, hard drives, bios ID and motherboard ID ; Reports a VM only if hardware in * 2 or more different categories * are found ; Note - reason is, non-VMs might use virtual hardware or have the word "virtual" in some description Func _CheckVM() $strComputer = '.' $objWMIService = ObjGet('winmgmts:\\' & $strComputer & '\root\cimv2') $vmhit_count = 0 $vmhit_details = "" ; Check for VM management processes If ProcessExists("VBoxService.exe") Or ProcessExists("VBoxTray.exe") Or ProcessExists("VMwareTray.exe") Or ProcessExists("VMwareUser.exe") Then _AddVMHit($vmhit_count, $vmhit_details, "RUNNING SOFTWARE", "Found a Vbox or VMware service or tray process") ; Check for VM devices If Not IsObj($objWMIService) Then msgbox(0,"","? WTF?") return "" EndIf ; Check for VM hard disks $colItems = $objWMIService.ExecQuery('SELECT * FROM Win32_DiskDrive', 'WQL', 0x10 + 0x20) If IsObj($colItems) Then For $objItem In $colItems $vReturn = $objItem.Model Select Case StringInStr($vReturn,"VBOX HARDDISK") _AddVMHit($vmhit_count, $vmhit_details, "DISKS", "Found device ""VBOX HARDDISK""") Case StringInStr($vReturn,"QEMU HARDDISK") _AddVMHit($vmhit_count, $vmhit_details, "DISKS", "Found device ""QEMU HARDDISK""") Case StringInStr($vReturn,"VMWARE VIRTUAL IDE HARD DRIVE") _AddVMHit($vmhit_count, $vmhit_details, "DISKS", "Found device ""VMWARE VIRTUAL IDE HARD DRIVE""") Case StringInStr($vReturn,"VMware Virtual S SCSI Disk Device") _AddVMHit($vmhit_count, $vmhit_details, "DISKS", "Found device ""VMware Virtual S SCSI Disk Device""") EndSelect Next EndIf ; Check for VM BIOS $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_BIOS", "WQL", 0x10 + 0x20) If IsObj($colItems) Then For $objItem In $colItems Select Case StringInStr($objItem.BIOSVersion(0),"Vbox") _AddVMHit($vmhit_count, $vmhit_details, "BIOS", "Found Vbox BIOS version") Case StringInStr($objItem.SMBIOSBIOSVersion,"virt") _AddVMHit($vmhit_count, $vmhit_details, "BIOS", "Found Vbox BIOS version") EndSelect Next EndIf ; Check for VM Motherboard/chipset $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Baseboard", "WQL", 0x10 + 0x20) If IsObj($colItems) Then For $objItem In $colItems Select Case StringInStr($objItem.Name,"Base Board") And StringInStr($objItem.Product, "440BX Desktop Reference Platform") _AddVMHit($vmhit_count, $vmhit_details, "MOTHERBOARD", "Found VMware-style motherboard, ""440BX Desktop Reference Platform"" / Name=""Base Board""") EndSelect Next EndIf If $vmhit_count >= 2 Then Return $vmhit_details & @CRLF & @CRLF & "Hits in " & $vmhit_count & " of 4 hardware categories - probably a virtual machine." Else Return "" EndIf EndFunc ;==>_CheckVM ; Notes a hardware hit, but doesn't increase the "category count" if we've already noted VM hardware in a given category Func _AddVMHit(ByRef $vmhit_count, ByRef $vmhit_details, $this_hit_category, $this_hit_text) If StringInStr($vmhit_details, "In CATEGORY:" & $this_hit_category & ":") Then ; Already logged a hit in this category, just note the extra hit $vmhit_details &= " and " & $this_hit_text Else ; Category not logged yet - add it and the hit if $vmhit_details > "" Then $vmhit_details &= @CRLF $vmhit_details &= "In CATEGORY:" & $this_hit_category & ": " & $this_hit_text $vmhit_count += 1 EndIf EndFunc ;==>_AddVMHit
  8. This is a code generator. It takes an RTF file as source and creates reliable AutoIt code for in-line use in programs, that can be used as the contents of a rich text edit control. Details: Rich Text can contain formatting, screenshots and other images, which is useful (eg for in-program Help). Since RTF can be 10 - 100s of KB long and can contain non-text characters (CR, LF, Chr(0) etc), common ways to include RTF are to include it in a zipped App folder, FileInstall and extract/read it or _GUICtrlRichEdit_StreamFromFile() at runtime, or FileRead the source to a long stream of binary in a variable. The code below is a fourth approach with some advantages. It's a code generator. It takes as source an RTF file (of any kind) and creates as output AutoIt code which faithfully assigns the exact RTF file to a variable. The advantage of this code is that the result is pure AutoIt plain text. So the rtf is completely readable, understandable and easily reviewed. Virtually no "junk" (null strings , unnecessary string termination, inefficient @CR & @LF etc) is created. Any non-text characters are converted to AutoIt macros (@CR, @LF etc) or Chr()'s. No changes are made to the content, even if an AutoIt line break is needed in the middle of some included control codes (CR/LF). The output has an almost constant length for each code line regardless of how few or many non-text characters are contained. The code it creates can be copy-pasted directly into your code, or put in a separate file and included via #include "...", and then put in the control using _GUICtrlRichEdit_Create() or _GUICtrlRichEdit_SetText() without any runtime processing, and with no included files or file system access. The RTF code generator: ; Rtf to Au3 converter, by Stilez ; www.autoitscript.com/forum/topic/131614-convert-rtf-rich-text-to-inline-code/ $max_AutoIt_linelength = 1000 $rtf_filename = @ScriptDir & "\MyTree.rtf" $output_filename = @ScriptDir & "\MyTree.au3" $rtf_description = "Picture of my tree sourced from " & $rtf_filename $rtf_data = FileRead($rtf_filename) $var_name = "$__My_rtf" $au3_text = _RichTextToAU3($var_name, $rtf_description, $rtf_data, $max_AutoIt_linelength) ; Save in unicode since the comment text or file paths could include unicode. ; Note: unicode + BOM (128) format caused AutoIt itself to consistently crash for me when re#included. No BOM (256) format works fine instead. Reported at bug tracker - bug #1989 $f = FileOpen($output_filename, 2 + 256) If $f = -1 Then MsgBox(0,"","Error opening output file for writing") Exit EndIf FileWrite($f, $au3_text) FileClose($f) MsgBox(0,"","Rtf to Au3 completed - check out the contents of " & $output_filename & " :)") ; ---------------------------- End of demo program ; ---------------------------- Start of actual RTF functions ; $var_name - the name of an AutoIt variable which will be assigned the file content ; $rtf_description - an optional description (self-commenting output) ; $rtf_data - the actual raw rtf to be converted to au3 - it can include control codes, unicode, whatever ; $max_AutoIt_linelength - the approx max length of a line of output code (may be a few chars longer) Func _RichTextToAU3($var_name, $rtf_description, ByRef $rtf_data, $max_AutoIt_linelength = 2000) $charpointer = 1 $result = "; " & $var_name & " holds the contents of: """ & $rtf_description & """" & @CRLF & @CRLF & $var_name & " = " $output_chunk = "" $first_time = True While _GetRtfSafeChunk($rtf_data, $charpointer, $output_chunk, $max_AutoIt_linelength) If $first_time Then $result &= $output_chunk $first_time = False Else $result &= @CRLF & $var_name & " &= " & $output_chunk EndIf WEnd if $first_time = True Then $result &= """""" Return $result & @CRLF EndFunc ;==> _RichTextToAU3 ; Read and transcribe from current position in source text into au3 format until our output reaches max allowed length. ; Return True if we did something, or False if we're done and nothing needed transcribing (end of text) ; ByRef used to minimize copying in memory of potentially very long strings. Func _GetRtfSafeChunk(ByRef $text, ByRef $charpointer, ByRef $output_chunk, $max_AutoIt_linelength) $textlen = StringLen($text) If $charpointer > $textlen Then Return False $output_chunk = """" $stringmode = True While $charpointer <= $textlen And StringLen($output_chunk) < $max_AutoIt_linelength $c = StringMid($text, $charpointer, 1) $ca = Asc($c) If $stringmode And ($ca < 32 Or $ca > 126) Then $output_chunk &= """" $stringmode = False ElseIf Not $stringmode And ($ca >= 32 And $ca <= 126) Then $output_chunk &= " & """ $stringmode = True EndIf Select Case $c = @CR If StringMid($text, $charpointer, 2) = @CRLF Then $output_chunk &= " & @CRLF" $charpointer += 1 Else $output_chunk &= " & @CR" EndIf Case $c = @LF $output_chunk &= " & @LF" Case $c = @TAB $output_chunk &= " & @TAB" Case $ca < 32 Or $ca > 126 $output_chunk &= " & Chr(" & Asc($c) & ")" Case $c = """" $output_chunk &= """""" Case Else $output_chunk &= $c EndSelect $charpointer += 1 WEnd If $stringmode Then $output_chunk &= """" Return True EndFunc ;==>_GetRtfSafeChunk Example of style of output (extract of a real file): ; $__My_rtf holds the contents of: "Picture of my tree sourced from C:\Users\MyUsername\Desktop\MyTree.rtf" $__My_rtf = "{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\fonttbl{\f0\fnil\fcharset0 Calibri;}}" & @CRLF & "{\colortbl ;\red204\green204\blue204;\red0\green0\blue0;}" & @CRLF & "{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\sl276\slmult1\qc\cf1\highlight2\lang9\f0\fs22 Hello world! \cf0\highlight0\par" & @CRLF & "\pard\sl240\slmult1\qc{\pict\wmetafile8\picw1773\pich1508\picwgoal1005\pichgoal855 " & @CRLF & "000c0239004300030000001e0004000000070104000400c00..." & @CRLF $__My_rtf &= "60099ffff003399cc00ffffcc00003300" & @CRLF & "0099cc9900ffcccc00330033000000000000000000000000000000000000000000000000000000" & @CRLF & "000000000000000000000000000000000000000000000000000000000000000000000000000000" & @CRLF & "000000000000000000000000000000000000000000000000000000000000000000000000000000" & @CRLF & "000000000000000000000000000000000000000000000000000000000000000000000000000000" & @CRLF & "0000000000000000000000000000000000000000000" $__My_rtf &= "00000000000000000000000000000000000" & @CRLF & "000000000000000000000000000000000000000000000000000000000000000000000000000000" & @CRLF & "000000000000000000000000000000000000000000000000000000000000000000000000000000" & @CRLF & "000000000000000000000000000000000000000000000000000000000000000000000000000000" & @CRLF & "000000000000000000000000000000000000000000000000000000000000000000000000000000" & @CRLF & "00000000000000000000000000000000000000000" $__My_rtf &= "0000000000000000000000000000000000000" & @CRLF & "000000000000000000000000000000000000000000000000000000010101010101010101010101" & @CRLF & "0b010b0906030b0208160607010101010101010101010160010101010101010101010101020102" & @CRLF & "020101010101010101010101010001010101010101010101010101010101010209030a0c0c0a0a" & @CRLF & "010101010101010101010101010b060b07060a0616020101210101010101010101010101010101" & @CRLF & "010101010104060a1d010101010101010101010" $__My_rtf &= "7060a110606060c0d050101010101010101010101000101010101" & @CRLF & "01010101020105060904020b0c0a060c0d0a0a060a0f15100a0f090a0a100a0d0c0f0c0d0d0606" & @CRLF & "0b010b0906030b0208160607010101010101010101010160010101010101010101010101020102" & @CRLF & "020101010101010101010101010001010101010101010101010101010101010209030a0c0c0a0a" & @CRLF & "01010101010102010707080709060a0606060802030a06030b0101010101010101010101010101" & @CRLF & "01010101010101010101010" $__My_rtf &= "1000101010101010101010101010101010101010101010101010101" & @CRLF & "010102030405060307010801020101010101010101010101010101010101010101010101010101" & @CRLF & "010100040000002701ffff030000000000" & @CRLF & "}\par" & @CRLF & "This is my tree!\par" & @CRLF & "}" & @CRLF
  9. Thanks! I agree, I haven't checked the code on old or unusual platforms, or even other platforms that are current. I'm not sure what is best practice here, if I were expected to check code against other platforms (which I don't own copies of) I'd never get round to releasing code publicly, as I mainly write it for my own use. I don't have win2k so I'm glad you spotted it. Presumably some versions don't include the property BIOSVersion(0)? If you can suggest amended code below, that would be great, and if there's a better way to present code when it's useful but not tested on many platforms, let me know (In this case the only reason this code exists is, I want my win7 install to automatically switch to the highest valid resolution post-install. That depends whether it's in a VM or not, which means reliably detecting VM running. I wasn't happy that existing VM detection code would do this reliably for my future Win7 installs, for example if the user has a VHD some code assumes the system is on a VM. So this code got written to detect better. It's probably useful for others, and helpful to people who are "in my shoes", but I'm sure it can be refined. Best practice? Dunno )
  10. I'm not a machine code programmer, nor a Windows coder,. I accept it but I don't know enough to understand. Presumably TCC compiler and compiled code is x86, but AutoIt x64 can still compile code x86. At what point would x64 code try to call or link x86 code and be unable? If one compiled the program with AutoIt on an x86 machine would the executable be able to run on x64? What about if one ran the x86 version of AutoIt on an x64 machine, or installed/ran AutoIt in a 32 bit compatibility mode? Some clarification would be interesting Thanks!
  11. Out of interest what's the issue with x64? Can it generate x32 code which can still run on an x64 machine?
  12. In case it's useful to anyone, this code works well for me and it's resilient against non-VM systems which have some virtual devices. Unlike most code I've seen, it only reports a VM if it finds VM hardware in 2 or more different categories out of software (VM service processes), disk drives, BIOS ID and motherboard ID. So systems with virtual hard drive or an accidental match on some criterion are unlikely to trigger it by mistake. Uses code by fennek (link) At present it returns a string - empty "" if not a VM, or a description of its diagnostic reasoning if it decides we're in a VM. Easy to fix if you want classic 0 1 or @error returns. $a = _CheckVM() if $a = "" Then MsgBox(0, "I'm not in a VM", "Done!") Else MsgBox(0, "I'm in a VM!", "My reason is" & @CRLF & @CRLF & $a) EndIf ; Checks if we're in a VM. Returns "" if we aren't, or a string containing the diagnostic explanation if we are. ; Uses code by fennek, extra logic by Stilez ; www.secret-zone.net/showthread.php?3143-Detect-Vmware-VirtualBox-VirtualP-Autoit ; Method: Checks for VM services/processes, hard drives, bios ID and motherboard ID ; Reports a VM only if hardware in * 2 or more different categories * are found ; Note - reason is, non-VMs might use virtual hardware or have the word "virtual" in some description Func _CheckVM() $strComputer = '.' $objWMIService = ObjGet('winmgmts:\\' & $strComputer & '\root\cimv2') $vmhit_count = 0 $vmhit_details = "" ; Check for VM management processes If ProcessExists("VBoxService.exe") Or ProcessExists("VBoxTray.exe") Or ProcessExists("VMwareTray.exe") Or ProcessExists("VMwareUser.exe") Then _AddVMHit($vmhit_count, $vmhit_details, "RUNNING SOFTWARE", "Found a Vbox or VMware guest OS service or tray process") ; Check for VM devices If Not IsObj($objWMIService) Then msgbox(0,"","? WTF?") return "" EndIf ; Check for VM hard disks $colItems = $objWMIService.ExecQuery('SELECT * FROM Win32_DiskDrive', 'WQL', 0x10 + 0x20) If IsObj($colItems) Then For $objItem In $colItems $vReturn = $objItem.Model Select Case StringInStr($vReturn,"VBOX HARDDISK") _AddVMHit($vmhit_count, $vmhit_details, "DISKS", "Found device ""VBOX HARDDISK""") Case StringInStr($vReturn,"QEMU HARDDISK") _AddVMHit($vmhit_count, $vmhit_details, "DISKS", "Found device ""QEMU HARDDISK""") Case StringInStr($vReturn,"VMWARE VIRTUAL IDE HARD DRIVE") _AddVMHit($vmhit_count, $vmhit_details, "DISKS", "Found device ""VMWARE VIRTUAL IDE HARD DRIVE""") Case StringInStr($vReturn,"VMware Virtual S SCSI Disk Device") _AddVMHit($vmhit_count, $vmhit_details, "DISKS", "Found device ""VMware Virtual S SCSI Disk Device""") EndSelect Next EndIf ; Check for VM BIOS $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_BIOS", "WQL", 0x10 + 0x20) If IsObj($colItems) Then For $objItem In $colItems Select Case StringInStr($objItem.BIOSVersion(0),"Vbox") _AddVMHit($vmhit_count, $vmhit_details, "BIOS", "Found Vbox BIOS version") Case StringInStr($objItem.SMBIOSBIOSVersion,"virt") _AddVMHit($vmhit_count, $vmhit_details, "BIOS", "Found Vbox BIOS version") EndSelect Next EndIf ; Check for VM Motherboard/chipset $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Baseboard", "WQL", 0x10 + 0x20) If IsObj($colItems) Then For $objItem In $colItems Select Case StringInStr($objItem.Name,"Base Board") And StringInStr($objItem.Product, "440BX Desktop Reference Platform") _AddVMHit($vmhit_count, $vmhit_details, "MOTHERBOARD", "Found VMware-style motherboard, ""440BX Desktop Reference Platform"" / Name=""Base Board""") EndSelect Next EndIf If $vmhit_count >= 2 Then Return $vmhit_details & @CRLF & @CRLF & "Hits in " & $vmhit_count & " of 4 hardware categories - probably a virtual machine." Else Return "" EndIf EndFunc ;==>_CheckVM Func _AddVMHit(ByRef $vmhit_count, ByRef $vmhit_details, $this_hit_category, $this_hit_text) If StringInStr($vmhit_details, "In CATEGORY:" & $this_hit_category & ":") Then ; Already logged a hit in this category, just note the extra hit $vmhit_details &= " and " & $this_hit_text Else ; Category not logged yet - add it and the hit if $vmhit_details > "" Then $vmhit_details &= @CRLF $vmhit_details &= "In CATEGORY:" & $this_hit_category & ": " & $this_hit_text $vmhit_count += 1 EndIf EndFunc ;==>_AddVMHit If anyone knows what to do when ObjGet('winmgmts:\\.\root\cimv2') isn't an object, please say! Also any other VM hardware identifiers - please add them to this thread
  13. I looked for this for a while, maybe someone else will too. It's an AutoIt script to automate adding back the classic Quick Launch bar in Windows 7. Original work by wazer @ MSFN, I've updated it. Main Options - Set quick launch bar width, copy existing icons to quick launch bar, wait for desktop before acting (useful in session start or installing) Other options - Remove the 'pinned' list, set taskbar buttons = "never combine", small taskbar icons, disable autotray, close language bar, leave taskbar locked/unlocked Full help/info included, and should work in unattended installs too. File hosted at links below, more detail on MSFN. Includes several localised help files so won't fit within forum size limits. Download: MediaFire / FileFactory / DepositFiles (v2.00 RC1.02)
  14. I was playing round with WinMinimizeAll() and WinMinimizeAllUndo(). If you have popup dialogs etc in between, sometimes the WinMinimizeAllUndo() "forgets" which windows were minimized by WinMinimizeAll() so it doesn't do the restore function as you'd expect. For anyone who hits this, the following code will handle it - and allow arbitrary window manipulation in between. It logs all non-minimized window handles, and when you're done, it checks for any windows that are displayed now, were displayed before (according to its handle) and whose state has changed from non-minimized to minimized, and restores it. Things it doesn't do - it doesn't handle clashes of window handles, and it doesn't remember the active window (their Z-order). If anyone wants to fix for those, please do! #Include <Array.au3> dim $OriginalNonMinimizedWindows[1] $OriginalNonMinimizedWindows[0]="" $winlist = WinList() If $winlist[0][0] > 0 Then for $i = 1 to $winlist[0][0] $winhdl = $winlist[$i][1] $state = WinGetState($winhdl) If BitAND($state,16) <> 16 Then _ArrayAdd($OriginalNonMinimizedWindows, $winhdl) Next EndIf _ArraySort($OriginalNonMinimizedWindows) WinMinimizeAll() sleep (1500) $winlist = Winlist() If $winlist[0][0] > 0 Then For $i = 1 to $winlist[0][0] $winhdl = $winlist[$i][1] $state = WinGetState($winhdl) If BitAND($state, 16) == 16 Then If _ArrayBinarySearch($OriginalNonMinimizedWindows, $winhdl) >= 0 Then WinSetState($winhdl, "", @SW_RESTORE) msgbox(1,"","Restored window for: " & $winlist[$i][0] & " (handle "& $winlist[$i][1] & ").", 1) EndIf EndIf Next EndIf
  15. Hi, I'm trying to automate adding a folder as a toolbar in Windows 7. That's easy and works well. The problem is the "folder chooser" dialog box is a bit ugly and its automation is crude to watch. I'd like to conceal that, maybe by suppressing redraw for that process or window or something while it's active. I also have the dialog class as "[CLASS:MSTaskListWClass; TEXT:Running applications]" but not sure whether that's useful somehow. Any help with this would be great. It's part of an enhancement for some code on MSFN so I'd like to do it nicely. Any other improvements welcomed. Opt("WinDetectHiddenText", 0) Opt("WinTextMatchMode",2) OnAutoItExitRegister("CleanExit") BlockInput(1) ; Add new toolbar MouseClick("right", 0, @DesktopHeight) Send("{DOWN}{RIGHT}{UP}{ENTER}") $e = WinActive("New Toolbar - Choose a folder") If $e == 0 Then Msgbox(17,"Error","Expected dialog didn't open") Exit EndIf sleep(1000) ControlSetText("New Toolbar - Choose a folder", "", "Edit1", "C:\My Toolbar") sleep(1000) ControlClick("New Toolbar - Choose a folder", "", "Button1") ; Continue with other stuff ... Func CleanExit() BlockInput(0) EndFunc
×
×
  • Create New...