Sign in to follow this  
Followers 0
GHOSTSKIKDA

* NoWritInFlashDisk

5 posts in this topic

#1 ·  Posted (edited)

Hi !

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

#Region ### START Koda GUI section ###
$Form1 = GUICreate("NoWritInFlashDisk", 443, 186, -1, -1, BitOR($WS_CAPTION,$WS_POPUP,$WS_BORDER,$WS_CLIPSIBLINGS))
GUISetBkColor(0xDBD3CB)
$Group1 = GUICtrlCreateGroup("", 16, 9, 401, 145, $BS_RIGHT)
$Button1 = GUICtrlCreateButton("؟", 393, 18, 19, 17, 0)
GUICtrlSetCursor (-1, 4)
$Button2 = GUICtrlCreateButton("Quit", 32, 121, 75, 25, 0)
GUICtrlSetCursor (-1, 0)
$Button3 = GUICtrlCreateButton("0", 184, 48, 19, 17, 0)
$Label1 = GUICtrlCreateLabel("No Write in Flash Disk", 216, 48, 185, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Label2 = GUICtrlCreateLabel("Write in Flash Disk", 208, 80, 197, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Button4 = GUICtrlCreateButton("0", 184, 80, 19, 17, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
    Case $GUI_EVENT_CLOSE
        Exit
    Case $Button3
        RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies","WriteProtect","REG_DWORD",1)
        GUICtrlSetColor($Label1 , 0x0000FF)
        GUICtrlSetColor($Label2, 0xFF0000)
        $Button3 = GUICtrlCreateButton("1", 184, 48, 19, 17, 0)
        $Button4 = GUICtrlCreateButton("0", 184, 80, 19, 17, 0)
    Case $Button4
        RegDelete("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies")
        GUICtrlSetColor($Label2 , 0x0000FF)
        GUICtrlSetColor($Label1, 0xFF0000)
        $Button4 = GUICtrlCreateButton("1", 184, 48, 19, 17, 0)
        $Button3 = GUICtrlCreateButton("0", 184, 80, 19, 17, 0)
    Case $Button2
        Sleep(500)
        Exit
EndSwitch
WEnd

Posted Image

Edited by ALG

[center]I LOVE ALGERIA .... ;-)[/center]

Share this post


Link to post
Share on other sites



1) Wrong Forum... this one is reserved for examples, not questions.

2) I would not create button over button, better change value of existing ones with GUICtrlSetData()

3) The value is written to reg... maybe it needs a restart to be in effect?

Share this post


Link to post
Share on other sites

Thank you for clarification, my friend :)


[center]I LOVE ALGERIA .... ;-)[/center]

Share this post


Link to post
Share on other sites

Code correct

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

#Region ### START Koda GUI section ###
$Form1 = GUICreate("NoWritInFlashDisk", 443, 186, -1, -1, BitOR($WS_CAPTION,$WS_POPUP,$WS_BORDER,$WS_CLIPSIBLINGS))
GUISetBkColor(0xDBD3CB)
$Group1 = GUICtrlCreateGroup("", 16, 9, 401, 145, $BS_RIGHT)
$Button1 = GUICtrlCreateButton("؟", 393, 18, 19, 17, 0)
GUICtrlSetCursor (-1, 4)
$Button2 = GUICtrlCreateButton("Quit", 32, 121, 75, 25, 0)
GUICtrlSetCursor (-1, 0)
$Button3 = GUICtrlCreateButton("0", 184, 48, 19, 17, 0)
$Label1 = GUICtrlCreateLabel("No Write in Flash Disk", 216, 48, 185, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Label2 = GUICtrlCreateLabel("Write in Flash Disk", 208, 80, 197, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Button4 = GUICtrlCreateButton("0", 184, 80, 19, 17, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$a=RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies","WriteProtect")
if $a=1 Then
        GUICtrlSetColor($Label1 , 0x0000FF)
        GUICtrlSetColor($Label2, 0xFF0000)
        GUICtrlSetData($Button3, "1")
        GUICtrlSetData($Button4, "0")
    Else
        GUICtrlSetColor($Label2 , 0x0000FF)
        GUICtrlSetColor($Label1, 0xFF0000)
        GUICtrlSetData($Button4, "1")
        GUICtrlSetData($Button3, "0")
EndIf
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
    Case $GUI_EVENT_CLOSE
        Exit
    Case $Button3
        RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies","WriteProtect","REG_DWORD",1)
        GUICtrlSetColor($Label1 , 0x0000FF)
        GUICtrlSetColor($Label2, 0xFF0000)
        GUICtrlSetData($Button3, "1")
        GUICtrlSetData($Button4, "0")
    Case $Button4
        RegDelete("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies")
        GUICtrlSetColor($Label2 , 0x0000FF)
        GUICtrlSetColor($Label1, 0xFF0000)
        GUICtrlSetData($Button4, "1")
        GUICtrlSetData($Button3, "0")
    Case $Button2
        Sleep(500)
        Exit
EndSwitch
WEnd

[center]I LOVE ALGERIA .... ;-)[/center]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

@ALG

Please check my sample:

http://www.autoitscript.com/forum/index.php?autocom=downloads&showfile=136
Edited by euverve

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  
Followers 0