Jump to content

Recommended Posts

$x1 = InputBox("xx", "xxxx?")
if ($x1 = 1) Then
   MouseClick(132,393,1)
   Sleep(5000)

EndIf

 

So if I input 1 the if statement should work but it won't, what I wrong?

Share this post


Link to post
Share on other sites

You need to tell Mouse click which button to use: MouseClick ( "button" [, x, y [, clicks = 1 [, speed = 10]]] )

From the help file

#include <AutoItConstants.au3>

; Double click at the current mouse position.
MouseClick($MOUSE_CLICK_LEFT)
MouseClick($MOUSE_CLICK_LEFT)

; Double click at the x, y position of 0, 500.
MouseClick($MOUSE_CLICK_LEFT, 0, 500, 2)

; Double click at the x, y position of 0, 500. This is a better approach as it takes into account left/right handed users.
MouseClick($MOUSE_CLICK_PRIMARY, 0, 500, 2)

So this should do the trick :)

#include <AutoItConstants.au3>
$x1 = InputBox("xx", "xxxx?")
if ($x1 = 1) Then
   MouseClick($MOUSE_CLICK_LEFT,132,393,1)
   Sleep(5000)

EndIf

Cheers
/Rex

Share this post


Link to post
Share on other sites

Zag8888,

Welcome to the AutoIt forums.

For your future coding, as InputBox returns a string, you should really write the comparison as follows:

If ($xi = "1") Then

as AutoIt can sometimes give you unexpected results if you compare different datatypes. This is because its automatic data conversion "feature" might not convert the elements in the way you think it should. So it is always best to force the elements into the same datatype - string in this case.

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
4 minutes ago, Rex said:

You need to tell Mouse click which button to use: MouseClick ( "button" [, x, y [, clicks = 1 [, speed = 10]]] )

From the help file

#include <AutoItConstants.au3>

; Double click at the current mouse position.
MouseClick($MOUSE_CLICK_LEFT)
MouseClick($MOUSE_CLICK_LEFT)

; Double click at the x, y position of 0, 500.
MouseClick($MOUSE_CLICK_LEFT, 0, 500, 2)

; Double click at the x, y position of 0, 500. This is a better approach as it takes into account left/right handed users.
MouseClick($MOUSE_CLICK_PRIMARY, 0, 500, 2)

So this should do the trick :)

#include <AutoItConstants.au3>
$x1 = InputBox("xx", "xxxx?")
if ($x1 = 1) Then
   MouseClick($MOUSE_CLICK_LEFT,132,393,1)
   Sleep(5000)

EndIf

Cheers
/Rex

 

1 minute ago, Melba23 said:

Zag8888,

Welcome to the AutoIt forums.

For your future coding, as InputBox returns a string, you should really write the comparison as follows:

If ($xi = "1") Then

as AutoIt can sometimes give you unexpected results if you compare different datatypes. This is because its automatic data conversion "feature" might not convert the elements in the way you think it should. So it is always best to force the elements into the same datatype - string in this case.

M23

Thanks a lot! Now it works great!

Also how can I mouse click without use my mouse cursor?

Cheers :)

Share this post


Link to post
Share on other sites
13 minutes ago, Zag8888 said:

Also how can I mouse click without use my mouse cursor?

You can use ControlClick, but it doesn't use the mouse coordinates, it's used to click on a control.


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

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

  • Similar Content

    • By hendrikhe
      Hello,
      I am wondering how to "scroll" to left and right  (till the end ) on a webpage .
      Sending Arrow left/right only moves a bit, I wan to move isntaly to the end
      Up and down is easily done sending Page Up and Page Down.
      Any ideas?
      Greetings
      Hendrik
    • By Zag8888
      Hey folks, I have a little problem with my script.
      I have no experience with these things, and I know for  sure that my code is not the best, but please be lenient, thanks 😅
      The User should first choose 1 of the 2 Options to actually start the script. If 1 of the 2 Option is choosen then the User should click start again and all should work.
      I have already commented the problem, If the button Start is clicked before, the User will select just 1 of the 2 option and the program will start (Without clicking start).How can I set $Start to $GUI_UNCHECKED? I have already tried to use GuiCtrlSetState, but didnt worked.
       
      $Start = GuiCtrlCreateButton("Start", 20, 200, 90, 50,bitor($BS_CENTER,0,0)) GUICtrlSetOnEvent($Start,"Startallrun") Func Startallrun() If ((GUICtrlRead($Option1) = $GUI_UNCHECKED) And (GUICtrlRead($Option2) = $GUI_UNCHECKED)) Then MsgBox($MB_OK, "Error", "You have to select 1 Option") While (GUICtrlRead($Option1) = $GUI_UNCHECKED) Sleep(10) If (GUICtrlRead($Option1) = $GUI_CHECKED) Or (GUICtrlRead($Option2) = $GUI_CHECKED) Then GUICtrlSetState($Start,$GUI_UNCHECKED) ; This doesen't work for Buttons While (GUICtrlRead($Start) = $GUI_UNCHECKED) Sleep(10) If ($Start = $GUI_CHECKED) Then ; That's the problem. The script will start if I click one of the 2 options (because start was already checked before) ExitLoop EndIf WEnd ExitLoop EndIf WEnd Else If (GUICtrlRead($Option1) = $GUI_CHECKED) Then MsgBox($MB_OK, "Starting", "Start") Start() EndIf EndIf EndFunc  
    • By Silas
      Hello Internet,
      I am trying to create 10 labels, which all show a history of transactions, in order.
      Problem is, it get's confused when I try to use [$i] to create different variables. How can I create different labels and thus variables with this?
      For $i=1 to 10 Assign("PayH_" & $i, 20) ;Creates the variables for the values Global $PayHLabel_[$i] = GUICtrlCreateLabel($PayH_[$i], 30, 30) ;Creates the labels which show the values Next I know I can do this without a For Loop, but I am trying to learn how to keep my script short.
      Thanks in advance.
    • By Docfxit
      I'm getting an error in this script:
      Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) TrayTip("clears any tray tip","",0) AutoItSetOption("TrayIconDebug", 1) ;0-off #include "OSVersion.au3" Run('C:\Dnload\9xAddons\TestThis.exe') MsgBox("","Test","$ProgramFiles - " & $ProgramFiles & @CRLF & "_OSVersion() - " & _OSVersion()) Exit This is the error I am getting:

      The variables should be defined in the #include "OSVersion.au3"
      Func _OSVersion() Global $OSVersion Local $sWinVer = FileGetVersion('winver.exe') $OS_Version = @OSVersion $servicepack_version = StringReplace(@OSServicePack, "Service Pack ", "SP") If @error = -1 Then $servicepack_version = "" ConsoleWrite($OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '') & @CRLF) ConsoleWrite(@OSArch & @CRLF) If $OSVersion = 'Win7' Or $OSVersion = 'Win7SP1' Or $OSVersion = 'Win7X64' Or $OSVersion = 'Win7SP1x64' Then $ProgramFiles = "C:\Programs\" Else $ProgramFiles = "C:\Program Files\" EndIf Return $OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '') EndFunc ;==>_OSVersion What do I need to do to resolve the error?
      Thanks,
      Docfxit
    • By coles
      Hi All,
      Need a help with Autoit task, I am trying to copy an XML file and edit that XML file and copy it back
      The script i have attached if the script we use to copy files to client from server, so basically what it does is
      Going through a Set of IP address and 
      Map the drive Copy the file Write copy process was success Goes on a loop through IP's to check all machines have updated files   #include <File.au3> #include <iNet.au3> #include <_XMLDomWrapper.au3> func latestUpdate($address, $name) Local $result Local $hFileIndexHTML DriveMapDel ( "G:" ) ConsoleWrite('Trying: ' & $address & "/" & $name & @CRLF); $result = DriveMapAdd ( "G:", "\\" & $address & "\C$", 0, $name & "\adminname","adminpswd") ;Copying the file from Mapped drive to local if $result = 1 Then FileCopy( "G:\Program Files\test.xml", "C:\sample\test.xml", 1); ConsoleWrite('Copying Updated File: ' & $address & @CRLF); $hFileIndexHTML = FileOpen("C:\sample\test.txt", 1) FileWrite($hFileIndexHTML, $address & @CRLF) FileClose($hFileIndexHTML) EndIf EndFunc func done($file, $address) For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) if ( $address = $line ) Then ConsoleWrite('Already done: ' & $file & " " & $address & @CRLF); return true EndIf Next return false EndFunc func getMachineName($ipaddress) return _TCPIpToName($ipaddress) EndFunc func process($address) local $machineName $machineName = getMachineName($address) if ($machineName = "") Then ConsoleWrite("No machine found at:" & $address & @CRLF) Else ConsoleWrite("Machine found at:" & $address & " - " & $machineName & @CRLF) if ( done( "C:\sample\test.txt", $address) = false ) then if ( $machineName <> "" ) then latestUpdate($address, $machineName) else endif endif EndIf EndFunc TCPStartup() while 1=1 PROCESS("10.10.1.1") sleep( 1000 * 60 * 10) wend The XML file i am trying to copy is unique and different in all machines (Machine name,ID's etc), But whole structure is the same (ie, the num of lines ) [That's the reason i can't copy a single file to all the machines].
      I was thinking of using _FileWriteToLine  to replace 3 lines with new data 
      eg:
      _FileWriteToLine("c:\sample\test.xml", 71,  "<RIA>"http://goog.html"</RIA>", True) 
      _FileWriteToLine("c:\sample\test.xml", 350,  "<col header="Status" width="7%" dataFld="status_code" style="" preprocesser="processES" template="" hidden="0"/>", True) 
      _FileWriteToLine("c:\sample\test.xml", 650,  "<col header="Units" width="11%" dataFld="units" style="" preprocesser="" template="fU(units)" hidden="0"/>", True) 
      These lines inside XML  
      340<em>
      341<gd
      342-360 is similar as blah blah <col header="Status" width="7%" dataFld="status_code" style="" preprocesser="processES" template="" hidden="0"/>
      same goes for 650th line also
       
      I would like to get opinion of copying this file as this is a highly critical file needed to keep machines running
       
      Do you think using _file write to line is risky?. Do you think i have to copy the file from parent folder to another folder after replacing the lines and then copy from there back to client system. This is all what i can think now, Any comments/suggestions will be much appreciated.
       
       
       
       
       
×
×
  • Create New...