Jump to content
Sign in to follow this  
momar33

Wandering Button (When Gui set to Fullscreen and Button is Redrawn)

Recommended Posts

momar33

I am seeing a buttons position change when the following happens.

1. GUI created at 800 x 600

2. GUI info is stored using WinGetPos

3. GUI changed to full-screen using WinMove

4. Button info is stored using ControlGetPos

5. Button is deleted

6. Button is re-created using the stored data from item 4.

7. GUI is restored to the info gathered in item 2.

The button starts with this info:

Button Left:   408
Button Top:    84
Button Width:  80
Button Height: 24
 
and after the events above the button has this info:
Button Left:   409
Button Top:    83
Button Width:  80
Button Height: 24
 
Here is some code that can reproduce the issue:
(press space, f, space, f, then look in the console)
#Region Includes

#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <Array.au3>

#EndRegion Includes

Const $HT_KEY_FULLSCREEN = "f"
Const $HT_KEY_SPACE = "{SPACE}"

Global $btnAddRebuy[21]
Global $btnRemovePlayer[21]

Global $fFullscreen = False

Global $aGuiInfo
Global $aGuiInfo2

Global $guiWidth  = 800
Global $guiHeight = 600


#Region Dimensions for Settings Screen

; Player
Global $lblPlayerTop    = 60

Global $playerLabelSpace = 24


; Add Rebuy Button
Global $btnRebuyLeft    = 320
Global $btnRebuyWidth   = 80
Global $btnRebuyHeight  = 24

; Remove Player
Global $btnRemoveLeft   = 408
Global $btnRemoveWidth  = 80
Global $btnRemoveHeight = 24

#EndRegion Dimensions for Settings Screen





$hMain = GUICreate("Timer", $guiWidth, $guiHeight, -1, -1, BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION,$WS_OVERLAPPEDWINDOW,$WS_TILEDWINDOW,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_TABSTOP,$WS_BORDER,$WS_CLIPSIBLINGS))


For $i = 1 To 5 Step 1  
    $btnAddRebuy[$i] = GUICtrlCreateButton("Button", $btnRebuyLeft, $lblPlayerTop + ($playerLabelSpace * $i), $btnRebuyWidth, $btnRebuyHeight)
    GUICtrlSetResizing($btnAddRebuy[$i], $GUI_DOCKAUTO)
    GuiCtrlSetState($btnAddRebuy[$i], $GUI_DISABLE)
    
    $btnRemovePlayer[$i] = GUICtrlCreateButton("Button", $btnRemoveLeft, $lblPlayerTop + ($playerLabelSpace * $i), $btnRemoveWidth, $btnRemoveHeight)
    ;GUICtrlSetResizing($btnRemovePlayer[$i], $GUI_DOCKAUTO)
 Next
 
GUISetState(@SW_SHOW)

HotKeySet($HT_KEY_FULLSCREEN, "Fullscreen")
HotKeySet($HT_KEY_SPACE, "Redraw")
 
While 1
   $msg = GUIGetMsg()
   If $msg = $GUI_EVENT_CLOSE Then
      ExitLoop
   EndIf
WEnd

Func Fullscreen()
    If WinActive($hMain) Then
        If $fFullscreen Then
            ;GUISetStyle(BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION,$WS_OVERLAPPEDWINDOW,$WS_TILEDWINDOW,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_TABSTOP,$WS_BORDER,$WS_CLIPSIBLINGS), Default, $hMain)
            $aGuiInfo2 = WinGetPos($hMain)
            ConsoleWrite("******* Fullscreen *******" & @LF)
            ConsoleWrite("Win Left:   " & $aGuiInfo2[0] & @LF)
            ConsoleWrite("Win Top:    " & $aGuiInfo2[1] & @LF)
            ConsoleWrite("Win Width:  " & $aGuiInfo2[2] & @LF)
            ConsoleWrite("Win Height: " & $aGuiInfo2[3] & @LF & @LF)
            ;WinMove($hMain, Default, $aGuiInfo[0], $aGuiInfo[1], $aGuiInfo[2], $aGuiInfo[3])
            WinMove($hMain, Default, 238, 179, 816, 638)
            $fFullscreen = False
            
            $aCtrlInfo = ControlGetPos($hMain, "", $btnRemovePlayer[1])
            ConsoleWrite("******* Button Info after Restored *******" & @LF)
            ConsoleWrite("Button Left:   " & $aCtrlInfo[0] & @LF)
            ConsoleWrite("Button Top:    " & $aCtrlInfo[1] & @LF)
            ConsoleWrite("Button Width:  " & $aCtrlInfo[2] & @LF)
            ConsoleWrite("Button Height: " & $aCtrlInfo[3] & @LF & @LF)
        Else
            ;GUISetStyle($WS_POPUP, Default, $hMain)
            $aGuiInfo = WinGetPos($hMain)
            ConsoleWrite("******* Start Size *******" & @LF)
            ConsoleWrite("Win Left:   " & $aGuiInfo[0] & @LF)
            ConsoleWrite("Win Top:    " & $aGuiInfo[1] & @LF)
            ConsoleWrite("Win Width:  " & $aGuiInfo[2] & @LF)
            ConsoleWrite("Win Height: " & $aGuiInfo[3] & @LF & @LF)
            WinMove($hMain, Default, 0, 0, @DesktopWidth, @DesktopHeight)
            $fFullscreen = True
            
            $aCtrlInfo = ControlGetPos($hMain, "", $btnRemovePlayer[1])
            ConsoleWrite("******* Button Info after Fullscreened *******" & @LF)
            ConsoleWrite("Button Left:   " & $aCtrlInfo[0] & @LF)
            ConsoleWrite("Button Top:    " & $aCtrlInfo[1] & @LF)
            ConsoleWrite("Button Width:  " & $aCtrlInfo[2] & @LF)
            ConsoleWrite("Button Height: " & $aCtrlInfo[3] & @LF & @LF)
        EndIf
    Else
        HotKeySet($HT_KEY_FULLSCREEN)
        Send($HT_KEY_FULLSCREEN)
        HotKeySet($HT_KEY_FULLSCREEN, "Fullscreen")
    EndIf
 EndFunc


Func Redraw()
      Local $aCtrlInfo
      $aCtrlInfo = ControlGetPos($hMain, "", $btnRemovePlayer[1])
      ConsoleWrite("******* Button Info before Redraw *******" & @LF)
      ConsoleWrite("Button Left:   " & $aCtrlInfo[0] & @LF)
      ConsoleWrite("Button Top:    " & $aCtrlInfo[1] & @LF)
      ConsoleWrite("Button Width:  " & $aCtrlInfo[2] & @LF)
      ConsoleWrite("Button Height: " & $aCtrlInfo[3] & @LF & @LF)
      GuiCtrlDelete($btnRemovePlayer[1])

      $btnRemovePlayer[1] = GUICtrlCreateButton("Button", $aCtrlInfo[0], $aCtrlInfo[1], $aCtrlInfo[2], $aCtrlInfo[3])
      ;GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
      
      $aCtrlInfo = ControlGetPos($hMain, "", $btnRemovePlayer[1])
      ConsoleWrite("******* Button Info after Redraw *******" & @LF)
      ConsoleWrite("Button Left:   " & $aCtrlInfo[0] & @LF)
      ConsoleWrite("Button Top:    " & $aCtrlInfo[1] & @LF)
      ConsoleWrite("Button Width:  " & $aCtrlInfo[2] & @LF)
      ConsoleWrite("Button Height: " & $aCtrlInfo[3] & @LF & @LF)

EndFunc
Is there a way to fix this, or is the issue built in to how windows get resized?
 

Share this post


Link to post
Share on other sites
Melba23

momar33,

Why not use the correct GUICtrlResizing mode (you can set it globally using Opt) and then just hide/show the button rather then deleting/recreating it? That would save a lot of code and keep it in the correct place. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
momar33

I am using $GUI_DOCKAUTO in my actual program, but removed it for simplification.

With $GUI_DOCKAUTO set, this still happens just slightly differently.

The code posted is the result of weeding out unnecessary code.

Hiding/Showing will not work for me. I change the button color which makes the button "Windows Classic Style", I redraw the button to get the 3d button back.

What I am doing is using a colored button to show a more prominent tab focus.

(Down button changes the focus (and background color) of the next button down, then redraws the button that previously had focus).

Share this post


Link to post
Share on other sites
Melba23

momar33,

Because of a bug deep in the core code (and therefore very unlikely ever to be fixed) colouring buttons is not a good idea in AutoIt - they trap the ENTER key for a start and lose styles for another. :(

Whenever I need to highlight a button I place a slightly larger label underneath it (and disable it to prevent Autoit getting confused and actioning neither) and then change the colour of that label when required. That way the button remains "standard" and perfectly useable. Here is a short example:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

$hGUI = GUICreate("Test", 500, 500)

$cLabel_1 = GUICtrlCreateLabel("", 8, 8, 84, 34)
GUICtrlSetState($cLabel_1, $GUI_DISABLE)
$cButton_1 = GUICtrlCreateButton("One", 10, 10, 80, 30)

$cLabel_2 = GUICtrlCreateLabel("", 8, 48, 84, 34)
GUICtrlSetState($cLabel_2, $GUI_DISABLE)
GUICtrlSetBkColor($cLabel_2, 0xFF0000)
$cButton_2 = GUICtrlCreateButton("Two", 10, 50, 80, 30)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cButton_1
            GUICtrlSetBkColor($cLabel_1, 0xFFFFFF)
            GUICtrlSetBkColor($cLabel_2, 0xFF0000)
        Case $cButton_2
            GUICtrlSetBkColor($cLabel_2, 0xFFFFFF)
            GUICtrlSetBkColor($cLabel_1, 0xFF0000)
    EndSwitch
WEnd
Any use? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
momar33

M23,

I had actually thought about that method at one time, but for whatever reason decided against it.  (or it may have been a backup idea)

I will likely use that method if I can't figure out the issue in the OP.

Do you have any idea what is causing the issue in the OP?

It doesn't appear to be an issue with my code, but I was kinda hoping it was and I just missed it.

Thanks,

M33

Share this post


Link to post
Share on other sites
Melba23

momar33,

 

Do you have any idea what is causing the issue in the OP?

Not really. GUI resizing and storing control coordinates for redrawing is always fraught with difficulty - which is why I tend to go for the hide/show method and let AutoIt look after control position and size for me. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • Pike
      By Pike
      Hello Everyone,
      New Guy here. This is a two-part question, hopefully easy enough though. I know it's ugly coding, this is because I have only a couple hours worth of coding experience and could really use some help.
      1) When I single click the button I want one action (like playing a sound clip) and when I double click the button I want a different action (such as opening dialogue box to ask for soundclip directory address). At the bottom of the script I made a comment which one I would like single click versus double click.
      2) I can not get the FileOpenDialogue to save the file address to the config.ini file at the 'One' position on the .ini.
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <FileConstants.au3> #include <AutoItConstants.au3> #include <Sound.au3> Opt('MustDeclareVars', 1) Opt("GUIOnEventMode", 1) Global $OneID _Main() Func _Main() GUICreate("Form1", 156, 86, 281, 276) $OneID = GUICtrlCreateButton("Button", 15, 17, 122, 37) GUICtrlSetOnEvent($OneID, "OnOne") GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit") GUISetState() While 1 While 1 Sleep(1000) WEnd WEnd EndFunc ;---------------Functions------------- While 1 Sleep(100) WEnd Func OnOne() ; ******************Single Click for this action**************** $OneID = IniRead("config.ini", "Config", "One", $OneID) If $OneID = True Then SoundPlay($OneID, @HotKeyPressed) Else ; *******Double Click for this action*****And Help Saving File Address to config.ini 'One'*********** $OneID = FileOpenDialog("Select file", @WorkingDir, "All (*.*)") IniWrite("config.ini", "Config", "One", $OneID) $OneID = InputBox("Enter Information", "Short Name for File?", "") IniWrite("config.ini", "Config", "NameOne", $OneID) EndIf EndFunc Any help would be greatly appreciated, and if you need anymore clarity as to what exactly I'm trying to do, please do not hesitate to ask. Thanks so much!
      Pike
    • SuleymanTopaloglu
      By SuleymanTopaloglu
      Hello i am new here and this is my first thread
      in this script i used some code snippets from forum.
      I do not remember who these belonged to.
      Disabled
      ALT+F4
      ALT+TAB
      TASK MANAGER
      LOCKING WINDOWS
      deleted items from ctrl+alt+delete screen
      (Lock Computer,Switch User,Sign Out,Chance a password,Task Manager)
       
      CTRL+ALT+DELETE (how ?)
      firstly we are disabled locking computer
      RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System', 'DisableLockWorkstation',"REG_DWORD",0x00000001) and then ctrl+alt+delete pressed IsDesktopLocked() triggered.
      we are calling  
      Run("rundll32.exe user32.dll,LockWorkStation") command with checking if $blockctrlaltdel = 1 statements. 
      then it return us to kiosk screen, because we are disabled locking computer. 
       
      Func IsDesktopLocked() Local $hDesktop Local $iRet Local $iRC Local $sMsg Local Const $DESKTOP_SWITCHDESKTOP = 0x100 $hDesktop = DllCall("User32.dll", "int", "OpenDesktop", "str", "Default", "int", 0, "int", 0, "int", $DESKTOP_SWITCHDESKTOP) $iRet = DllCall("User32.dll", "int", "SwitchDesktop", "int", $hDesktop[0]) If IsArray($iRet) Then If $iRet[0] = 0 Then if $blockctrlaltdel = 1 Then Run("rundll32.exe user32.dll,LockWorkStation") EndIf $iRC = 1 ElseIf $iRet[0] = 1 Then $iRC = 0 EndIf Else EndIf DllCall("User32.dll", "int", "CloseDesktop", "int", $hDesktop[0]);<-- handle returned by "OpenDesktop" ;$iRet = DllCall("User32.dll", "int", "CloseDesktop", "int", $iRet[0]) Return ($iRC) EndFunc ;==>IsDesktopLocked maybe this blocked to lock computer when rdp session closed. i havent tried and This script needed to Google chrome and "WinLockDll.dll" to work. 
      FULL SCRIPT
       
      #include <WinAPI.au3> #include <FontConstants.au3> #include <GUIConstants.au3> Opt('GUIOnEventMode', 1) Opt("TrayAutoPause", 0) HotKeySet("{ESCAPE}","_EXIT") ;~ $sFilePath = "D:\kiosk\" local $Form1,$blockctrlaltdel Global Const $VK_F4 = 0x73 Global $winlockdll = DllOpen(@ScriptDir&"\WinLockDll.dll") kullanimkapat() #region ; WinEventHook Global Const $EVENT_OPEN_DESKTOP_CHANGED = 0x0020 $h_DLL_User32 = DllOpen("User32.dll") $h_WinEventHook_Proc = DllCallbackRegister("_WinEventHook_Proc", "none", "hwnd;int;hwnd;long;long;int;int") If @error Then ConsoleWrite("Error DllCallbackRegister(_WinEventHook_Proc) did not succeed. FFH will exit now.") Exit EndIf $h_Hook = _WinEventHook_Set(0x0020, 0x0020, $h_DLL_User32) If @error Then ConsoleWrite("Error _WinEventHook_Set() did not succeed. FFH will exit now.") Exit EndIf OnAutoItExitRegister("_WinEventHook_UnSet") #endregion ; WinEventHook Global $winlockdll = DllOpen(@ScriptDir&"\WinLockDll.dll") Func kullanimkapat() $blockctrlaltdel = 1 Global $hHookProc = DllCallbackRegister("_KeyboardProc", "long", "int;wparam;lparam") Global $hHookKeyboard = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($hHookProc), _WinAPI_GetModuleHandle(0), 0) Global $hSysTray_Handle = DllCall("user32.dll", "HWND", "FindWindow", "str", "Shell_TrayWnd", "str", "") _WinAPI_ShellChangeNotify($SHCNE_ASSOCCHANGED, 0, 0, 0) _SendMessage($hSysTray_Handle[0], 0x5B4, 0, 0) DllCall($winlockdll, "Int", "Keys_Enable_Disable ", "Int", "1") DllCall($winlockdll, "Int", "TaskManager_Enable_Disable", "Int", "0") DllCall($winlockdll, "Int", "TaskSwitching_Enable_Disable", "Int", "0") DllCall($winlockdll, "Int", "Keys_Enable_Disable", "Int", "1") RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System', 'DisableChangePassword',"REG_DWORD",0x00000001) RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System', 'HideFastUserSwitching', "REG_DWORD",0x00000001) RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', 'NoLogoff',"REG_DWORD",0x00000001) RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', 'NoClose',"REG_DWORD",0x00000001) RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System', 'DisableTaskMgr',"REG_DWORD",0x00000001) RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System', 'DisableLockWorkstation',"REG_DWORD",0x00000001) FileDelete ( @LocalAppDataDir&"\Google\Chrome\User Data\Default\Preferences" ) ;~ Local $hFileOpen = FileOpen($sFilePath,BitOR(8,2)) ;~ FileWrite($hFileOpen,'<!DOCTYPE html><meta http-equiv="refresh" content="30"><html><head><script type="text/javascript">function disableselect(e){return!1}function reEnable(){return!0}document.onselectstart=new Function("return false"),document.oncontextmenu=new Function("return false"),window.sidebar&&(document.onmousedown=disableselect,document.onclick=reEnable);</script><style>#masano{top:50%;left:50%;width:250px;height:250px;margin-top:-125px;margin-left:-125px;border:1px solid red;background-color:red;position:fixed;font:normal 200px Calibri;line-height:250px;text-align:center;color:white}</style><title>*</title></head><body><div id="masano">'&@ComputerName&'</div></body></html>"') ;~ FileClose($hFileOpen);kiosk html writed Run("taskkill /im chrome.exe /f /t") Sleep(3000) ;~ Run(@HomeDrive&"\Program Files (x86)\Google\Chrome\Application\chrome.exe --kiosk "&$sFilePath) Run(@HomeDrive&"\Program Files (x86)\Google\Chrome\Application\chrome.exe --kiosk https://www.autoitscript.com/autoit3/files/graphics/autoit_10_wall_1920x1200.jpg") WinMinimizeAll() Global $hSplash = GuiCreate("", @DesktopWidth+5, @DesktopHeight+5, -5, -5,$WS_POPUP,$WS_THICKFRAME) ;invinsible fullscreen gui on top google chrome. GUISetBkColor (0xf0f8ff) WinSetTrans($hSplash, "", 5) GUISetState() WinSetOnTop($hSplash, "", 1) EndFunc Func kullanimAc() FileDelete ( @LocalAppDataDir&"\Google\Chrome\User Data\Default\Preferences" ) $blockctrlaltdel = 0 DllCallbackFree($hHookProc) If Not IsHWnd($hSysTray_Handle[0]) Then ShellExecute(@WindowsDir & "\Explorer.exe") DllCall($winlockdll, "Int", "Keys_Enable_Disable ", "Int", "0") DllCall($winlockdll, "Int", "TaskManager_Enable_Disable", "Int", "1") DllCall($winlockdll, "Int", "TaskSwitching_Enable_Disable", "Int", "1") DllCall($winlockdll, "Int", "Keys_Enable_Disable ", "Int", "0") RegDelete('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System','DisableChangePassword') RegDelete('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System', 'HideFastUserSwitching') RegDelete('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', 'NoLogoff') RegDelete('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', 'NoClose') RegDelete('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System', 'DisableTaskMgr') RegDelete('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System', 'DisableLockWorkstation') Run("taskkill /im chrome.exe /f /t") Sleep(500) GUIDelete($hSplash) Sleep(500) EndFunc Func _KeyboardProc($nCode, $wParam, $lParam) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHookKeyboard, $nCode, $wParam, $lParam) Switch $wParam Case $WM_KEYDOWN, $WM_SYSKEYDOWN, $WM_KEYUP, $WM_SYSKEYUP Local $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam) Local $vKode = DllStructGetData($tKEYHOOKS, "vkCode") Local $iFlags = DllStructGetData($tKEYHOOKS, "flags") Switch $vKode Case $VK_F4 If BitAND($iFlags, $LLKHF_ALTDOWN) Then Return -1 Else Return _WinAPI_CallNextHookEx($hHookKeyboard, $nCode, $wParam, $lParam) EndIf EndSwitch EndSwitch Return _WinAPI_CallNextHookEx($hHookKeyboard, $nCode, $wParam, $lParam) EndFunc #region ; WinEventHook Functions Func _WinEventHook_Proc($h_Hook, $iEvent, $hWnd, $idObject, $idChild, $iEventThread, $iEventTime) ;ConsoleWrite($hWnd & @TAB & $idObject & @CRLF) ConsoleWrite(TimerInit() & @tab & hex($iEvent,4) & @tab & "IsDesktopLocked()" & @tab & IsDesktopLocked() & @crlf) EndFunc ;==>_WinEventHook_Proc Func _WinEventHook_Set($iEventMin, $iEventMax, $hDLLUser32) Local $aRet Local Const $WINEVENT_OUTOFCONTEXT = 0x0 Local Const $WINEVENT_SKIPOWNPROCESS = 0x2 If Not $hDLLUser32 Or $hDLLUser32 = -1 Then $hDLLUser32 = "User32.dll" $aRet = DllCall($hDLLUser32, "hwnd", "SetWinEventHook", _ "uint", $iEventMin, _ "uint", $iEventMax, _ "hwnd", 0, _ "ptr", DllCallbackGetPtr($h_WinEventHook_Proc), _ "int", 0, _ "int", 0, _ "uint", $WINEVENT_OUTOFCONTEXT) ; BitOR($WINEVENT_OUTOFCONTEXT, $WINEVENT_SKIPOWNPROCESS) If @error Then Return SetError(@error, 0, 0) Return $aRet[0] EndFunc ;==>_WinEventHook_Set Func _WinEventHook_UnSet() If $h_WinEventHook_Proc Then DllCallbackFree($h_WinEventHook_Proc) EndIf If $h_Hook Then DllCall($h_DLL_User32, "int", "UnhookWinEvent", "hwnd", $h_Hook) If $h_DLL_User32 Then DllClose($h_DLL_User32) EndFunc ;==>_WinEventHook_UnSet #endregion ; WinEventHook Functions Func IsDesktopLocked() Local $hDesktop Local $iRet Local $iRC Local $sMsg Local Const $DESKTOP_SWITCHDESKTOP = 0x100 $hDesktop = DllCall("User32.dll", "int", "OpenDesktop", "str", "Default", "int", 0, "int", 0, "int", $DESKTOP_SWITCHDESKTOP) $iRet = DllCall("User32.dll", "int", "SwitchDesktop", "int", $hDesktop[0]) If IsArray($iRet) Then If $iRet[0] = 0 Then if $blockctrlaltdel = 1 Then Run("rundll32.exe user32.dll,LockWorkStation") EndIf $iRC = 1 ElseIf $iRet[0] = 1 Then $iRC = 0 EndIf Else EndIf DllCall("User32.dll", "int", "CloseDesktop", "int", $hDesktop[0]);<-- handle returned by "OpenDesktop" ;$iRet = DllCall("User32.dll", "int", "CloseDesktop", "int", $iRet[0]) Return ($iRC) EndFunc ;==>IsDesktopLocked Func _EXIT() kullanimAc() HotKeySet("{ESCAPE}") Exit EndFunc While 1 Sleep(100) WEnd  
      WinLockDll.dll
       
      pc-kilitle.au3
    • kcvinu
      By kcvinu
      Hi all,
      I have a button created with _GUICtrlButton_Create function. I know that this function returns a handle of button instead of an ID. So i have obtain control ID by calling _WinAPI_GetDlgCtrlID function. After that i have tried the GUICtrlSetBkColor function. But it didnt worked. Any suggestions will be appreciated. Thanks in advance. 
      Note : - The window which carries this button is not created with native gui create function. Instead, it is created with CreateWindowEx api function.
    • Robdog1955
      By Robdog1955
      I'm trying to click a button on a web page. I have added a couple of MsgBox lines to allow me to watch what happens on the page. As you can see the first half of my script enters data into text boxes on the page. I have no problem there. I just cannot click on the region buttons. The "set focus" line causes an outline to appear around the EU button and the "click button" line causes the "Pick a Region" text to disappear. Here is the code I have so far.
      #include <IE.au3> Local $oIE = _IECreate("http://questchecker.com/") Local $iQuestID = "123456" Local $sCharacterName = "CharacterName" Local $colForms = _IEFormGetCollection($oIE) $iCount = 0 For $oForm In $colForms $oFormElements = _IEFormElementGetCollection($oForm) For $oFormElement In $oFormElements $iCount = $iCount + 1 Local $sTagName = StringLower($oFormElement.tagName) Local $sElementType = $oFormElement.type Local $sElementName = $oFormElement.name Switch $iCount Case 6 _IEFormElementSetValue($oFormElement, "MyRealm", 0) ; realm Case 7 _IEFormElementSetValue($oFormElement, $sCharacterName, 0) Case 8 _IEFormElementSetValue($oFormElement, $iQuestID, 0) EndSwitch Next Next Local $oButtons = _IEGetObjByName($oIE, "questForm") For $oButton In $oButtons If _IEFormElementGetValue($oButton) = "US" Then MsgBox(0, "", "Click Okay to set focus") _IEAction($oButton, "focus") MsgBox(0, "", "Click Okay to click button") _IEAction($oButton, "click") ExitLoop EndIf Next MsgBox(0, "", "Click Okay to quit") _IEQuit($oIE) Exit  
    • keelaji
      By keelaji
      Hello,
      first of all i searched in the forum but i didn't found any solution to my problem.
      I am using windows 10.
      I made a script that is supposed to change the title to the active window, resize it to the smallest size possible (should be around 800 x 600) and move to (0, 0).
      I can change the title but i fail to do the other 2 tasks.
      i use wingettitle [active] copied from the F1 help tool (and this works), i i put the title in a variable and than i use
      winsettitle ($variable, "one") (this works too)
      winmove ("one", 0, 0, 800, 600) (doesn't do anything)
      i also tried
      local $x = winget ( "one")
      msgbox (0, "", $x) (i get a completely white box so i suppose winget can't have any data about my window ??)
      any suggestion ?
×