3 posts in this topic
I wondered why negative integers I wrote into registry (e.g. negative x-coordinates of a gui if using two monitors and the right one is the main one) wouldn't return right when reading. Now I know: it is saved as an unsigned integer (without algebraic sign). So here is a snippet that is changing unsigned to signed integer:
Global Const $g_sRegKey = "HKEY_CURRENT_USER\Software\" & @ScriptName ; path to registry RegWrite($g_sRegKey, "Value", "REG_DWORD", -2147483647) ; write some negative integer into registry; -2147483647 highest possible negative integer , 2147483648 highest possible positive integer if talking of 32bit Local $sValue = RegRead($g_sRegKey, "Value") ; read out registry ConsoleWrite("Value: " & $sValue & @CRLF) ; show real value in console Local $sResult = _SignedInteger($sValue) ; change to signed value ConsoleWrite("Result: " & $sResult & @CRLF) ; and show it in console Func _SignedInteger($iUnsignedInteger) Local $iSignedInteger If $iUnsignedInteger > (2^31) Then ; then it means a negative integer $iSignedInteger = $iUnsignedInteger - (2^32) Else $iSignedInteger = $iUnsignedInteger EndIf Return $iSignedInteger EndFunc It took me some time to find out the problem and so I hope I can help somebody with this.
I post here because i was wonderring if someone in this forum could help me with my script.
What i'm trying to do, is to basically install a new keyboard layout in Windows and activate it. I want to acheive by the registry or the command line, but not with the autoit automation tools, i don't find it stable...
Thanks for your help and have a good day!
I'm having a problem right here ..
I was trying to create a few Registry Values using autoit, but it seems to me that Autoit can't write those values to this specific part of the registry ..
Here is the code I'm trying to run:
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\test\command", "", "REG_SZ", "C:\test\convert.exe %1 geojson|convert") I'm definitly sure that the path is correct. Script is runned with Admin Rights. Everything's fine here.
It's possible to read other values stored by Windows in this directory:
MsgBox(0, 0, RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Windows.burn", "Description")) But you can't edit those using Autoit. I don't know what this is. In my eyes it's an Autoit Bug or something like that ...
Possible solution for me is to write a ".reg" file and run it afterwards, but this is an unclean method I don't really want to use ..
Any suggestions on this?
Edit: the OS is Windows 7 x64 German Language btw ..
I wanted to have a few lines that copy the whole registry into a file. I know that there is RegRead, but I don't want to type every single key into my code...
Any way of doing this easily? Filetype doesn't matter, as long as it isn't encrypted. A batch or exe would be okay, if it's in the same location on every PC. Doing this without admin permissions would be awesome too
Another project idea that I am trying to get working.
A USB GPS device needs to be assigned COMM Port 25 when it is plugged into the computer. It obviously gets the first open port when plugged in the first time and if I manually change it to 25 it will get a new port again if somebody plugs the device into a new USB port.
So I want to make a script that can detect the device, and move/configure its port automatically.
I started off finding this UDF: https://www.autoitscript.com/forum/topic/128546-serial-port-com-port-udf/?page=32
It was useful for finding the device is plugged in and what port its on, but it does not have the ability to actually change the port.
I think that will have to be done via registry, or perhaps via Objects.
I just want to double check my facts here and get a grip on what I need to do.
Registry has the following keys that change:
HKLM\HARDWARE\SERIALCOMM - \Device\ProlificSerial0
This key just lists the COMM Port for the device, it changes based on its current port.
Under this key is a subkey that will duplicate every time the device gets a new port, I have not figure out quite yet how to determin what that subkey will be named, but it has the "FriendlyName" key and also the Device parameters\PortName key
Both of those are unfortunately SYSTEM level permission so that makes scripting a change even harder.
Last is HKLM\SYSTEM\CurrentControlSet\Control\COM Name Arbiter
This contains the record of what comm ports are occupied or vacant via binary to hex. I would have to find a way to read its current value and change it to show port 25 taken and if possible free up the port taken by the device before the change. Not sure how to write something like that.
Has anybody done something like this before? If so what was your best approach?