Jump to content

[Solved] Hide Mouse Pointer & Change Input Style


 Share

Recommended Posts

ES_PASSWORD by default uses the bullet or asterix on XP, have a look at MSDN about ES_PASSWORD.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Thanks for everyones input into this.

Guiness i checked out your link, and it does indeed work very nicely for solving the problem stated in the Orginal Post but i am never one to like lots of lines of code.I was hoping i used the function or syntax wrong for "SetStyle" ^^. Instead I am going for GUICtrlSetColor($Input, 0x000000) "Setting the font color same as back color making it invisible to human eye". Sense in my full code Mouse usage is disabled, along with copy+paste. Its not possible for it to highlight. So this way it has the added advantage of not being able to see the length of password "if anyone is behind me".

To Anyone else to wants to Hide the mouse. Here is some code I now use

You can get the Invisible Mouse .cur from this Website. http://www.rw-designer.com/online-cursor-editor

Place the Invsible.cur on your desktop named invisible.cur. If you want to change the name or location then edit 1

If you want the windows defaults or set your own defaults. Edit $MouseShown Array.

Local $MouseVals[15] =["AppStarting","Arrow","Crosshair","Hand","Help","IBeam","No","NWPen","SizeAll","SizeNESW","SizeNS","SizeNWSE","SizeWE","UpArrow","Wait"]
Local $MouseShow[15] = ["cross_l.cur", "cross_l.cur", "cross_l.cur", "cross_l.cur", "cross_l.cur", "beam_r", "aero_unavail_xl.cur", "cross_l.cur", "aero_move_xl.cur", "aero_nesw_xl.cur", "aero_ns_xl.cur", "aero_nwse_xl.cur", "aero_ew_xl.cur", "cross_l.cur", "cross_l.cur"]

Func HidePointer($HidePointer)
     If $HidePointer Then
          For $A = 0 to 14
               RegWrite("HKEY_CURRENT_USERControl PanelCursors", $MouseVals[$A], "REG_EXPAND_SZ", "%USERPROFILE%Desktopinvisible.cur") ; Edit 1
          Next
     Else
          For $A = 0 to 14
               RegWrite("HKEY_CURRENT_USERControl PanelCursors", $MouseVals[$A], "REG_EXPAND_SZ", "%SYSTEMROOT%Cursors" & $MouseShow[$A])
          Next
     EndIf
     DllCall("user32.dll", "int", "SystemParametersInfo", "int", 0x57, "int", 0, "int", 0, "int", 0)
EndFunc
Edited by IanN1990
Link to comment
Share on other sites

Wouldn't this be easier for your usage, it does give you the password length, but that's hardly a security issue unless you're ultra-paranoid.

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
Example()
Func Example()
     Local $file, $btn, $msg
     GUICreate(" Click OK button to change style", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1)
     $file = GUICtrlCreateInput("", 10, 5, 300, 20)
     $btn = GUICtrlCreateButton("Ok", 40, 75, 60, 20)
     GUISetState()
     $msg = 0
     While $msg <> $GUI_EVENT_CLOSE
          $msg = GUIGetMsg()
          Select
               Case $msg = $btn
                    GUICtrlSetStyle($file, $ES_PASSWORD) ; change the style of the input box
                    GUICtrlSendMsg($file, $EM_SETPASSWORDCHAR, Asc("&"), 0) ; changes the password character to "&"
          EndSelect
     WEnd
     MsgBox(4096, "Password", GUICtrlRead($file))
EndFunc   ;==>Example

This will change the password character to "&" instead of the bullet or asterisk as a demonstration. If there's anything in the input box when you press the button, it will change to the password character as soon as you click inside the input.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

So playing around with your code, i can see that GUICtrlSetstyle alone isn't enough and it needs a SendMsg. So does that mean if i wanted to set it back to default i need to send another message ?

#include <EditConstants.au3>
local $A
$hWnd = GUICreate("Gui Style", 260, 100)
$Style = GUICtrlCreateButton("Set Style", 45, 50, 150, 20)
$Input = GUICtrlCreateInput("", 0, 0, 50, 50)
GUISetState()

While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $Style
If $A Then
GUICtrlSetStyle($Input, $GUI_SS_DEFAULT_INPUT)
ConsoleWrite("B")
Else
GUICtrlSetStyle($Input, $ES_PASSWORD) ; change the style of the input box
GUICtrlSendMsg($Input, $EM_SETPASSWORDCHAR, Asc("*"), 0) ;
ConsoleWrite("C")
EndIf
$A = Not $A
Case Else
EndSwitch
WEnd
Edited by IanN1990
Link to comment
Share on other sites

Have you tried it?

Why ask a question that could be answered, by writing the code and testing it, faster than coming here and typing your question?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

IanN1990,

I did point out many posts before that setting the style alone wouldn't work. Look at my _DisplayPassword function again please, the code is clearly written on how to reset the password character.

Guiness i checked out your link, and it does indeed work very nicely for solving the problem stated in the Orginal Post but i am never one to like lots of lines of code.

If this is the case then I'm afraid you should stop using the UDFs. You have to get out of that mind frame that long code is bad code, because it's going to really stunt your growth in developing further as a coder.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

@Googlechrome and autoit. I wish you would stop fighting and just paste code correctly so i dont need to edit the same post 10 times to get the correct format ><

local $PasswordProtected
local $hWnd = GUICreate("Password Example", 260, 100)
local $Button = GUICtrlCreateButton("Password", 45, 50, 150, 20)
local $Input = GUICtrlCreateInput("", 0, 0, 260, 25)
GUISetState()

While True
$Msg = GUIGetMsg()
     Switch $Msg
          Case $Button
               If $PasswordProtected Then
                    GUICtrlSendMsg($Input, 0xCC, 0, 0)
               Else
                    GUICtrlSendMsg($Input, 0xCC, Asc("*"), 0)
               EndIf
          ControlFocus("", "", $Input)
          $PasswordProtected = Not $PasswordProtected
     EndSwitch
Wend

@BrewManNH

Yes of course i tryed it.

Now i could be wrong, but from what i found having this line or not does nothing for changing the input. GUICtrlSetStyle($Input, ES_PASSWORD) does nothing for changing the input. GUICtrlSendMsg($Input, $EM_SETPASSWORDCHAR, Asc("*"), 0) Alone changes the input nicely, and has the advantage of letting one set the style of password they want.

So i came to the conclusion i needed to send another message to change it back, but what would be the message ?

GUICtrlSendMsg ( controlID, msg , wParam, lParam ) - From Help Fine

GUICtrlSendMsg ($Input, $GUI_SS_DEFAULT_INPUT, 0, 0) - Is What i tried, As that contrant is the default used for input boxes

Didn't work, i went into the editcontrants.au3 to see if there was any other constrant i could set but found nothing useful.

Is it the case i need to clear the old style somehow before setting the new style "which would be the default ?"

Ego my orginal question. What message do i need to send.

@Guinness

I checked out your post, and i was already aware of the "Collect, destory, remake with password style". I was hoping for something that doesn't require this, and if it was the case then thats fine but i wanted to know.

Ok that explains why i felt everyone was getting getting tense and i feel a bit on the defence. I did read your posted Guniess but only like the first 3-4 posts. As i thought I was an example for one method (which was a destroy and create, which I already knew and wasn't looking for), not the cast 7 posts down there is a second method and 8 posts down a third one. While the third method lies the answer i wanted.

So from everyone else perspective you had in fact given the answer, i just missed it and from your view it looked like I wasn't working / putting the effort in which isn't the case.

So fine, i admit my fault. Not getting much time on a pc with internet, i should of checked it more thurothy. Lesson learnt.

As to your second post though, i respectfully disagree in some aspects.

My general motto for coding is.

Less lines of code

Better performance

More functionally.

Here is a example of why I disagree.

More lines of code tends to get confusing and can lead to more bugs.

Again taking your _DisplayPassword each time its called local vars are being redeclared (performance), there's a switch, 2 cases , a Dllcall with maths, a if. So With many things going on there's a high chance of a bug, plus more cpu. Now in your example its made so anyone can use it, so most of this is to be expected but i am just showing a point.

2 lines of code, less change for a bug and good performance ? Surely this cant be seen as bad.

As for the UDF.

I do tend to look into UDFs to see if there is anything i can improve or how much of the UDF is really being used.

An Example.

_MouseTrap() Is a function I use in my main script. I found that when ever you left/right or middle click the mouse trap is broken, but that's only if you have changed your "active" sense you called the mouse trap.

So. I could include Misc with all the functions or i could take _Mousetrap out and then i dont need to include the whole UDF.

Func _MouseTrap($iLeft = 0, $iTop = 0, $iRight = 0, $iBottom = 0)
Local $aResult
If @NumParams == 0 Then
$aResult = DllCall("user32.dll", "bool", "ClipCursor", "ptr", 0)
If @error Or Not $aResult[0] Then Return SetError(1, _WinAPI_GetLastError(), False)
Else
If @NumParams == 2 Then
$iRight = $iLeft + 1
$iBottom = $iTop + 1
EndIf
Local $tRect = DllStructCreate($tagRECT)
DllStructSetData($tRect, "Left", $iLeft)
DllStructSetData($tRect, "Top", $iTop)
DllStructSetData($tRect, "Right", $iRight)
DllStructSetData($tRect, "Bottom", $iBottom)
$aResult = DllCall("user32.dll", "bool", "ClipCursor", "struct*", $tRect)
If @error Or Not $aResult[0] Then Return SetError(2, _WinAPI_GetLastError(), False)
EndIf
Return True
EndFunc ;==>_MouseTrap

I can then seen, each time the function is being called. Its doing alot of things that in my case dont need to happen. As in my instance the varaibles will always be the same. I could just do this.

At the start of the script generate the varaible.

Local $DllMouseLock = DllStructCreate("struct;long Left;long Top;long Right;long Bottom;endstruct")
DllStructSetData($DllMouseLock, "Left", 0)
DllStructSetData($DllMouseLock, "Top", 0)
DllStructSetData($DllMouseLock, "Right", 1920)
DllStructSetData($DllMouseLock, "Bottom", 1080)

DllCall("user32.dll", "bool", "ClipCursor", "struct*", $DllMouseLock) ;Enables the Mouse Trap
sleep(2500)
DllCall("user32.dll", "bool", "ClipCursor", "ptr", 0) ;Releases the Mouse Trap

So what advantages does this have ? Well first because i have gone into the function, i understand it better. I have removed lots of re-runs, now it doesn't need to re-create the dll struct every time. Less lines better performance. Why call a function when i can just call the dllcall directly skipping the middle man ? This all leads to less things that can go wrong. As i stated above, i just don't see how this can be bad.

So thats why i do what i do. I agree as a home user programming for myself my views could be seen as trivial and not important. The chances of ending up in a project with 20,000 lines of code is unlikely, and with a High grade pc "when I get it back" performance issues mean little. But i still prefer trying to keep things small, tidy, easier to understand and maintaining good performance so if one day it did turn into a 50k script. It would already be optimized Rather then a 100k script that makes the pc lag.

Link to comment
Share on other sites

I just googled the EM_SETPASSWORDCHAR variable used to change the characters in the input and found out that to change it back you just need to use 0 (zero) instead of the character selected, in this case the * (asterisk).

I also found out by experimenting, that you DON'T need to use GUICtrlSetStyle to change the input characters to the password character, you just need to use the GUICtrlSendMessage command to do it.

See below.

#include <EditConstants.au3>
Local $A
$hWnd = GUICreate("Gui Style", 260, 100)
$Style = GUICtrlCreateButton("Set Style", 45, 50, 150, 20)
$Input = GUICtrlCreateInput("", 0, 0, 50, 50)
GUISetState()
While 1
     $Msg = GUIGetMsg()
     Switch $Msg
          Case $Style
               If $A Then
;~                   GUICtrlSetStyle($Input, $GUI_SS_DEFAULT_INPUT) ; found out by experimenting, that this wasn't necessary
                    GUICtrlSendMsg($Input, $EM_SETPASSWORDCHAR,  0, 0) ; Changes the password character back to normal characters.
                    ConsoleWrite("B")
               Else
;~                   GUICtrlSetStyle($Input, $ES_PASSWORD) ; not necessary
                    GUICtrlSendMsg($Input, $EM_SETPASSWORDCHAR, Asc("*"), 0) ;
                    ConsoleWrite("C")
               EndIf
               $A = Not $A
          Case -3 ; ($GUI_EVENT_CLOSE)
               exit
     EndSwitch
WEnd

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...