Jump to content
Sign in to follow this  

Dllcall does not work... partial

Recommended Posts

Dear all,

I have a Windows 8 tablet hanging on the living room wall which is running permanently. There's also a precense detector in the living room, which communicates with a miniserver. If a person is in the room, it will be detected and the server triggers a programm. This is where my autoit script takes part.
If someone is in the room, a diashow (screensaver) should be shown. Otherwise, the screen should be turned off (for energie savings).

This works, so far. I can start the screensaver and I can turn off the monitor. But I cannot turn it on again. What am I doing wrong? Has anybody a clue?

According to MSDN, it should work like this: https://msdn.microsoft.com/en-us/library/windows/desktop/ms646360(v=vs.85).aspx





Global Const $listen_IP         = IniRead("einstellungen.ini", "Netzwerk", "IP-Adresse", "")
Global Const $listen_PORT       = IniRead("einstellungen.ini", "Netzwerk", "IP-Adresse", "1989")
Global Const $CMD_SCREENSAVER   = "cmd_bildschirmschoner"
Global Const $CMD_MONITOR_AN    = "cmd_monitor_an"
Global Const $CMD_MONITOR_AUS   = "cmd_monitor_aus"
;~ Global Const $CMD_MOUSE_MOVE = "cmd_mouse_move"



#include "constants.au3"
#include <Constants.au3>


Local $ID_socket = TCPConnect($listen_IP, $listen_PORT)

If $CmdLine[0] >= 1 Then
   Switch $CmdLine[1]
   Case "-bildschirmschoner"
      TCPSend($ID_socket, $CMD_SCREENSAVER)
   Case "-an"
      TCPSend($ID_socket, $CMD_MONITOR_AN)
   Case "-aus"
      TCPSend($ID_socket, $CMD_MONITOR_AUS)
   Case Else
      MsgBox(0,"Fehler", $CmdLine[1] & " ist kein gültiger Paramter")
   MsgBox(0,"Fehler", "Parameter wird zwingend gebraucht" & @CRLF & @CRLF & "Bsp.:" & @CRLF & "miniserver.exe -bildschirmschoner" & @CRLF & "miniserver.exe -an" & @CRLF & "miniserver.exe -aus")




#include "constants.au3"


Local $ID_socket = TCPListen($listen_IP, $listen_PORT, 100)

While True
   Local $socket_established = -1
   Local $socket_received_data = Null

      $socket_established = TCPAccept($ID_socket)
   Until $socket_established <> -1

   $socket_received_data = TCPRecv($socket_established, 1024)


Func _do($TCP_DATA)
   Switch $TCP_DATA
      Local $result = DllCall("user32.dll", "hwnd", "GetDesktopWindow")
      DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $result[0], "uint", 0x0112, "wparam", 0xF140, "lparam", 0)
      DllCall('user32.dll', 'int', 'SendMessage', 'hwnd', WinGetHandle('[CLASS:Progman]'), 'int', 0x0112, 'int', 0xF170, 'int', -1)
      DllCall('user32.dll', 'int', 'SendMessage', 'hwnd', WinGetHandle('[CLASS:Progman]'), 'int', 0x0112, 'int', 0xF170, 'int', 2)

;~ https://msdn.microsoft.com/en-us/library/windows/desktop/ms646360(v=vs.85).aspx


Thank you in advance

Share this post

Link to post
Share on other sites

Does the line


in your tablet script really get called? You can check by placing a MsgBox before or after the DLLCall.

I'm not very experienced on DLLCalls, can you maybe wake the system up alternatively by moving the mouse a little bit?

Share this post

Link to post
Share on other sites

Yes, this case is called. I have already "debugged" this way.
If extended the skript by doing a MouseMove(1,1) and a Send("^")
The screen still doesn't turn on. Only if I am moving the real mouse, it works

Share this post

Link to post
Share on other sites

Weird, they both work fine for me on Windows 7. Is it an Windows 8 or Windows 10 tablet? You could try using 1 instead of 2 for the last argument to the DLLCall to put the monitor to sleep. It doesn't work on my machine but it may work on yours. 1 is sleep mode instead of power off.

Share this post

Link to post
Share on other sites

yes it is a windows 8 system. I've tried this on a windows 7 machine of a friend. It worked there. It really seems to be a windows 8 issue. thanks for pointing that out

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...