How can I bind F3 behavior on key 5 on numeric keypad in midnight commander? - mc

How can I bind F3 behavior on key 5 on the numeric keypad in Midnight Commander?
It will be very usable for me.

You cannot rebind keys in Midnight Commander. But you can use alternate keys. If F3 doesn't work for you, press Esc3.
Try the command F9 → Options → Learn keys.... It allows to adapt Midnight Commander to the terminal.

Related

VS-2019 program crashes on first floating point instruction on some servers

I have a service with code that runs for years.
Now using the VS-2019 16.3.7/8/9 I get a 0xC000001D (The thread tried to execute an invalid instruction.) exceptions on the first floating point arithmetic in the boot phase of the service on some machines.
Installing the same code base compiled with 16.2.4/5 works.
I have a full memory crash dump from one machine. The crash happens on a call to _dtol3.
I can see in the assembly code this situation.
0149477B 83 3D B4 AC 55 01 06 cmp dword ptr [__isa_available (0155ACB4h)],6
01494782 7C 15 jl _dtol3_default (01494799h)
01494784 C5 FA 7E C0 vmovq xmm0,xmm0
01494788 62 F1 FD 08 7A C0 vcvttpd2qq xmm0,xmm0 <---- CRASH
__isa_available has the value 6. On my machine the value is 5. One machine were we can see the crash is a XEON Silver 4110 running our software virtualized. Same exe runs on a XEON E5-2620. The same exe runs on all my client machines in my company without any problem (a mix of old and new Intel machines).
Looking at the called code, I can see that there is a simple difference and division of to double values comparing it to a value greater or equal 1.0.
COleDateTime nowClient = COleDateTime::GetCurrentTime(),
nowDB = GetCurrentTime();
COleDateTimeSpan diff = nowDB-nowClient;
if (diff.GetTotalMinutes()>=1) // <----- CRASH
...
Is there any way to influence the code creation in the VS to avoid the calls to this code? (Any shim, compatibility setting)
Is there any known change in VS-2019 that influences the floating math since VS 16.2.4, that might has influence on my problem?
This is a bug in the 16.3.x update of Visual Studio. Here is a link to the bug report.
Read it carefully, it actually happens on machines that support AVX512, not older CPUs as the initial post describes. This also contains a couple of workarounds to avoid the issue until Microsoft has a fix.
You can enable or disable the generation of 'advanced' instructions for each project in its "Properties" sheet:
Right click the project in the Solution Explorer and select "Properties" from the pop-up menu.
Select/Open the "C/C++" tab in the left-hand pane and then select the "Code Generation" item.
In the list of properties then presented in the right-hand pane, select "Not Set" for the "Enabled Enhanced Instruction Set" property (or whichever option will give you code that is compatible with your target PCs).
The compiler's use of vmovq implies that you have (at least) "Advanced Vector Extensions" enabled; also, I think (not 100% sure) that vcvttpd2qq is in the "AVX2" category.

AutoHotkey (AHK): GetKeyState not recognizing keypress made by ControlSend

I have a very complex script that depresses a key, and needs to check at cerrtain points whether that key is still depressed or not, so GetKeyState seemed perfect, but I could not get it to work, so I made a simple script doing only that, and it still doesn't recognize the state.
The script is as follows:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
~#Right::
ControlSend,, {d down}, ahk_pid 6920
Loop{
GetKeyState, dState, d
;MsgBox, d Key State: %dState%
SplashTextOn,300,50, AutoNavigatorInfo, d Key State: %dState%
WinMove, AutoNavigatorInfo, , 300, 0 ; Move the splash window to the top left corner.
}
Sadly, the splashText window I use keeps relaying dState as U. Very odd seeing as in the test window I am using, it is interacting properly with the d key depressed.
I agree with blackholyman "GetKeyState will not work for controlsend as GetKeyState Gets the global system state of the key but controlsend only sets the state locally i.e the key state is only set for one control or window."
But if you need "ControlSend for certain window functions, such as sending commandby PID" I think you can do it with Send command too. Use WinActivate to activate window that you need to send key and after use Send to send key. You can use PID with WinActivate command instead of Wintitle parameter, more about it here: http://ahkscript.org/docs/misc/WinTitle.htm
Try this code:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
~#Right::
WinActivate, ahk_pid 6920
Send, {d down}
Loop{
GetKeyState, dState, d
;MsgBox, d Key State: %dState%
SplashTextOn,300,50, AutoNavigatorInfo, d Key State: %dState%
WinMove, AutoNavigatorInfo, , 300, 0 ; Move the splash window to the top left corner.
}
GetKeyState will not work for controlsend as GetKeyState Gets the global system state of the key but controlsend only sets the state locally i.e the key state is only set for one control or window.

bitwise logical operators in COBOL?

How can one express bitwise logical operations in mainframe COBOL?
I have:
01 WRITE-CONTROL-CHAR.
03 WCC-NOP PIC X VALUE X'01'.
03 WCC-RESET PIC X VALUE X'02'.
03 WCC-PRINTER1 PIC X VALUE X'04'.
03 WCC-PRINTER2 PIC X VALUE X'08'.
03 WCC-START-PRINTER PIC X VALUE X'10'.
03 WCC-SOUND-ALARM PIC X VALUE X'20'.
03 WCC-KEYBD-RESTORE PIC X VALUE X'40'.
03 WCC-RESET-MDT PIC X VALUE X'80'.
In Micro Focus COBOL, I could do something like:
WCC-NOP B-AND WCC-RESET
but it seems there's no such operator on the mainframe (or at least not in Enterprise COBOL for z/OS).
Is there some (hopefully straightforward!) way to simulate/replicate bitwise logical operations in mainframe COBOL?
Your best bet appears to be 'CEESITST', as it appears to exist in z/OS COBOL. I found an example using that as well as the other bit manipulation programs.
http://esj.com/articles/2000/09/01/callable-service-manipulating-binary-data-at-the-bit-level.aspx
If you AND together values that don't share bits, you will always get zero, so I'm going to assume you meant OR. This makes sense since you tend to OR independent bits to construct a multi-bit value.
With that in mind, when the bit masks are independent of each other, as in a single term doesn't interact with other terms, there is no difference between:
termA OR termB
and:
termA + termB
Your terms are all independent here, being x'1', x'2' and so forth (no x'03' or x'ff') so adding them should work fine:
COMPUTE TARGET = WCC-NOP + WCC-RESET
Now that's good for setting bits starting with nothing, but not so useful for clearing them. However, you can use a similar trick for clearing:
COMPUTE TARGET = 255 - WCC-NOP - WCC-RESET
Setting or clearing them from an arbitrary starting point (regardless of their current state) is a little trickier and can't be done easily with addition and subtraction.

What is the meaning of 6E 00 when I send a command to a SmartCard

I try to access a SmartCard via C++.
I got already the Connection and the CardHandle.
But when I send an APDU Command via SCardTransmit, i'll get 6E 00 as the answer from the card.
No matter which APDU Command i send.
Everytime 6E 00.
For Example:
FF CA FA 00 00 (Card's ATR - Answer To Reset) or
FF CA FF 82 00 (Product name in ASCII)
The same thing when i send the Command with an PC/SC Testtootl like "PC/SC Diag".
Has anybody an Idea what the meaning of this Error-Code and how to solve the problem?
Please help me !!!! ;-)
According to ISO 7816-4 0x6E00 means "Class not supported".
Are you using the correct CLA value in the APDU?
The class (CLA) byte is usually 0x00, 0xA0, 0xC0 or 0xF0 and sometimes masked with 0x0C that indicates Secure Messaging on some cards. AFAIK, the only invalid CLA value is 0xFF.
But this varies from one card to another, do you have the card specification from the vendor?
It means "Wrong Instruction Class". Maybe it's just the wrong type of card?
https://datatracker.ietf.org/doc/html/draft-urien-eap-smartcard-05
The BasicCard PDF manual has a list of error codes on page 152-153.
The one you got they describe as "CLA byte of command not recognized".
"6A 86" is likely the response to a card specific command and I dont see it in the BasicCard list.

How to programmatically move Windows taskbar?

I'd like to know any sort of API or workaround (e.g., script or registry) to move (or resize) Windows taskbar to another position including another monitor (if dual monitors). Definitely, we can move task bar by using mouse, but I want to move it by a program, or a sort of automated way.
I tried to find Win32 API, but it seems no one does this job.
EDIT: I was surprised by many people's opinion. Let me explain why I wanted it. In my workplace, I'm using dual monitors (resolutions are different), and the taskbar is placed on the left monitor while the primary monitor is the right monitor. However, I often connect to my workplace computer via remote desktop. After the remote connection, the taskbar position is switched. That's why I wanted to make a simple program that can save/restore taskbar's position. Everyday I have to rearrange my taskbar. That's it. I just want it for me.
I also have this need on Windows 7. Here is my take to do this using autohotkey script:
; This script will try to drag and move the taskbar to where the *current* mouse
; cursor is
; 0x111: WM_COMMAND, 424: lock/unlock taskbar, http://www.codeproject.com/KB/miscctrl/Taskbar_Manipulation.aspx
RegRead, TaskbarLocked, HKEY_CURRENT_USER, SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced, TaskbarSizeMove
If TaskbarLocked = 0
SendMessage 0x111, 424, , , ahk_class Shell_TrayWnd
WinActivate ahk_class Shell_TrayWnd
MouseGetPos targetX, targetY
ControlGetPos x, y, w, h, MSTaskListWClass1, ahk_class Shell_TrayWnd
MouseMove x+1, y+1
MouseClickDrag Left, x+1, y+1, targetX, targetY, 10
; often after dragging the taskbar to left or right side of a monitor, even though
; there are enough room to show two columns of icons, it will only show one column,
; it seems showing or hiding an icon will fix this
Menu, Tray, NoIcon
Menu, Tray, Icon
; lock the taskbar if it was previously locked
If TaskbarLocked = 0
SendMessage 0x111, 424, , , ahk_class Shell_TrayWnd
I have tested this on Windows 7 with classic window theme. To use this, assign a hotkey to call this script, then position mouse cursor to where you want to drag the taskbar to, then press the hotkey.
The taskbar is a window. Use SetWindowPos() to move it. See also SHAppBarMessage() and ABM_WINDOWPOSCHANGED.
Though the taskbar may be special and Windows may not like you moving it around. There are a lot of special cases in the Shell appbar API implementation for the taskbar.
To move to another monitor, use EnumDisplayMonitors() with GetMonitorInfo(). Some monitors may have negative coordinates.
I've had some luck with this task in an AutoHotkey script, just in case you don't care about the language used. It uses simulated keystrokes and mouse movements to move your taskbar. I stopped short of automatically unlocking/locking the taskbar.
The hard part was getting it to work reliably. A lot of the code is dedicated to making sure that the taskbar moved. It still doesn't work 100%... it fails like 10% of the time from what I've seen. However, it should be good enough to get you started!
If I ever come back to this script to make it work perfectly, I'll repost here.
Here is the example script (highlighting is a bit odd here, as the language is AHK):
F3::
reload
return
F5::
MoveTaskbar(2,"bottom")
return
F6::
MoveTaskbar(2,"left")
return
F7::
MoveTaskbar(1,"top")
return
; Move the taskbar
; dspNumber: number. device number (primary display is 1, secondary display is 2...)
; edge: string. Top, Right, Bottom, or Left
MoveTaskbar(dspNumber, edge)
{
Critical
OutputDebug MoveTaskbar - called to move taskbar to display #%dspNumber% ("%edge%" edge)
; absolute coordinate system
CoordMode, Mouse, Screen
; error checking for dspNumber
SysGet, numMonitors, MonitorCount
if (numMonitors<dspNumber)
{
OutputDebug MoveTaskbar - [ERROR] target monitor does not exist (dspNumber = "%dspNumber%")
return
}
; get screen position for target monitor
SysGet, target, Monitor, %dspNumber%
oX := 7
oY := 7
; get coordinates for where to move the taskbar
if (edge = "Top")
{
oX := (targetRight-targetLeft)/2
trgX := oX+targetLeft
trgY := targetTop+15
}
else if (edge = "Right")
{
oY := -(targetBottom-targetTop)/2
trgX := targetRight-15
trgY := -oY + targetTop
}
else if (edge = "Bottom")
{
oX := -(targetRight-targetLeft)/2
trgX := -oX+targetLeft
trgY := targetBottom-15
}
else if (edge = "Left")
{
oY := (targetBottom-targetTop)/2
trgX := targetLeft+15
trgY := oY+targetTop
}
else
{
OutputDebug MoveTaskbar - [ERROR] target edge was improperly specified (edge = "%edge%")
return
}
trgX := round(trgX)
trgY := round(trgY)
oX := round(oX)
oY := round(oY)
OutputDebug MoveTaskbar - target location is (%trgX%,%trgY%)
MouseGetPos, startX, startY
OutputDebug MoveTaskbar - mouse is currently at (%startX%,%startY%)
; request the move mode (via context menu)
SendInput #b
SendInput !+{Space}
SendInput m
; wait for the move mode to be ready
Loop
{
if A_Cursor = SizeAll
break
}
OutputDebug MoveTaskbar - move mode is ready
; start the move mode
SendInput {Right}
; wait for the move mode to become active for mouse control
Loop
{
if A_Cursor = Arrow
break
}
OutputDebug MoveTaskbar - move mode is active for mouse control
; move taskbar (and making sure it actually does move)
offset := 7
count := 0
Loop
{
; move the taskbar to the desired location
OutputDebug MoveTaskbar - attempting to move mouse to (%trgX%,%trgY%)
MouseMove, %trgX%, %trgY%, 0
MouseGetPos, mX, mY, win_id
WinGetClass, win_class, ahk_id %win_id%
count += 1
; if the mouse didn't get where it was supposed to, try again
If ((mX != trgX) or (mY != trgY))
{
OutputDebug MoveTaskbar - mouse didn't get to its destination (currently at (%mX%,%mY%)). Trying the move again...
continue
}
; if the taskbar hasn't followed yet, wiggle the mouse!
if (win_class != "Shell_TrayWnd")
{
OutputDebug MoveTaskbar - window with class "%win_class%" is under the mouse... wiggling the mouse until the taskbar gets over here
;offset := - offset
trgX -= round(oX/2)
trgY -= round(oY/2)
oX := -oX
oY := -oY
if count = 50
{
OutputDebug, MoveTaskbar - wiggling isn't working, so I'm giving up.
return
}
}
else
break
}
OutputDebug MoveTaskbar - taskbar successfully moved
SendInput {Enter}
}
Thank you for asking this question!
Its Windows 10 now and i got the same kind of problem where i made a script to switch between a 2 screens setup and only the tv for movies. After switching back to the 2 screens setup, the taskbar is back on the right monitor, just like you experienced.
I found a solution involving modifying the registry key that defines the taskbar location.
This is the said key:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3
Open the regisrty editor while your taskbar is at the right spot and size (Win+R, type regedit", the enter), then navigate to the key path above. You should find a binary value named "Settings" that looks like this:
30 00 00 00 fe ff ff ff 02 00 00 00 03 00 00 00 4e 00 00 00 32 00 00 00 80 f8 ff ff b2 01 00 00 be f8 ff ff ea 05 00 00 60 00 00 00 01 00 00 00
Your numbers may vary, but it doesn't matter. Simply click on file>export action in the menu once you navigated to the value, then use the file->export option from the top menu, and and save the .reg file in your system forlder (C:\Windows\System32). Make sure the export range is set to "Selected Branch" so only this value is affected. This will create a registry script that will restore the exact position of your taskbar.
However, if you just use the "merge" option on your script, you won't see the change since you will need to restart the explorer.exe process. To achieve this, you can simply make a batch script in noptepad looking like this:
#echo off
%windir%\system32\regedit.exe /s file.reg
taskkill /f /im explorer.exe
start explorer.exe
end
Simply replace in the 2nd line the "file.reg" by the complete file name of the .reg script you previously created, then save the file as a ".bat".
Running this script as an admin will reset the taskbar to where it should be. You will see the ui flashing briefly, since the taskbar and desktop will reset.
You could call this script from a Task, or make a shortcut that is set to run as admin to make it even easier!
I hope this answer reaches you, even if is is a "little" late XD
Your Welcome!
As far as I can tell, Vista and onwards ignore any program trying to move the taskbar. The old method was ABM_SETPOS + MoveWindow, and this no longer works on the taskbar. The only way that I am aware of that still works is simulating a mouse move (click-move-release). I've read about that method, but I've never done it myself.
Here is a solution with PowerShell. My code is based on the solutions presented in the answers here:
2,3 | ForEach-Object {
$local:regPath = "HKCU:\$(
)SOFTWARE\Microsoft\Windows\$(
)CurrentVersion\Explorer\StuckRects$_"
$s = Get-ItemProperty $regPath |
Select-Object -ExpandProperty Settings
$s[12] = 2
Set-ItemProperty -Path $regPath -Name Settings -Value $s
}
# Restart the Explorer process so that registry is read again
Get-Process Explorer | Stop-Process
$local:stop = $false
do {
Start-Sleep -Seconds 5
$stop = Get-Process Explorer -ErrorAction SilentlyContinue
if( $stop ) { continue }
Write-Host -ForegroundColor Yellow "$(
)Explorer hasn't auto-started, attempting to restart..."
Start-Process Explorer
} until ( $stop )
The code will change to 2 (right-side) the 13th position of the Settings registry stream at the following keys:
HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2
HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3
Afterwards, it kills the explorer.exe process, waits around for 5 seconds and if explorer hasn't started again, it will start a new instance.
SHAppBarMessage(ABM_SETPOS,...)
In my experience the task bar on the left and right side clash unworkably with the rest of the experience. Even top has the problem that Preview appear outside the screen at the top.
For me this works in windows 11 to toggle task bar between top and bottom.
$RegistryPath = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3'
$Name = "Settings"
$NewValue = Get-ItemProperty -Path $RegistryPath
$NewValue.Settings[12] = 4-$NewValue.Settings[12]
Set-ItemProperty -Path $RegistryPath -Name $Name -Value $NewValue.Settings
Stop-Process -Name "Explorer"
Explorer is autmatically started when it is killed so there is no need to start it manually.