Jump to content
Sign in to follow this  
goldenix

DLL.CallFunction(User32.dll-> ShowCursor)

Recommended Posts

goldenix

So i searched the forum & the google & this code is used everywhere. But If I try to use it it does not work.

Maybe I need to use the _cdecl thing.? Tho I dont know how to do that.

$DllCall = DllCall("user32.dll","int","ShowCursor","int",0) ;hide cursor
ConsoleWrite($DllCall & @CRLF)
ConsoleWrite(@error & @CRLF)

Sleep(2000)

$DllCall = DllCall("user32.dll","int","ShowCursor","int",1) ; show
ConsoleWrite($DllCall & @CRLF)
ConsoleWrite(@error & @CRLF)
Edited by goldenix

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites
Malkey

So i searched the forum & the google & this code is used everywhere. But If I try to use it it does not work.

Maybe I need to use the _cdecl thing.? Tho I dont know how to do that.

$DllCall = DllCall("user32.dll","int","ShowCursor","int",0) ;hide cursor
ConsoleWrite($DllCall & @CRLF)
ConsoleWrite(@error & @CRLF)

Sleep(2000)

$DllCall = DllCall("user32.dll","int","ShowCursor","int",1) ; show
ConsoleWrite($DllCall & @CRLF)
ConsoleWrite(@error & @CRLF)
This is an example using _WinAPI_ShowCursor().

If you look in the WinAPI.au3 include file, _WinAPI_ShowCursor() uses DllCall("User32.dll", "int", "ShowCursor", "int", $fShow).

There is also a description in the help file, without an example.

;
#include <WinAPI.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

GUICreate("My GUI"); will create a dialog box that when displayed is centered
GUISetState(@SW_SHOW); will display an empty dialog box

$DllCall = _WinAPI_ShowCursor(False)
;$DllCall = DllCall("user32.dll", "int", "ShowCursor", "int", False)

ConsoleWrite($DllCall & @CRLF)
ConsoleWrite(@error & @CRLF)

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

$DllCall = DllCall("user32.dll", "int", "ShowCursor", "int", True)
;$DllCall = _WinAPI_ShowCursor(True)

ConsoleWrite($DllCall & @CRLF)
ConsoleWrite(@error & @CRLF)
;

Share this post


Link to post
Share on other sites
martin

This is an example using _WinAPI_ShowCursor().

If you look in the WinAPI.au3 include file, _WinAPI_ShowCursor() uses DllCall("User32.dll", "int", "ShowCursor", "int", $fShow).

There is also a description in the help file, without an example.

;
 #include <WinAPI.au3>
 #include <GUIConstantsEx.au3>
 #include <WindowsConstants.au3>
 
 GUICreate("My GUI"); will create a dialog box that when displayed is centered
 GUISetState(@SW_SHOW); will display an empty dialog box
 
 $DllCall = _WinAPI_ShowCursor(False)
;$DllCall = DllCall("user32.dll", "int", "ShowCursor", "int", False)
 
 ConsoleWrite($DllCall & @CRLF)
 ConsoleWrite(@error & @CRLF)
 
; Run the GUI until the dialog is closed
 While 1
     $msg = GUIGetMsg()
 
     If $msg = $GUI_EVENT_CLOSE Then ExitLoop
 WEnd
 
 $DllCall = DllCall("user32.dll", "int", "ShowCursor", "int", True)
;$DllCall = _WinAPI_ShowCursor(True)
 
 ConsoleWrite($DllCall & @CRLF)
 ConsoleWrite(@error & @CRLF)
;
Maybe goldenix wants to hide the cursor for another application.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
SmOke_N

So i searched the forum & the google & this code is used everywhere. But If I try to use it it does not work.

Maybe I need to use the _cdecl thing.? Tho I dont know how to do that.

$DllCall = DllCall("user32.dll","int","ShowCursor","int",0) ;hide cursor
ConsoleWrite($DllCall & @CRLF)
ConsoleWrite(@error & @CRLF)

Sleep(2000)

$DllCall = DllCall("user32.dll","int","ShowCursor","int",1) ; show
ConsoleWrite($DllCall & @CRLF)
ConsoleWrite(@error & @CRLF)
To answer this question specifically. What doesn't work?

If you're asking why $DllCall doesn't return a value in your ConsoleWrite, then that's because you didn't use an array for the value (ie... $DllCall[0]).

If you're asking why @error always returns zero, well with the way you have it setup, you're checking the @error of the first ConsoleWrite and not the actual DllCall().


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
goldenix

Maybe goldenix wants to hide the cursor for another application.

I thought I can hide my cursor universally for all application. I was wrong?

I would like to hide my cursor for Irfanview window. Is it possible to do that? Or notepad window? I tried also like in the second example but my codes do not work. :D

$Window     = WinGetHandle("[CLASS:IrfanView]")
$Window     = " - IrfanView"oÝ÷ Ù«­¢+Ù=ÁÐ ÅÕ½Ðí]¥¹Q¥Ñ±5Ñ¡5½ÅÕ½Ðì°Ð¤ìÄõÍÑÉаÈõÍÕMÑÈ°ÌõáаÐõÙ¹°´ÄѼ´Ðõ9½Í(ÀÌØí¡]¹$$ô]¥¹Ñ!¹± ÅÕ½Ðím
1MLé9½ÑÁtÅÕ½Ðì¤()]¥¹Ñ¥ÙÑ ÀÌØí¡]¹¤((ÀÌØí±±
±°$ô±±
±° ÅÕ½ÐíÕÍÈÌȹ±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐíM¡½Ý
ÕÉͽÈÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°À¤$$$í¡¥ÕÉͽÈ(ÀÌØí±±
±°$ô±±
±° ÅÕ½ÐíÕÍÈÌȹ±°ÅÕ½Ðì°ÅÕ½Ðí¡]¹ÅÕ½Ðì°ÅÕ½ÐíMÑ
ÁÑÕÉÅÕ½Ðì°ÅÕ½Ðí¡]¹ÅÕ½Ðì°ÀÌØí¡]¹¤íMÑ
ÁÑÕÉ´$¡Ù¹¼¥Ý¡Ð¥ÌÑ¡¥Ì½È()M±À ÈÀÀÀ¤((ÀÌØí±±
±°$ô±±
±° ÅÕ½ÐíÕÍÈÌȹ±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐíM¡½Ý
ÕÉͽÈÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°Ä¤$$$íÍ¡½ÜÕÉͽÈ(ÀÌØí±±
±°ô±±
±° ÅÕ½ÐíÕÍÈÌȹ±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐíI±Í
ÁÑÕÉÅÕ½Ðì¤()á¥Ð

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites
goldenix

To answer this question specifically. What doesn't work?

I cant edit my last post the %#¤/&/¤&% thing again.

The code wont hide my cursor. Simply noting happens.


My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites
martin

I cant edit my last post the %#¤/&/¤&% thing again.

The code wont hide my cursor. Simply noting happens.

If you want to hide the mouse cursor from every app then you could do something like

#include <GUIConstantsEx.au3>
  #include <WindowsConstants.au3>
  #include <WinAPI.au3>
  #include <misc.au3>
  HotKeySet("{ESC}","DoQuit")
  GUICreate("My GUI",2,2,0,0,$WS_POPUP); will create a dialog box that when displayed is centered
  GUISetBkColor(0)
  GUISetState(@SW_SHOW); will display an empty dialog box
  mousemove(1,1)
  _mousetrap(0,0,2,2)
  $DllCall = _WinAPI_ShowCursor(False)
;$DllCall = DllCall("user32.dll", "int", "ShowCursor", "int", False)
  
  ConsoleWrite($DllCall & @CRLF)
  ConsoleWrite(@error & @CRLF)
  
; Run the GUI until the dialog is closed
  While 1
      $msg = GUIGetMsg()
  
      If $msg = $GUI_EVENT_CLOSE Then DoQuit()
  
  WEnd
  
  $DllCall = DllCall("user32.dll", "int", "ShowCursor", "int", True)
;$DllCall = _WinAPI_ShowCursor(True)
  
  ConsoleWrite($DllCall & @CRLF)
  ConsoleWrite(@error & @CRLF)
  
  
  Func DoQuit()
      _MouseTrap()
      Exit
  EndFunc

and if you want to stop the mouse from being over a certain window you could do this to make the mouse pass straight through.

;mgrefmousepassthrough
 $lastx = MouseGetPos(0)
  $lasty = MouseGetPos(1)
  While 1
      $np = WinGetPos("Untitled - Notepad");or whatever title you want
      $mp = MouseGetPos()
  
      If $mp[0] >=$np[0] And $mp[0] <= $np[0] + $np[2] And _
              $mp[1] >= $np[1] And $mp[1] <= $np[1] + $np[3] Then
          If $lastx < $np[0] Then
              MouseMove($np[0] + $np[2] + 10, $mp[1],0)
          ElseIf $lastx > $np[0] + $np[2] Then
              MouseMove($np[0] - 10, $mp[1],0)
          ElseIf $lasty < $np[1] Then
              MouseMove($mp[0], $np[1] + $np[3] + 10,0)
          Else
              MouseMove($mp[0], $np[1] - 10,0)
          EndIf
  
      Else
      $lastx = MouseGetPos(0)
      $lasty = MouseGetPos(1)
      EndIf
  WEnd
Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
goldenix

.....

Seems its my fault for not explaining why i need this. I sort images 500 000 images left to sort. So I need autoit to reduce mouse movement, clicking & key presses.

1) I click once at the image thumbnail & then IrfanView window is opened & I see the image.
2) Mouse cursor is hidden now until I move the mouse in any direction by $range = 20.
3) if mouse was moved by €range > 20 then winclose(IrfanView) & show cursor again.

As you see, I must hide the mouse somehow because its disturbing when I view the image.

That first code only moves my mouse in to the left top corner of my monitor & does not hide the mouse. So it does not do anything.

That second sample, I understand the idea, but in my case it is out of the question, because I will need to move the mouse like a lunatic in the result. I mean this image sorting puts serious stress on my wrist. :D

So my DLL call was correct? I also tried with True & false & nothing. can it be something is wrong with my Windows?

However this sample hire works & hides the cursor, but only for the GUI created by autoit (Wont hide the cursor for the notepad or Irfan window):

#691096

Edited by goldenix

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites
SmOke_N

Simply hiding the cursor from view, doesn't necessarily mean that it won't show up with WM_MOUSMOVE on infranviews GUI window. Why not just lock the mouse in place until you are done with the window?


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
goldenix

Why not just lock the mouse in place until you are done with the window?

From my experience I can say, that to close the window by moving the mouse a little is very effective. It speeds up my sorting a lot. other vise I would have to make additional half a million button presses on my keyboard = more time will be spent + more stress on my wrists.

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.