Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/29/2024 in all areas

  1. Melba23

    furian

    I do hope this does not become a habit.... When, in your opinion, your thread is unfairly locked, the Mod team are always open to receiving a courteous and well-argued PM from you explaining why you felt your thread should not been. But sending a diatribe, incorrectly interpreting the forum rules, and trying to bully us into reopening it will not work. If you then send further meassages in the same vein you cannot really expect anything other then the inevitable. Particularly when challenging the Mod in question to ban you. M23
    3 points
  2. You can't directly connect to your wifi through the command prompt (eg. netsh), however there's always some work around. I've never worked with NETSH before, but I played around for a while with it. I'll be honest, I've never been a fan of using the command prompts of apps, for some reason I feel like I have less control. These are make-shift udfs I just put together, some were my practice funcs, but if you look at the ones I point out at the top, they may help you. The last one, if the first two function calls fail, is one where you can create a tmp xml file, add that profile, run the netsh command then delete the tmp xml file. All of these worked on the my Windows 10 machine. Should work on Windows 11 too from what I was reading. ;~ #RequireAdmin ; may need to have admin priviliges #include-once #include <AutoItConstants.au3> #include <StringConstants.au3> #include <FileConstants.au3> Global $gsMySSID_WifiName = "MyNetwork" ; obviously change it to your own network name If Not _AutNETSH_WLan_IsConnectedBy("SSID", $gsMySSID_WifiName) Then ConsoleWrite("Going to attempt to connect.." & @CRLF) _AutNETSH_WLan_ConnectionRequest($gsMySSID_WifiName) Sleep(5000) ; give it 5 seconds and check if it worked If Not _AutNETSH_WLan_IsConnectedBy("SSID", $gsMySSID_WifiName) Then ConsoleWrite("Still not connected, does the profile exist yet?" & @CRLF & _ "If the profile doesn't exist, or the password/username changes often, try using: " & @CRLF & _ "_AutNETSH_WLan_AddConnectionRequest() below somwwhere..." & @CRLF) EndIf EndIf Func _AutNETSH_WLan_IsConnectedBy($sType, $sFind, $sWkDir = Default) ; because @error may return error text ; we'll just return yes or no string If $sWkDir = Default Or $sWkDir = -1 Then $sWkDir = @UserProfileDir EndIf Local $iPID = Run("netsh wlan show interface", $sWkDir, @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) Local $aRead = _AutNETSH_WLan_STDRead($iPID) If @error Then Return SetError(1, 0, StringRegExpReplace($aRead[1], "(?s)^\s*|\s*$", "")) EndIf ; escape type and value to find $sType = __AutNETSH_WLan_EscapeDelimiters($sType) $sFind = __AutNETSH_WLan_EscapeDelimiters($sFind) Local $sStRE = "(*UCP)(?mi)\h*" & $sType & "\h*\:\h*" & $sFind & "\h*$" Return (StringRegExp($aRead[0], $sStRE) <> 0) EndFunc Func _AutNETSH_WLan_IsConnected($sWkDir = Default) ; because @error may return error text ; we'll just return yes or no string If $sWkDir = Default Or $sWkDir = -1 Then $sWkDir = @UserProfileDir EndIf Local $iPID = Run("netsh wlan show interface", $sWkDir, @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) Local $aRead = _AutNETSH_WLan_STDRead($iPID) If @error Then Return SetError(1, 0, StringRegExpReplace($aRead[1], "(?s)^\s*|\s*$", "")) EndIf Local Const $sStRE = "(*UCP)(?mi)\h*state\h*\:\h*(\w+)" Local $aRet = StringRegExp($aRead[0], $sStRE, $STR_REGEXPARRAYGLOBALMATCH) If Not IsArray($aRet) Then Return SetError(2, 0, "") EndIf Return $aRet[0] EndFunc Func _AutNETSH_WLan_ConnectionRequest($sSSID, $sWkDir = Default) If $sWkDir = Default Or $sWkDir = -1 Then $sWkDir = @UserProfileDir EndIf ; connect to profile Local $iPID = Run('netsh wlan connect name="' & $sSSID & '"', $sWkDir, @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) Local $aRead = _AutNETSH_WLan_STDRead($iPID) If @error Then Return SetError(1, 0, StringRegExpReplace($aRead[1], "(?s)^\s*|\s*$", "")) EndIf Return $aRead[0] EndFunc Func _AutNETSH_WLan_AddConnectionRequest($sSSID, $sPassword, $sConnectionType = Default, _ $sConnectionMode = Default, $sAuthentication = Default, _ $sEncryption = Default, $sUseOneX = Default, $sKeyType = Default, _ $sProtected = Default, $sEnableRandomization = Default, _ $sWkDir = Default, $sTmpPath = Default) If $sConnectionType = Default Or $sConnectionType = -1 Then $sConnectionType = "ESS" EndIf If $sConnectionMode = Default Or $sConnectionMode = -1 Then $sConnectionMode = "auto" EndIf If $sAuthentication = Default Or $sAuthentication = -1 Then $sAuthentication = "WPA2PSK" EndIf If $sEncryption = Default Or $sEncryption = -1 Then $sEncryption = "AES" EndIf If $sUseOneX = Default Or $sUseOneX = -1 Then $sUseOneX = "false" EndIf If $sKeyType = Default Or $sKeyType = -1 Then $sKeyType = "passPhrase" EndIf If $sProtected = Default Or $sProtected = -1 Then $sProtected = "false" EndIf If $sEnableRandomization = Default Or $sEnableRandomization = -1 Then $sEnableRandomization = "false" EndIf If $sWkDir = Default Or $sWkDir = -1 Then $sWkDir = @UserProfileDir EndIf If $sTmpPath = Default Or $sTmpPath = -1 Or Not FileExists($sTmpPath) Then $sTmpPath = @ScriptDir EndIf Local $sXMLFile = "WLAN." & StringRegExpReplace($sSSID, "(*UCP)\W", "") $sXMLFile &= ".tmp(" & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & @MSEC & ").xml" Local $sOutXML = StringRegExpReplace($sTmpPath, "[\\/]+$", "") & "\" & $sXMLFile Local $sXML = "" $sXML &= '<?xml version="1.0"?>' & @CRLF $sXML &= ' <WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">' & @CRLF $sXML &= ' <name>' & $sSSID & '</name>' & @CRLF $sXML &= ' <SSIDConfig>' & @CRLF $sXML &= ' <SSID>' & @CRLF $sXML &= ' <name>' & $sSSID & '</name>' & @CRLF $sXML &= ' </SSID>' & @CRLF $sXML &= ' </SSIDConfig>' & @CRLF $sXML &= ' <connectionType>' & $sConnectionType & '</connectionType>' & @CRLF $sXML &= ' <connectionMode>' & $sConnectionMode & '</connectionMode>' & @CRLF $sXML &= ' <MSM>' & @CRLF $sXML &= ' <security>' & @CRLF $sXML &= ' <authEncryption>' & @CRLF $sXML &= ' <authentication>' & $sAuthentication & '</authentication>' & @CRLF $sXML &= ' <encryption>' $sEncryption & '</encryption>' & @CRLF $sXML &= ' <useOneX>' & $sUseOneX & '</useOneX>' & @CRLF $sXML &= ' </authEncryption>' & @CRLF $sXML &= ' <sharedKey>' & @CRLF $sXML &= ' <keyType>' & $sKeyType & '</keyType>' & @CRLF $sXML &= ' <protected>' & $sProtected & '</protected>' & @CRLF $sXML &= ' <keyMaterial>' & $sPassword & '</keyMaterial>' & @CRLF $sXML &= ' </sharedKey>' & @CRLF $sXML &= ' </security>' & @CRLF $sXML &= ' </MSM>' & @CRLF $sXML &= ' <MacRandomization xmlns="http://www.microsoft.com/networking/WLAN/profile/v3">' & @CRLF $sXML &= ' <enableRandomization>' & $sEnableRandomization & '</enableRandomization>' & @CRLF $sXML &= ' </MacRandomization>' & @CRLF $sXML &= '</WLANProfile>' Local $hOpen = FileOpen($sOutXML, $FO_OVERWRITE) FileWrite($hOpen, $sXML) FileClose($hOpen) ; add profile to cache Local $iPID = Run('netsh wlan add profile filename="' & $sOutXML & '"', $sWkDir, @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) Local $aRead = _AutNETSH_WLan_STDRead($iPID) If @error Then FileDelete($sOutXML) Return SetError(1, 0, StringRegExpReplace($aRead[1], "(?s)^\s*|\s*$", "")) EndIf Local $sRet = $aRead[0] ; connect to profile $iPID = Run('netsh wlan connect name="' & $sSSID & '"', $sWkDir, @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) $aRead = _AutNETSH_WLan_STDRead($iPID) If @error Then FileDelete($sOutXML) Return SetError(2, 0, StringRegExpReplace($aRead[1], "(?s)^\s*|\s*$", "")) EndIf FileDelete($sOutXML) $sRet &= " : " & $aRead[0] Return $sRet EndFunc Func _AutNETSH_WLan_ShowNetworks($sWkDir = Default) ; return network array If $sWkDir = Default Or $sWkDir = -1 Then $sWkDir = @UserProfileDir EndIf Local $iPID = Run("netsh wlan show networks", $sWkDir, @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) Local $aRead = _AutNETSH_WLan_STDRead($iPID) If @error Or Not IsArray($aRead) Then Return SetError(1, @error, StringRegExpReplace($aRead[1], "(?s)^\s*|\s*$", "")) EndIf Local Const $sSSIDRE = "(?si)(SSID\h*\d+\h*\:\h*.+?)(?:\v{3,}|$)" Local $aSSIDs = StringRegExp($aRead[0], $sSSIDRE, $STR_REGEXPARRAYGLOBALMATCH) If @error Or Not IsArray($aSSIDs) Then Return SetError(2, @error, "") EndIf Local $aHeaders = __AutNETSH_WLan_stdoutgetheader($aSSIDs) If @error Then Return SetError(3, @error, "") EndIf Local $aHData = __AutNETSH_WLan_stdoutgethdata($aSSIDs, $aHeaders) If @error Then Return SetError(4, @error, "") EndIf Return $aHData EndFunc ; See RunAs() in help file, may need to sign on as admin acct Func _AutNETSH_WLan_ShowNetworksAsUser($sUserName, $sDomain, $sPassword, $sLogonFlag, $sWkDir = Default) ; return network array If $sWkDir = Default Or $sWkDir = -1 Then $sWkDir = @UserProfileDir EndIf Local $iPID = RunAs($sUserName, $sDomain, $sPassword, $sLogonFlag, _ "netsh wlan show networks", $sWkDir, @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) Local $aRead = _AutNETSH_WLan_STDRead($iPID) If @error Or Not IsArray($aRead) Then Return SetError(1, 0, StringRegExpReplace($aRead[1], "(?s)^\s*|\s*$", "")) EndIf Local Const $sSSIDRE = "(?si)(SSID\h*\d+\h*\:\h*.+?)(?:\v{3,}|$)" Local $aSSIDs = StringRegExp($aRead[0], $sSSIDRE, $STR_REGEXPARRAYGLOBALMATCH) If @error Or Not IsArray($aSSIDs) Then Return SetError(2, @error, "") EndIf Local $aHeaders = __AutNETSH_WLan_stdoutgetheader($aSSIDs) If @error Then Return SetError(3, @error, "") EndIf Local $aHData = __AutNETSH_WLan_stdoutgethdata($aSSIDs, $aHeaders) If @error Then Return SetError(4, @error, "") EndIf Return $aHData EndFunc Func _AutNETSH_WLan_STDRead($iPID) $iPID = ProcessExists($iPID) If Not $iPID Then Return SetError(1, 0, 0) EndIf Local $sTmp, $sORead, $sOErr While ProcessExists($iPID) $sTmp = StdoutRead($iPID) If @error Then $sOErr = StderrRead($iPID) ExitLoop EndIf $sORead &= $sTmp WEnd ; clean up leading and traling $sORead = StringRegExpReplace($sORead, "(?s)^\s*|\s*$", "") $sOErr = StringRegExpReplace($sOErr, "(?s)^\s*|\s*$", "") Local $aRet[2] = [$sORead, $sOErr] If StringLen($sORead) = 0 Then Return SetError(1, 0, $aRet) EndIf Return $aRet EndFunc Func __AutNETSH_WLan_stdoutgetheader(ByRef $aData) If Not IsArray($aData) Then Return SetError(1, 0, 0) EndIf ; how many heades, some will have more/less based on connection type Local $iExt, $iHeaderCount = 0, $aHeaders For $i = 0 To UBound($aData) - 1 StringRegExpReplace($aData[$i], "(?m)\h+\:", "") $iExt = @extended If $iExt > $iHeaderCount Then $iHeaderCount = $iExt $aHeaders = StringRegExp($aData[$i], "(?m)\h*(.+?)\h+\:", $STR_REGEXPARRAYGLOBALMATCH) If IsArray($aHeaders) Then For $j = 0 To UBound($aHeaders) - 1 If StringInStr($aHeaders[$j], "SSID") Then $aHeaders[$j] = "SSID" ExitLoop EndIf Next EndIf EndIf Next If $iHeaderCount = 0 Then Return SetError(2, 0, 0) EndIf Return SetExtended($iHeaderCount, $aHeaders) EndFunc Func __AutNETSH_WLan_stdoutgethdata(ByRef $aData, ByRef $aHeaders) If Not IsArray($aData) Then Return SetError(1, 0, 0) EndIf If Not IsArray($aHeaders) Then Return SetError(2, 0, 0) EndIf ; [0][n] = headers Local $aRet[UBound($aData) + 1][UBound($aHeaders)] ; fill headers into ret array For $i = 0 To UBound($aHeaders) - 1 $aRet[0][$i] = $aHeaders[$i] ; turn headers into escaped chars $aHeaders[$i] = __AutNETSH_WLan_EscapeDelimiters($aHeaders[$i]) Next Local $aFound, $aLines, $iEnum, $iColCount = 0 ; start at 1, 0 is headers For $i = 0 To UBound($aData) - 1 $iEnum = 0 ; split into individual rows $aLines = StringRegExp($aData[$i], "\h*(.+?)\h*(\v+|$)", $STR_REGEXPARRAYGLOBALMATCH) For $x = 0 To UBound($aLines) - 1 For $j = 0 To UBound($aHeaders) - 1 If StringRegExp($aLines[$x], "(?i)^\h*" & $aHeaders[$j]) Then $aFound = StringRegExp($aLines[$x], "(?mi)\h*" & $aHeaders[$j] & ".*?\:\h*(.+?)\h*$", $STR_REGEXPARRAYGLOBALMATCH) If @error Or Not IsArray($aFound) Then ContinueLoop $aRet[$i + 1][$j] = $aFound[0] $iEnum += 1 ExitLoop EndIf Next Next If $iEnum > 0 Then $iColCount += 1 Next If $iColCount < UBound($aData) Then ; oops EndIf Return $aRet EndFunc Func __AutNETSH_WLan_EscapeDelimiters($sData) Local Const $sRE = "([\\\.\^\$\|\[|\]\(\)\{\}\*\+\?\#])" Local Const $sRep = "\\$1" Return StringRegExpReplace($sData, $sRE, $sRep) EndFunc If you're going to do this across a private network, you may want to look into RunAs(), I have one example function in there with that that you can kind of get the idea from. Anyway, I did more than I thought I would for something I can never see myself using... so hope it helps. Edit: You may need to change this section for enterprise: $sXML &= ' <authEncryption>' & @CRLF $sXML &= ' <authentication>WPA2PSK</authentication>' & @CRLF $sXML &= ' <encryption>AES</encryption>' & @CRLF $sXML &= ' <useOneX>false</useOneX>' & @CRLF $sXML &= ' </authEncryption>' & @CRLF I'm to lazy to make something that does it atm. Edit2: Changed _AutNETSH_WLan_AddConnectionRequest() so you can customize all the xml options if needed. I'm not 100% on WPA2 Enterprise, but it looks like you can change Authentication = WPA2 and Encryption to TKIP... anyway, really really really done this time
    3 points
  3. I updated the original, fixed it with If WinExists($hParent) Then it's an attempt to hide the window only when i'm in front
    1 point
  4. How about a third option : #include <GUIConstants.au3> #include <WinAPIConstants.au3> #include <WinAPISys.au3> Global Const $tagMSLLHOOKSTRUCT = $tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo" Global $hHook, $hGUI, $hParent Run("Notepad") $hParent = WinWait("[CLASS:Notepad]") HideOnDrag() Func HideOnDrag() $hGUI = GUICreate("ControlParent", Default, Default, Default, Default, $WS_POPUP, $WS_EX_TOPMOST + $WS_EX_CONTROLPARENT) GUISetState() Local $hStub = DllCallbackRegister(WinProc, "lresult", "int;wparam;lparam") $hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($hStub), _WinAPI_GetModuleHandle(0)) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _WinAPI_UnhookWindowsHookEx($hHook) DllCallbackFree($hStub) WinClose($hParent) EndFunc ;==>HideOnDrag Func WinProc($iMsg, $wParam, $lParam) Local Static $bSet = False Local $tMSLLHOOKSTRUCT If $iMsg = 0 Then If $wParam = $WM_LBUTTONDOWN Then $tMSLLHOOKSTRUCT = DllStructCreate($tagMSLLHOOKSTRUCT, $lParam) $aPos = WinGetPos($hGUI) If $tMSLLHOOKSTRUCT.X >= $aPos[0] And $tMSLLHOOKSTRUCT.X <= $aPos[0] + $aPos[2] And _ $tMSLLHOOKSTRUCT.Y >= $aPos[1] And $tMSLLHOOKSTRUCT.Y <= $aPos[1] + $aPos[3] Then ConsoleWrite("down" & @CRLF) WinSetTrans($hParent, "", 70) $bSet = True EndIf ElseIf $wParam = $WM_LBUTTONUP And $bSet Then ConsoleWrite("up" & @CRLF) WinSetTrans($hParent, "", 255) $bSet = False EndIf EndIf Return _WinAPI_CallNextHookEx($hHook, $iMsg, $wParam, $lParam) EndFunc ;==>WinProc
    1 point
  5. #include <GUIConstants.au3> #include <Misc.au3> #include <WinAPISysWin.au3> ; For _SendMessage And Draggable #include <WinAPIvkeysConstants.au3> Global $dll = DllOpen("user32.dll") Global Const $SC_DRAGMOVE = 0xF012 Run("Notepad.exe") Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase WinWait("Notepad", "") Global $hParent = WinGetHandle("Notepad", "") HideOnDrag(255) ;---------------------------------------------------------------------------------------- Func HideOnDrag($startTransparency) Global $hGUI = GUICreate("Example", Default, Default, Default, Default, $WS_POPUP, $WS_EX_TOPMOST) GUISetState() WinSetTrans($hParent, "", $startTransparency) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _Quit() EndSwitch _IsDrag() WEnd EndFunc ;==>HideOnDrag ;---------------------------------------------------------------------------------------- Func _IsDrag() Local $hDLL = DllOpen("user32.dll") If _IsPressed("01", $hDLL) Then ; 01 Left mouse button WinSetTrans($hParent, "", 50) While _IsPressed("01", $hDLL) _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) Sleep(10) WEnd EndIf WinSetTrans($hParent, "", 255) DllClose($hDLL) EndFunc ;==>_IsDrag ;---------------------------------------------------------------------------------------- Func _Quit() SplashTextOn("Notice", "Closing") Sleep(200) SplashOff() Exit EndFunc ;==>_Quit ;----------------------------------------------------------------------------------------
    1 point
  6. @Melba23 you mentioned this link in the past and I tried a few ways there but just couldn't get it right. After some persistence I finally got it: #include <GUIConstants.au3> #include <Misc.au3> HotKeySet("+{ESC}", "_Quit") ; ^Ctrl !Alt +Shift Global $dll = DllOpen("user32.dll") Global Const $SC_DRAGMOVE = 0xF012 Global $bGetNext = False Run("Notepad.exe") Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase WinWait("Notepad", "") Global $hParent = WinGetHandle("Notepad", "") HideOnDrag(255) Func HideOnDrag($startTransparency) Global $hGUI = GUICreate("Hidden Title", Default, Default, Default,Default, $WS_POPUP, $WS_EX_TOPMOST) GUISetBkColor(0x0000BB) GUISetState() WinSetTrans($hParent, "", $startTransparency) GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") Do Sleep(5) Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If $hWnd = $hGui and $iMsg = $WM_NCHITTEST then If _IsMouseButtonDown() Then ConsoleWrite("Down" & @CRLF) WinSetTrans($hParent,"",20) $bGetNext = True ElseIf $bGetNext Then ConsoleWrite("Up" & @CRLF) WinSetTrans($hParent,"",250) $bGetNext = False EndIf Return $HTCAPTION EndIf EndFunc Func _IsMouseButtonDown() If _IsPressed(01, $dll) Then Return True EndIf Return False EndFunc Func _Quit() SplashTextOn("Notice", "Closing") DllClose($dll) Sleep(200) SplashOff() Exit EndFunc ;==>_Quit
    1 point
  7. Every time I see your posted code, I see some kind of magic. What I especially like is that it's in 24 hour whereas mine was in 12. Less massaging 😅 Thank you @Nine.
    1 point
  8. I'm humbled. Truly. 😊 I was hoping to "take ownership" of the key and make it all official looking, you know? HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\rsn.reboot.nag Or something like that. 🤣 I'm looking at the code for the date/time calculation and man is it a pile of slop. I never expected a real programmer to ask to see it! I'm an old school cmd scripter and it shows. The data in LastNotificationAddedTime is in NT time epoch. And in this case I was using w32tm.exe to do the calculations. So the basic snippet looks like the following. In this example, I'm defining $iLastNotificationAddedTime when in the actual I'm fetching it from the registry. $iLastNotificationAddedTime = "133552598496093801" $iPID = Run( @ComSpec & ' /c for /f "tokens=1-8 delims=/ " %a in ' & "( 'w32tm /ntte " & $iLastNotificationAddedTime & "' ) do @echo %f/%d/%e %g", "", @SW_HIDE, $STDOUT_CHILD) It changes the output from normal: "154574 18:24:09.6093801 - 3/18/2024 2:24:09 PM" to "2024/3/18 2:24:09" so I can further massage it for date math.
    1 point
  9. Just use GDI+. I do not know this UDF, but it seems to create a .bmp file from scratch. #include <GDIPlus.au3> #include <GUIConstants.au3> _GDIPlus_Startup() Local $hBitmap = _GDIPlus_BitmapCreateFromScan0(200, 200) Local $tBitmapData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, 200, 200, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD), $GDIP_PXF32ARGB) Local $iScan0 = DllStructGetData($tBitmapData, "Scan0") Local $tPixel = DllStructCreate("int[" & 200 * 200 & "];", $iScan0) PixelWrite($tPixel, 200, 0, 0, 99, 99, 0xFFFF0000) PixelWrite($tPixel, 200, 100, 0, 199, 99, 0xFF00FF00) PixelWrite($tPixel, 200, 0, 100, 99, 199, 0xFF0000FF) PixelWrite($tPixel, 200, 100, 100, 199, 199, 0xFF00FFFF) _GDIPlus_BitmapUnlockBits($hBitmap, $tBitmapData) Local $hGUI = GUICreate("Example", 200, 200) GUISetState() Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() Func PixelWrite(ByRef $tStruc, $iWidth, $iXs, $iYs, $iXe, $iYe, $nColor) For $j = $iYs To $iYe $iRowOffset = $j * $iWidth + 1 For $i = $iXs To $iXe DllStructSetData($tStruc, 1, $nColor, $iRowOffset + $i) Next Next EndFunc
    1 point
  10. @Nine I tried your notification code and it consistently creates an ownership reg entry on my test box: HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\Microsoft.Explorer.Notification.{EF042132-5191-5B05-CE52-68DCD8D3A677} Is there a way to create the notification key with a user defined name? Previously, I've been using TrayTip() to create the notifications but it creates a different key each run. So I've been enumerating the registry before and after to get the key name.
    1 point
  11. This UDF provides algorithms for fuzzy string comparison and the associated similarity search in string arrays. It offers functions for character-based comparisons, comparing the phonetics of words and the geometric distance of characters on a keyboard. In this way, typing errors can be recognized, similar-sounding words can be detected and other spellings of words can be included in further processing. The current function list of the UDF: --------- fuzzy array handling: _FS_ArraySearchFuzzy - finds similar entries for a search value in an array _FS_ArrayToPhoneticGroups - groups the values of an array according to their phonetics --------- character-based metrics: _FS_Levenshtein - calculate the levenshtein distance between two strings _FS_OSA - calculate the OSA ("optimal string alignment") between two strings _FS_Hamming - calculate the hamming distance between two strings --------- phonetic metrics: _FS_Soundex_getCode - calculate the soundex code for a given word to represent the pronounciation in english _FS_Soundex_distance - calculate the soundex-pattern for both input values _FS_SoundexGerman_getCode - calculate the modified soundex code for german language for a given word to represent the pronounciation in german _FS_SoundexGerman_distance - calculate the soundexGerman-pattern for both input values _FS_Cologne_getCode - calculate the cologne phonetics code for german language for a given word to represent the pronounciation in german _FS_Cologne_distance - calculate the cologne phonetics distance between both input values --------- key-position based metrics: _FS_Keyboard_GetLayout - return a map with coordinates for the characters for using in _FS_Keyboard_Distance_Chars() _FS_Keyboard_Distance_Chars - calculates the geometric key spacing between two characters on a keyboard _FS_Keyboard_Distance_Strings - calculate the keyboard-distance between two strings >>sourcecode and download on github<<
    1 point
  12. OK I understand What about this one ? #include <GuiConstantsEx.au3> #include <Windowsconstants.au3> #include <SendMessage.au3> HotKeySet("{ESC}", "On_Exit") ; Set distance from edge of window where resizing is possible Global Const $iMargin = 4 ; Set max and min GUI sizes Global Const $iGUIMinX = 50, $iGUIMinY = 50, $iGUIMaxX = 300, $iGUIMaxY = 300 Global $tPoint = DllStructCreate("struct; long X;long Y; endstruct") ; Create GUI $hGUI = GUICreate("Y", 100, 100, -1, -1, $WS_POPUP) GUISetBkColor(0x00FF00) GUISetState() ; Register message handlers GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") ; For resize/drag GUIRegisterMsg($WM_MOUSEMOVE, "_SetCursor") ; For cursor type change GUIRegisterMsg($WM_GETMINMAXINFO, "_WM_GETMINMAXINFO") ; For GUI size limits While 1 Sleep(10) WEnd ; Check cursor type and resize/drag window as required Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) Local $iCursorType = _GetBorder() If $iCursorType > 0 Then ; Cursor is set to resizing style $iResizeType = 0xF000 + $iCursorType _SendMessage($hGUI, $WM_SYSCOMMAND, $iResizeType, 0) Else Local $aCurInfo = GUIGetCursorInfo($hGUI) If $aCurInfo[4] = 0 Then ; Mouse not over a control DllCall("user32.dll", "int", "ReleaseCapture") _SendMessage($hGUI, $WM_NCLBUTTONDOWN, $HTCAPTION, 0) EndIf EndIf EndFunc ;==>WM_LBUTTONDOWN ; Set cursor to correct resizing form if mouse is over a border Func _SetCursor() DllStructSetData($tPoint, "x", MouseGetPos(0)) DllStructSetData($tPoint, "y", MouseGetPos(1)) Local $aResult = DllCall("user32.dll", "hwnd", "WindowFromPoint", "struct", $tPoint) If $aResult[0] <> $hGUI Then Return Local $iCursorID Switch _GetBorder() Case 0 $iCursorID = 2 ; arrow Case 1, 2 $iCursorID = 13 ; SIZEWE Case 3, 6 $iCursorID = 11 ; SIZENS Case 5, 7 $iCursorID = 10 ; SIZENESW Case 4, 8 $iCursorID = 12 ; SIZENWSE EndSwitch GUISetCursor($iCursorID, 1) EndFunc ;==>SetCursor ; Determines if mouse cursor over a border Func _GetBorder() Local $aMPos = MouseGetPos() Local $aWinPos = WinGetPos($hGUI) Local $iSide = 0 Local $iTopBot = 0 If $aMPos[0] < $aWinPos[0] + $iMargin Then $iSide = 1 If $aMPos[0] > $aWinPos[0] + $aWinPos[2] - $iMargin Then $iSide = 2 If $aMPos[1] < $aWinPos[1] + $iMargin Then $iTopBot = 3 If $aMPos[1] > $aWinPos[1] + $aWinPos[3] - $iMargin Then $iTopBot = 6 Return $iSide + $iTopBot EndFunc ;==>_GetBorder ; Set min and max GUI sizes Func _WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam) $tMinMaxInfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($tMinMaxInfo, 7, $iGUIMinX) DllStructSetData($tMinMaxInfo, 8, $iGUIMinY) DllStructSetData($tMinMaxInfo, 9, $iGUIMaxX) DllStructSetData($tMinMaxInfo, 10, $iGUIMaxY) Return 0 EndFunc ;==>_WM_GETMINMAXINFO Func On_Exit() Exit EndFunc
    1 point
  13. Allow2010, The Moving and Resizing PopUp GUIs tutorial in the Wiki will explain several ways to do this - two of which have already been suggested. M23
    1 point
×
×
  • Create New...